congbobo184 commented on a change in pull request #8256:
URL: https://github.com/apache/pulsar/pull/8256#discussion_r511715307



##########
File path: 
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/PositionImpl.java
##########
@@ -81,6 +82,64 @@ public long getEntryId() {
         return entryId;
     }
 
+    public int compareToWithAckSet(PositionImpl other) {
+        checkNotNull(other);
+        int result = ComparisonChain.start().compare(this.ledgerId, 
other.ledgerId).compare(this.entryId, other.entryId)
+                .result();
+        if (result == 0) {
+            if (other.ackSet == null && ackSet == null) {
+                return result;
+            }
+            checkNotNull(other.ackSet);
+            checkNotNull(ackSet);
+            BitSetRecyclable otherAckSet = 
BitSetRecyclable.valueOf(other.ackSet);
+            BitSetRecyclable thisAckSet = BitSetRecyclable.valueOf(ackSet);
+            if (otherAckSet.equals(thisAckSet)) {
+                return result;
+            }
+            otherAckSet.and(thisAckSet);
+            boolean flag = otherAckSet.equals(thisAckSet);
+            thisAckSet.recycle();
+            otherAckSet.recycle();
+            return flag ? 1 : 0;
+        }
+        return result;
+    }
+
+    public boolean isAckSetRepeated(PositionImpl other) {
+        if (ackSet == null || other.ackSet == null) {
+            return false;
+        }
+        checkNotNull(other);
+        checkNotNull(ackSet);
+        checkNotNull(other.ackSet);
+        BitSetRecyclable thisAckSet = BitSetRecyclable.valueOf(ackSet);
+        BitSetRecyclable otherAckSet = BitSetRecyclable.valueOf(other.ackSet);
+        if (otherAckSet.size() < thisAckSet.size()) {
+            otherAckSet.set(otherAckSet.size(), thisAckSet.size());
+        }
+        thisAckSet.flip(0, thisAckSet.size());
+        otherAckSet.flip(0, otherAckSet.size());
+        thisAckSet.and(otherAckSet);
+        boolean isAckSetRepeated = !thisAckSet.isEmpty();
+        thisAckSet.recycle();
+        otherAckSet.recycle();
+        return isAckSetRepeated;
+    }
+
+    public void andAckSet(PositionImpl other) {
+        checkNotNull(other);
+        checkNotNull(ackSet);
+        checkNotNull(other.ackSet);
+        BitSetRecyclable thisAckSet = BitSetRecyclable.valueOf(ackSet);
+        BitSetRecyclable otherAckSet = BitSetRecyclable.valueOf(other.ackSet);
+        if (otherAckSet.size() < thisAckSet.size()) {
+            otherAckSet.set(otherAckSet.size(), thisAckSet.size());
+        }
+        thisAckSet.and(otherAckSet);
+        this.ackSet = thisAckSet.toLongArray();
+    }

Review comment:
       it has move to PendingAckHandleImpl




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to