Claudenw commented on code in PR #406:
URL:
https://github.com/apache/commons-collections/pull/406#discussion_r1283566165
##########
src/main/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilter.java:
##########
@@ -103,40 +172,41 @@ default boolean merge(final BloomFilter other) {
/**
* Merges the specified Hasher into this Bloom filter.
*
- * <p>Specifically: all counts for the unique indexes identified by the
{@code hasher} will be incremented by 1.</p>
+ * <p>Specifically: all cells for the unique indexes identified by the
{@code hasher} will be incremented by 1.</p>
*
* <p>This method will return {@code true} if the filter is valid after
the operation.</p>
*
* @param hasher the hasher
* @return {@code true} if the removal was successful and the state is
valid
* @see #isValid()
- * @see #add(BitCountProducer)
+ * @see #add(CellProducer)
*/
@Override
default boolean merge(final Hasher hasher) {
Objects.requireNonNull(hasher, "hasher");
- return merge(hasher.uniqueIndices(getShape()));
+ return merge(hasher.indices(getShape()));
}
/**
* Merges the specified index producer into this Bloom filter.
*
- * <p>Specifically: all counts for the indexes identified by the {@code
indexProducer} will be incremented by 1.</p>
+ * <p>Specifically: all unique cells for the indices identified by the
{@code indexProducer} will be incremented by 1.</p>
*
* <p>This method will return {@code true} if the filter is valid after
the operation.</p>
*
- * <p>Note: Indices that are returned multiple times will be incremented
multiple times.</p>
+ * <p>Note: If indices that are returned multiple times should be
incremented multiple times convert the IndexProducer
+ * to a CellProducer and add that.</p>
*
* @param indexProducer the IndexProducer
* @return {@code true} if the removal was successful and the state is
valid
* @see #isValid()
- * @see #add(BitCountProducer)
+ * @see #add(CellProducer)
*/
@Override
default boolean merge(final IndexProducer indexProducer) {
Objects.requireNonNull(indexProducer, "indexProducer");
try {
- return add(BitCountProducer.from(indexProducer));
+ return add(CellProducer.from(indexProducer.uniqueIndices()));
} catch (final IndexOutOfBoundsException e) {
Review Comment:
We do this because BloomFilter throws and IndexOutOfBoundsException if any
index is <0 or >=bitCount.
--
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]