lhotari commented on code in PR #17465:
URL: https://github.com/apache/pulsar/pull/17465#discussion_r962884348


##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/ConcurrentOpenLongPairRangeSet.java:
##########
@@ -242,6 +242,27 @@ public Range<T> lastRange() {
         return Range.openClosed(consumer.apply(lastSet.getKey(), lower), 
consumer.apply(lastSet.getKey(), upper));
     }
 
+    @Override
+    public int cardinality(long lowerKey, long lowerValue, long upperKey, long 
upperValue) {
+        NavigableMap<Long, BitSet> subMap = rangeBitSetMap.subMap(lowerKey, 
true, upperKey, true);
+        MutableInt v = new MutableInt(0);
+        subMap.forEach((ledgerId, bitset) -> {
+            if (ledgerId == lowerKey || ledgerId == upperKey) {
+                BitSet temp = (BitSet) bitset.clone();
+                if (ledgerId == lowerKey) {
+                    temp.clear(0, (int) Math.max(0, lowerValue));
+                }
+                if (ledgerId == upperKey) {
+                    temp.clear((int) Math.min(upperValue + 1, temp.length()), 
temp.length());
+                }

Review Comment:
   I seem to understand why it's needed, however it would be useful to add a 
comment



-- 
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]

Reply via email to