bloomfilter-rb
bloomfilter-rb copied to clipboard
Fix crc32 overload
In order to fix crc32 overload issue, I introduced the built-in crc32 Zlib.crc32.
This version is no longer compatible with previous versions.
I'm not used to ruby native extension coding, so please review it and give me some advice.
Hmm, not sure this is the right approach.. If I'm reading this correctly, you removed crc32 step and replaced it with a simple modulo? The pure Ruby version looks good, but the native implementation needs to call the Ruby's crc32.
Thank you so much for your review and advice.
The index is computed based on Zlib.crc32.
https://github.com/igrigorik/bloomfilter-rb/pull/39/files#diff-127d145f47af4cdb51891aad435aba5aR28
And the Zlib.crc32 is given to native code through block.
(So index is not simple modulo.)
https://github.com/igrigorik/bloomfilter-rb/pull/39/files#diff-5fcfefdfe790e195f24687d8aac68f5dR90
I'm not sure how to call ruby's built-in crc32 directly from native code, so I used block mechanism to pass the hash function to native code.
@n-nishizawa ah, gotcha.. missed the block callback.
That's going to be a costly roundtrip. Let's see if we can make it a direct call..
Thank you very much for your comment. I'm worried about the cost issue too.
Yeah, I also will find how to call the crc32 directly.