Skip to content

Add support 128bit hash #22

@C0deUser

Description

@C0deUser

Hello!

Please, add support 128bit hash (unsigned int)

from rbloom import Bloom
from xxhash import xxh3_128_intdigest

bf = Bloom(10_000, 0.01, xxh3_128_intdigest)
bf.add("hello")                             # Gives this error: OverflowError - int too big to convert 

I use next workaround as suggested in your example:

from rbloom import Bloom
from xxhash import xxh3_128_digest

def hash_func(obj):
    hash_bytes = xxh3_128_digest(obj)
    return int.from_bytes(hash_bytes, "big", signed=True)

bf = Bloom(10_000, 0.01, hash_func)
bf.add("hello")

This works as expected.

But surely it shouldn't matter to a Bloom filter whether an integer between -2^127 and 2^127 is 1, or an unsigned integer? A workaround would add overhead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions