|
25 | 25 | import java.util.Optional; |
26 | 26 | import java.util.concurrent.CountDownLatch; |
27 | 27 | import java.util.concurrent.locks.ReentrantLock; |
| 28 | +import java.util.function.IntConsumer; |
28 | 29 | import org.apache.hadoop.hbase.Cell; |
29 | 30 | import org.apache.hadoop.hbase.CellComparator; |
30 | 31 | import org.apache.hadoop.hbase.CellUtil; |
@@ -588,6 +589,13 @@ public boolean next(List<? super ExtendedCell> outResult, ScannerContext scanner |
588 | 589 |
|
589 | 590 | Optional<RpcCall> rpcCall = |
590 | 591 | matcher.isUserScan() ? RpcServer.getCurrentCall() : Optional.empty(); |
| 592 | + // re-useable closure to avoid allocations |
| 593 | + IntConsumer recordBlockSize = blockSize -> { |
| 594 | + if (rpcCall.isPresent()) { |
| 595 | + rpcCall.get().incrementBlockBytesScanned(blockSize); |
| 596 | + } |
| 597 | + scannerContext.incrementBlockProgress(blockSize); |
| 598 | + }; |
591 | 599 |
|
592 | 600 | int count = 0; |
593 | 601 | long totalBytesRead = 0; |
@@ -629,12 +637,7 @@ public boolean next(List<? super ExtendedCell> outResult, ScannerContext scanner |
629 | 637 | scannerContext.returnImmediately(); |
630 | 638 | } |
631 | 639 |
|
632 | | - heap.recordBlockSize(blockSize -> { |
633 | | - if (rpcCall.isPresent()) { |
634 | | - rpcCall.get().incrementBlockBytesScanned(blockSize); |
635 | | - } |
636 | | - scannerContext.incrementBlockProgress(blockSize); |
637 | | - }); |
| 640 | + heap.recordBlockSize(recordBlockSize); |
638 | 641 |
|
639 | 642 | prevCell = cell; |
640 | 643 | scannerContext.setLastPeekedCell(cell); |
|
0 commit comments