You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/06/29 09:00:32 UTC

[GitHub] [commons-collections] aherbert commented on a diff in pull request #316: Modified forEachBitMap

aherbert commented on code in PR #316:
URL: https://github.com/apache/commons-collections/pull/316#discussion_r909380561


##########
src/main/java/org/apache/commons/collections4/bloomfilter/ArrayCountingBloomFilter.java:
##########
@@ -231,7 +231,29 @@ public boolean forEachIndex(IntPredicate consumer) {
     @Override
     public boolean forEachBitMap(LongPredicate consumer) {
         Objects.requireNonNull(consumer, "consumer");
-        return BitMapProducer.fromIndexProducer(this, shape.getNumberOfBits()).forEachBitMap(consumer);
+        int blocksm1 = BitMap.numberOfBitMaps(shape.getNumberOfBits()) - 1;

Review Comment:
   `final int blocksm1`



##########
src/main/java/org/apache/commons/collections4/bloomfilter/ArrayCountingBloomFilter.java:
##########
@@ -231,7 +231,29 @@ public boolean forEachIndex(IntPredicate consumer) {
     @Override
     public boolean forEachBitMap(LongPredicate consumer) {
         Objects.requireNonNull(consumer, "consumer");
-        return BitMapProducer.fromIndexProducer(this, shape.getNumberOfBits()).forEachBitMap(consumer);
+        int blocksm1 = BitMap.numberOfBitMaps(shape.getNumberOfBits()) - 1;
+        int i = 0;
+        long value;
+        // must break final block separate as the the number of bits may not fall on the long boundary

Review Comment:
   Remove `the the`



##########
src/main/java/org/apache/commons/collections4/bloomfilter/ArrayCountingBloomFilter.java:
##########
@@ -231,7 +231,29 @@ public boolean forEachIndex(IntPredicate consumer) {
     @Override
     public boolean forEachBitMap(LongPredicate consumer) {
         Objects.requireNonNull(consumer, "consumer");
-        return BitMapProducer.fromIndexProducer(this, shape.getNumberOfBits()).forEachBitMap(consumer);
+        int blocksm1 = BitMap.numberOfBitMaps(shape.getNumberOfBits()) - 1;

Review Comment:
   Although it is the same number I would prefer `counts.length` here and not `shape.getNumberOfBits()` since it is the total length of the counts array that is being iterated over.



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org