I have the following code and I didn't understand why get()
method has been used in the highlighted line. If I remove that get()
method it throws me an error.
What I can take out from it is: get()
method returns the int value of the IntWritable. Correct me if I am wrong.
public void reduce(IntWritable key, Iterator<IntWritable> values, OutputCollector<IntWritable, IntWritable> output, Reporter reporter) throws IOException {
int sum = 0;
while (values.hasNext()) {
sum += values.next().get(); //error when removing the get()
}
}