Why use a bitwise AND here?
I wa开发者_开发技巧s 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?
To remove the sign bit. in the case that the hashCode is a negative number.
its like Math.abs(key.hashCode())
精彩评论