Skip to content

Commit

Permalink
Add a way to clear the bloom filter
Browse files Browse the repository at this point in the history
  • Loading branch information
zapek committed Dec 10, 2023
1 parent 857f809 commit a9669f7
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@

public class TurtleBloomFilter extends AbstractBloomFilter<Sha1Sum>
{
private BitArray bArray;

protected TurtleBloomFilter(int expectedInsertions, double falsePositiveProbability)
{
super(expectedInsertions, falsePositiveProbability, (sha1Sum, byteSink) -> byteSink.putBytes(sha1Sum.getBytes()));
//super(expectedInsertions, falsePositiveProbability);
}

@Override
protected BitArray createBitArray(int numBits)
{
try
{
return new MMapFileBackedBitArray(new File("foo"), numBits);
bArray = new MMapFileBackedBitArray(new File("foo"), numBits);
return bArray;
}
catch (Exception e)
{
Expand All @@ -52,4 +54,9 @@ public boolean contains(Sha1Sum value)
{
return super.contains(value.getBytes()); // XXX: the following workaround is needed until https://github.com/sangupta/bloomfilter/pull/5 is merged and a new upstream release is done
}

public void clear()
{
bArray.clear();
}
}

0 comments on commit a9669f7

Please sign in to comment.