This is an automated email from the ASF dual-hosted git repository.
xiangying pushed a commit to branch branch-2.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-2.10 by this push:
new 73b30a399dc Avoid unnecessary creation of BitSetRecyclable objects
(#17998)
73b30a399dc is described below
commit 73b30a399dc78829dd9f630f810f1ca6cc498507
Author: LinChen <[email protected]>
AuthorDate: Thu Oct 13 09:51:48 2022 +0800
Avoid unnecessary creation of BitSetRecyclable objects (#17998)
Co-authored-by: leolinchen <[email protected]>
(cherry picked from commit 6c65ca0d8a80bfaaa4d5869e0cea485f5c94369b)
---
.../org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git
a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
index c3e0426957d..62070a076cf 100644
---
a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
+++
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
@@ -2117,11 +2117,12 @@ public class ManagedCursorImpl implements ManagedCursor
{
individualDeletedMessages);
}
} else if (config.isDeletionAtBatchIndexLevelEnabled() &&
batchDeletedIndexes != null) {
- BitSetRecyclable bitSet =
batchDeletedIndexes.computeIfAbsent(position, (v) ->
- BitSetRecyclable.create().resetWords(position.ackSet));
BitSetRecyclable givenBitSet =
BitSetRecyclable.create().resetWords(position.ackSet);
- bitSet.and(givenBitSet);
- givenBitSet.recycle();
+ BitSetRecyclable bitSet =
batchDeletedIndexes.computeIfAbsent(position, (v) -> givenBitSet);
+ if (givenBitSet != bitSet) {
+ bitSet.and(givenBitSet);
+ givenBitSet.recycle();
+ }
if (bitSet.isEmpty()) {
PositionImpl previousPosition =
ledger.getPreviousPosition(position);
individualDeletedMessages.addOpenClosed(previousPosition.getLedgerId(),