aherbert commented on code in PR #406:
URL:
https://github.com/apache/commons-collections/pull/406#discussion_r1275113962
##########
src/main/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilter.java:
##########
@@ -77,22 +77,79 @@ public interface CountingBloomFilter extends BloomFilter,
BitCountProducer {
*/
boolean isValid();
+ /**
+ * Returns maximum value for a cell in this Counting filter.
+ * @return the maximum value for a cell in this Counting filter.
+ */
+ int getMaxCell();
+
+ /**
+ * Determines the maximum number of times the Bloom filter could have been
inserted
+ * into this counting filter.
+ * @param bloomFilter the Bloom filter the check for.
+ * @return the maximum number of times the Bloom filter could have been
inserted.
+ */
+ default int getMaxInsert(BloomFilter bloomFilter) {
+ return getMaxInsert((BitMapProducer) bloomFilter);
+ }
+
+ /**
+ * Determines the maximum number of times the IndexProducer could have
been inserted
+ * into this counting filter.
+ * @param idxProducer the producer to drive the count check.
+ * @return the maximum number of times the IndexProducer could have been
inserted.
+ */
+ default int getMaxInsert(IndexProducer idxProducer) {
+ return getMaxInsert( BitMapProducer.fromIndexProducer(idxProducer,
getShape().getNumberOfBits()));
Review Comment:
whitespace `( BitMap`
##########
src/test/java/org/apache/commons/collections4/bloomfilter/AbstractCountingBloomFilterTest.java:
##########
@@ -289,6 +291,50 @@ public void testExcludesDuplicates() {
bf1.merge(hasher);
bf1.remove(hasher);
assertEquals(0, bf1.cardinality());
- assertTrue(bf1.forEachCount((x, y) -> false), "Hasher in removes
results in value not equal to 0");
+ assertTrue(bf1.forEachCell((x, y) -> false), "Hasher in removes
results in value not equal to 0");
+ }
+
+ private void verifyMaxInsert( CountingBloomFilter bf, int from1, int
from11) {
+ BloomFilter bfFrom0 = new
DefaultBloomFilterTest.SparseDefaultBloomFilter(getTestShape());
+ bfFrom0.merge(new IncrementingHasher(0, 1));
+ BloomFilter bfFrom1 = new
DefaultBloomFilterTest.SparseDefaultBloomFilter(getTestShape());
+ bfFrom1.merge(TestingHashers.FROM1);
+ BloomFilter bfFrom11 = new
DefaultBloomFilterTest.SparseDefaultBloomFilter(getTestShape());
+ bfFrom11.merge(TestingHashers.FROM11);
+
+ assertEquals( 0, bf.getMaxInsert(new IncrementingHasher(0, 1)));
Review Comment:
No whitespace after `assertEquals(`
##########
src/main/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilter.java:
##########
@@ -164,17 +221,17 @@ default boolean merge(final BitMapProducer
bitMapProducer) {
/**
* Removes the specified Bloom filter from this Bloom filter.
*
- * <p>Specifically: all counts for the indexes identified by the {@code
other} filter will be decremented by 1.</p>
+ * <p>Specifically: all cells for the indexes identified by the {@code
other} filter will be decremented by 1.</p>
*
- * <p>Note: If the other filter is a counting Bloom filter the index
counts are ignored and it is treated as an
+ * <p>Note: If the other filter is a counting Bloom filter the othre
filter's cells are ignored and it is treated as an
Review Comment:
`othre`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]