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

dict.computeCapacity 函数的作用没看明白 #48

Closed
poettian opened this issue Jan 1, 2022 · 2 comments
Closed

dict.computeCapacity 函数的作用没看明白 #48

poettian opened this issue Jan 1, 2022 · 2 comments

Comments

@poettian
Copy link

poettian commented Jan 1, 2022

如题,调用 dict.MakeConcurrent 创建 ConcurrentDict 时,会先用该函数计算shardCount,但是这个函数的算法没明白时啥意思,作者能辛苦解惑一下吗?谢谢

@ewenliu
Copy link

ewenliu commented Jan 5, 2022

@poettian Hi, 该算法的含义是求比param大的最近2次幂,比如:

1、当param为24的时候,比24大的最近2次幂是2^5 = 32
2、当param为33的时候,比33大的最近2次幂是2^6 = 64

可以自己代入上述两个值计算每一步,就知道为什么要这么写了。

@poettian
Copy link
Author

poettian commented Jan 8, 2022

明白了,多谢

@poettian poettian closed this as completed Jan 8, 2022
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

2 participants