alexandrnikitin / bloom-filter-scala

Bloom filter for Scala, the fastest for JVM
https://alexandrnikitin.github.io/blog/bloom-filter-for-scala/
MIT License
376 stars 57 forks source link

How to get the filter element size #35

Closed safetys123 closed 6 years ago

safetys123 commented 6 years ago

How to get the filter element size. Google guava has a method approximateElementCount() to get elements size.

alexandrnikitin commented 6 years ago

@safetys123 Thank you for raising the issue. I didn't know that it has such feature. It seems they added it in recent versions. Do you have a particular use case in your mind?

To implement that feature one needs to implement getBitCount in UnsafeBitArray and use the formula from the guava source code 😉 https://github.com/alexandrnikitin/bloom-filter-scala/blob/0a1265e07934d3c33ba7e0c1971eabea80b5b528/bloom-filter/src/main/scala/bloomfilter/mutable/UnsafeBitArray.scala#L51-L53

Guava code of approximateElementCount() for reference https://github.com/google/guava/blob/207e0716eb9d2540c072d3003a643e80b75f8fc5/guava/src/com/google/common/hash/BloomFilter.java#L191

Will you have time to do it? I'll be happy to merge it!

safetys commented 6 years ago

@alexandrnikitin I just know a litter java, don't know scala, so I don't know how to add this function. I want to know how many elements in bloom filter, if tow much, I need to buy a server with more memory. Guava sometimes has a error, memery not enough, use you much better and fast. Thank you.

safetys123 commented 6 years ago

@alexandrnikitin Can you add the approximateElementCount() function when you are free. 😊 I just want to know how many element in the filter.

SidWeng commented 6 years ago

@alexandrnikitin I send a PR #37 for this issue, please review it.

alexandrnikitin commented 6 years ago

That's great! Thank you!

alexandrnikitin commented 6 years ago

@SidWeng I've made some fixes to the code #38 PTAL

SidWeng commented 6 years ago

38 👍 Thanks for your fixes!

alexandrnikitin commented 6 years ago

@SidWeng Thank you for your help! I've released v0.11.0, will be soon on maven. Please take a look.

Closed via #37 and #38

SidWeng commented 6 years ago

@alexandrnikitin v0.11.0 is still not on maven, should I wait more time or anything goes wrong?

alexandrnikitin commented 6 years ago

@SidWeng I've republished it again. I see that it's on sonatype already so should be on maven soon. I'm sorry for the inconvenience.

SidWeng commented 6 years ago

@alexandrnikitin Already on maven, thanks a lot!