How Java Hadoop Mapper can send multiple values

前端 未结 2 663
渐次进展
渐次进展 2021-01-04 23:51

My mapper needs to send the following tuples:


And I want to send to reducer the custID as a key, and as value th

2条回答
  •  离开以前
    2021-01-05 00:33

    The simplest I can think of is just to merge them into a single string:

    output.collect(custID, prodID + "," + rate);
    

    Then, split if back up on the reducers.

    If you post a little more code from your mapper maybe we could give a better example.

    UPDATE: That said, you asked for the best way. The most correct way is probably to create a separate class grouping prodID and rate together and send that.

提交回复
热议问题