Skip to content
Advertisement

Duplicate “values” for some key in map-reduce java program

I am new in mapreduce and hadoop (hadoop 3.2.3 and java 8). I am trying to separate some lines based on a symbol in a line. Example: “q1,a,q0,” should be return (‘a’,”q1,a,q0,”) as (key, value). My dataset contains ten(10) lines , five(5) for key ‘a’ and five for key ‘b’.

I expect to get 5 line for each key but i always get five for ‘a’ and 10 for ‘b’

Data

JavaScript

Mapper class:

JavaScript

Reducer class:

JavaScript

Driver class:

JavaScript

Advertisement

Answer

The problem was solved by putting the variable “count” inside the function “Reduce()”.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement