Alex Rivera | Logout

Why use a bitwise AND here?

Asked 2011-02-05T01:09:34.597
13

I was reading through the hadoop code and found this line in a partitioner.

(key.hashCode() & Integer.MAX_VALUE) % numReduceTasks

Why are they using the bitwise AND?

Edit
Report

1 Answer

18

To remove the sign bit. in the case that the hashCode is a negative number. its like Math.abs(key.hashCode())

answered 2011-02-05T01:11:57.963

Your Answer