gpt4 book ai didi

hadoop - Hadoop 中使用 DBInputFormat 的多输入

转载 作者:可可西里 更新时间:2023-11-01 15:41:42 26 4
gpt4 key购买 nike

在我的数据库中,我有多个表,每个表都是不同的实体类型。我有一个在 hadoop 中使用的 Avro 模式,它是这些不同实体类型的所有字段的联合,加上它有一个实体类型字段。

我想做的是为每个实体类型设置一个 DBInputFormat 和一个 DBWritable,将实体类型映射到组合的 Avro 类型。然后将每个 DBInputFormat 赋予 MultipleInputs 之类的东西,以便我可以创建复合输入格式。然后可以将复合输入格式提供给我的 map reduce 作业,这样来自所有表的所有数据都可以由同一个映射器类同时处理。

数据不断添加到这些数据库表中,因此我需要能够为每个实体类型/dbtable 配置 DBInputFormat 以仅获取新数据并正确进行拆分。

基本上,我需要 DBInputFormat 或 DataDrivenDBInputFormat 的功能,但也需要将它们组合起来的能力,类似于您可以使用路径和 MultipleInputs 所做的事情。

最佳答案

从 N 个输入表创建一个 View ,并在 DBInputFormat#setInput 中设置 View 。根据 Cloudera article .因此,我想在作业完成时不应更新表中的数据。

Hadoop may need to execute the same query multiple times. It will need to return the same results each time. So any concurrent updates to your database, etc, should not affect the query being run by your MapReduce job. This can be accomplished by disallowing writes to the table while your MapReduce job runs, restricting your MapReduce’s query via a clause such as “insert_date < yesterday,” or dumping the data to a temporary table in the database before launching your MapReduce process.

评估支持实时处理的框架,如 Storm , HStreaming , S4Strembases .其中有些位于 Hadoop 之上,有些则没有,有些是 FOSS,有些是商业的。

关于hadoop - Hadoop 中使用 DBInputFormat 的多输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8351356/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com