Replace BloomFilter underlying BitSet with cats-collections immutable BitSet#774
Replace BloomFilter underlying BitSet with cats-collections immutable BitSet#774regadas wants to merge 5 commits into
Conversation
|
If we are going to make a new implementation, I'd like to explore a pattern @non and I have found for parameterized monoids: final class BloomFilter[A](hashes: Int, width: Int)(implicit val hasher: Hasher[A]) {
sealed class BF[A] {
def mightContain(a: A): Boolean
}
final case class BFInstance[A](toValue: A) extends BF[A]
final case class BFSet(toBitSet: BitSet) extends BF[A]
// ...
def apply(a: A): BF[A] = ...
implicit val monoid: Monoid[BF[A]] = ...
}Then you use it with: val bloomFilter: BloomFilter[A] = new BloomFilter(4, 1024)
val itemA1: bloomFilter.BF[A] = bloomFilter(a1)
val itemA2: bloomFilter.BF[A] = bloomFilter(a2)
val a3 = Monoid.plus(itemA1, itemA2)Now, the type system prevents us from confusing bloom filter values from different parameter sets. Also, the serializers can be inside |
|
what do you think? |
|
Sounds good! ... I've been meaning to pick this up again! I'll explore that! A few notes around this PR:
|
See #716 for context.
Update: #716 (comment)