KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
My mapper needs to send the following tuples: <custID,prodID,rate> And I want to send to reducer the custID as a key, and as value the prodID and rate together, as they are needed for the reduce phase. Which is the best way of doing this? public void map(Object key, Text value, Context context) throws IOException, InterruptedException { String[] col = value.toString().split(","); custID.set(col[0]); data.set(col[1] + "," + col[2]); context.write(custID, data); } public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException { for (Text val : values) { String[] temp = val.toString().split(","); Text rate = new Text(temp[1]); result.set(rate); context.write(key, result); } }
Tags (comma-separated)
Save Edits
Cancel