in src/main/java/org/apache/commons/collections4/bloomfilter/SimpleBloomFilter.java [106:131]
public boolean merge(final BitMapProducer bitMapProducer) {
Objects.requireNonNull(bitMapProducer, "bitMapProducer");
try {
final int[] idx = new int[1];
bitMapProducer.forEachBitMap(value -> {
bitMap[idx[0]++] |= value;
return true;
});
// idx[0] will be limit+1 so decrement it
idx[0]--;
final int idxLimit = BitMap.getLongIndex(shape.getNumberOfBits());
if (idxLimit == idx[0]) {
final long excess = bitMap[idxLimit] >> shape.getNumberOfBits();
if (excess != 0) {
throw new IllegalArgumentException(
String.format("BitMapProducer set a bit higher than the limit for the shape: %s",
shape.getNumberOfBits()));
}
}
cardinality = -1;
} catch (final IndexOutOfBoundsException e) {
throw new IllegalArgumentException(
String.format("BitMapProducer should send at most %s maps", bitMap.length), e);
}
return true;
}