0
我有两个不同的数据集。Hadoop在Maper或Reducer末端使用java加入两个不同的数据集结束
***Comments.csv:***
id
userid
***Posts.csv-***
id
post_type
creationdate
score
viewcount
owneruserid
title
answercount
commentcount
我的显示名称,没有。由获得最大声望的用户创建的帖子。
我知道Map Reduce如何使用单个文件工作的代码。我知道如何为Job设置多个文件。但我不知道如何在Mapper级别加入不同的数据集。
我不确定是否可以用一个Mapper连接这两个数据集。
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
String[] data = value.toString().split(",");
// Logic to write values to context
}
MultipleInputs.addInputPath(job,new Path(args[0]),TextInputFormat.class,CommentsMapper.class);
MultipleInputs.addInputPath(job,new Path(args[1]),TextInputFormat.class,PostsMapper.class);
我的查询:
1. Map side join or Reduce side join : Which one is better?.
2. Is it possible to use single Mapper or Reducer? If yes, how is it possible?
我提供输入以简单的方式来实现这一目标。我已经通过Stackoverflow关于多个数据文件的问题,但输入格式是相同的所有这些文件。在我的情况下,输入格式不同。
在此先感谢。
您不能在映射器中加入不同的数据集。这就是Reducer的全部,你需要一个才能得到你想要的结果。如果您只想使用一个映射器的单个实例,我可能会建议只编写一个单线程作业而不使用Hadoop? –
好的。如果是Reducer方面加入,如何实现呢?我已经更新了这个问题 –