Jason918 commented on code in PR #18042:
URL: https://github.com/apache/pulsar/pull/18042#discussion_r997734670


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -1868,7 +1868,15 @@ public void asyncMarkDelete(final Position position, 
Map<String, Long> propertie
 
         if (config.isDeletionAtBatchIndexLevelEnabled() && batchDeletedIndexes 
!= null) {
             if (newPosition.ackSet != null) {
-                batchDeletedIndexes.put(newPosition, 
BitSetRecyclable.create().resetWords(newPosition.ackSet));
+                lock.writeLock().lock();
+                try {
+                    BitSetRecyclable givenBitSet = 
BitSetRecyclable.create().resetWords(newPosition.ackSet);
+                    batchDeletedIndexes.compute(newPosition,
+                            (k, v) -> v == null || givenBitSet.nextSetBit(0) > 
v.nextSetBit(0)
+                                    ? givenBitSet : v);

Review Comment:
   I am curious why not use the result of `givenBitSet & v` instead of choosing 
between them? 



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