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

It's doesn't work with bigint

Open fsdevblog opened this issue 8 years ago • 0 comments

I need to push to store around 300 millions of records I have to use BloomFilter::Native, because Redis string has limit 512Mb.

My calculations:

count_elements = 300_000_000
false_positive = 1.0E-6

m = BigDecimal(((count_elements * Math.log(false_positives)) / Math.log(1.0 / 2 ** Math.log(2))).to_s) # => 8626552539
k = (Math.log(2.0) * m / count_elements).ceil # => 20

But, it's doesn't work with bigint

Exception `RangeError' at /home/fsdev/.rvm/gems/ruby-2.4.1@test/gems/bloomfilter-rb-2.1.1/lib/bloomfilter/native.rb:20 - integer 8626552539 too big to convert to `int'
/home/fsdev/.rvm/gems/ruby-2.4.1@test/gems/bloomfilter-rb-2.1.1/lib/bloomfilter/native.rb:20:in `new': integer 8626552539 too big to convert to `int' (RangeError)
        from /home/fsdev/rvm/gems/ruby-2.4.1@test/gems/bloomfilter-rb-2.1.1/lib/bloomfilter/native.rb:20:in `initialize'

:((( Илья, выручай :)

fsdevblog avatar Jan 03 '18 17:01 fsdevblog