This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new abc8b430d56 HBASE-29253 Avoid allocating a new closure on every row
processed by StoreScanner (#6901)
abc8b430d56 is described below
commit abc8b430d56fc338fe9f7f4e04cd1e626966878a
Author: Charles Connell <[email protected]>
AuthorDate: Sun Apr 20 04:30:28 2025 -0400
HBASE-29253 Avoid allocating a new closure on every row processed by
StoreScanner (#6901)
Signed-off-by: Duo Zhang <[email protected]>
---
.../apache/hadoop/hbase/regionserver/StoreScanner.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
index 52aafa5c52e..7fe649c87a4 100644
---
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
+++
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
@@ -25,6 +25,7 @@ import java.util.NavigableSet;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.ReentrantLock;
+import java.util.function.IntConsumer;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil;
@@ -590,6 +591,13 @@ public class StoreScanner extends
NonReversedNonLazyKeyValueScanner
Optional<RpcCall> rpcCall =
matcher.isUserScan() ? RpcServer.getCurrentCall() : Optional.empty();
+ // re-useable closure to avoid allocations
+ IntConsumer recordBlockSize = blockSize -> {
+ if (rpcCall.isPresent()) {
+ rpcCall.get().incrementBlockBytesScanned(blockSize);
+ }
+ scannerContext.incrementBlockProgress(blockSize);
+ };
int count = 0;
long totalBytesRead = 0;
@@ -631,12 +639,7 @@ public class StoreScanner extends
NonReversedNonLazyKeyValueScanner
scannerContext.returnImmediately();
}
- heap.recordBlockSize(blockSize -> {
- if (rpcCall.isPresent()) {
- rpcCall.get().incrementBlockBytesScanned(blockSize);
- }
- scannerContext.incrementBlockProgress(blockSize);
- });
+ heap.recordBlockSize(recordBlockSize);
prevCell = cell;
scannerContext.setLastPeekedCell(cell);