[英]Hadoop joining two different data sets using java at Maper or Reducer end
我有兩個不同的數據集。
***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?
請提供輸入以簡單的方式實現這一目標。 我經歷了關於多個數據文件到Job的Stackoverflow問題,但是所有這些文件的輸入格式都是相同的。 就我而言,輸入格式是不同的。
提前致謝。
要執行reduce side join,可以讓地圖實現發出
(K,V) -> (JOIN_KEY,DATA)
。
然后,在簡化方面,您將可以訪問與該鍵關聯的所有值。 例如,如果您想確保列表中的文章數據首先位於列表中,然后所有的注釋數據都位於列表之后,則可以實施第二種排序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.