Skip to content

Commit

Permalink
Avoid unnecessary creation of BitSetRecyclable objects (apache#17998)
Browse files Browse the repository at this point in the history
Co-authored-by: leolinchen <leolinchen@tencent.com>
(cherry picked from commit 6c65ca0)
  • Loading branch information
lordcheng10 authored and liangyepianzhou committed Dec 14, 2022
1 parent a5a3a10 commit 73b30a3
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2117,11 +2117,12 @@ public void asyncDelete(Iterable<Position> positions, AsyncCallbacks.DeleteCallb
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(),
Expand Down

0 comments on commit 73b30a3

Please sign in to comment.