Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于hash分片计算方法,请赐教 #77

Open
YoungNong opened this issue Jan 7, 2017 · 2 comments
Open

关于hash分片计算方法,请赐教 #77

YoungNong opened this issue Jan 7, 2017 · 2 comments

Comments

@YoungNong
Copy link

单实例下,现有128个分库,8039709005,5907536637 这两个字符串,我用他们的hashcode取值后,对1024取模,结果是543,-383。怎么算也不在一个库里。请教下,字符串是怎么计算分片的

@zhukunqian
Copy link

PartitionByString.java 对字符串计算分片,里面有计算hash的函数。

hashcode & 1023 得到的应该在哪个分片上。

@hexianmao
Copy link
Member

(hashcode & 1023)等价于(hashcode % 1024),主要是为了提高性能。落在哪个分片要看hashcode具体的值。 @zhukunqian

@alibaba alibaba deleted a comment from tupunco Aug 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants