bloomfilter-rb icon indicating copy to clipboard operation
bloomfilter-rb copied to clipboard

Fix crc32 overload

Open n-nishizawa opened this issue 10 years ago • 4 comments
trafficstars

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.

n-nishizawa avatar Aug 06 '15 04:08 n-nishizawa

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.

igrigorik avatar Aug 06 '15 20:08 igrigorik

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 avatar Aug 06 '15 21:08 n-nishizawa

@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..

igrigorik avatar Aug 07 '15 21:08 igrigorik

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.

n-nishizawa avatar Aug 09 '15 00:08 n-nishizawa