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方面加入,如何實現呢?我已經更新了這個問題 –