Skip to content

Commit

Permalink
MINOR: Use clear method to speed up removal (#18400)
Browse files Browse the repository at this point in the history
Reviewers: Apoorv Mittal <apoorvmittal10@gmail.com>, Andrew Schofield <aschofield@confluent.io>
  • Loading branch information
tedyu authored Jan 6, 2025
1 parent 2521aee commit c116354
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions core/src/main/java/kafka/server/share/SharePartition.java
Original file line number Diff line number Diff line change
Expand Up @@ -1755,10 +1755,7 @@ be removed once all the messages (0-99) are acknowledged (ACCEPT or REJECT).
}

if (lastKeyToRemove != -1) {
NavigableMap<Long, InFlightBatch> subMap = cachedState.subMap(firstKeyToRemove, true, lastKeyToRemove, true);
for (Long key : subMap.keySet()) {
cachedState.remove(key);
}
cachedState.subMap(firstKeyToRemove, true, lastKeyToRemove, true).clear();
}
} finally {
lock.writeLock().unlock();
Expand Down

0 comments on commit c116354

Please sign in to comment.