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

Approximated Size returns 0 for a saturated bitset on amd64 #104

Open
rotemiman opened this issue Aug 21, 2024 · 0 comments
Open

Approximated Size returns 0 for a saturated bitset on amd64 #104

rotemiman opened this issue Aug 21, 2024 · 0 comments

Comments

@rotemiman
Copy link

rotemiman commented Aug 21, 2024

It seems that Go's behavior when casting Positive Infinity to uint32 is architecture specific. This causes theApproximatedSize calculation to return an inconsistent value between architectures.

If you run this:

saturatedBloom := bloom.FromWithM(bitset.New(10000).Complement().Bytes(), 10000, 4)
fmt.Println(saturatedBloom.ApproximatedSize())

In amd64, it prints 0, while if you run it on arm64, it prints the max value for uint32.

For a smaller example:

fmt.Println(uint32(math.Inf(1)))

Is equivalent.

I'd expect a saturated bloom to return a very high number and not zero, so I'd propose checking first for a saturated bloom and returning max uint32 explicitly.

See: golang/go#56023

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

1 participant