开发者

Why use a bitwise AND here?

开发者 https://www.devze.com 2023-02-08 11:26 出处:网络
I wa开发者_开发技巧s reading through the hadoop code and found this line in a partitioner. (key.hashCode() & Integer.MAX_VALUE) % numReduceTasks

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())

0

精彩评论

暂无评论...
验证码 换一张
取 消