@@ -342,13 +342,30 @@ public StoreScanner(ScanInfo scanInfo, ScanType scanType,
342342 seekAllScanner (scanInfo , scanners );
343343 }
344344
345+ // Used to instantiate a scanner for user scan in test
346+ @ VisibleForTesting
347+ StoreScanner (Scan scan , ScanInfo scanInfo , NavigableSet <byte []> columns ,
348+ List <? extends KeyValueScanner > scanners , ScanType scanType ) throws IOException {
349+ // 0 is passed as readpoint because the test bypasses Store
350+ this (null , scan , scanInfo , columns != null ? columns .size () : 0 , 0L , scan .getCacheBlocks (),
351+ scanType );
352+ if (scanType == ScanType .USER_SCAN ) {
353+ this .matcher =
354+ UserScanQueryMatcher .create (scan , scanInfo , columns , oldestUnexpiredTS , now , null );
355+ } else {
356+ this .matcher = CompactionScanQueryMatcher .create (scanInfo , scanType , Long .MAX_VALUE ,
357+ HConstants .OLDEST_TIMESTAMP , oldestUnexpiredTS , now , null , null , null );
358+ }
359+ seekAllScanner (scanInfo , scanners );
360+ }
361+
345362 // Used to instantiate a scanner for user scan in test
346363 @ VisibleForTesting
347364 StoreScanner (Scan scan , ScanInfo scanInfo , NavigableSet <byte []> columns ,
348365 List <? extends KeyValueScanner > scanners ) throws IOException {
349366 // 0 is passed as readpoint because the test bypasses Store
350- this (null , scan , scanInfo , columns != null ? columns .size () : 0 , 0L ,
351- scan . getCacheBlocks (), ScanType .USER_SCAN );
367+ this (null , scan , scanInfo , columns != null ? columns .size () : 0 , 0L , scan . getCacheBlocks (),
368+ ScanType .USER_SCAN );
352369 this .matcher =
353370 UserScanQueryMatcher .create (scan , scanInfo , columns , oldestUnexpiredTS , now , null );
354371 seekAllScanner (scanInfo , scanners );
@@ -569,7 +586,8 @@ public boolean next(List<Cell> outResult, ScannerContext scannerContext) throws
569586
570587 int count = 0 ;
571588 long totalBytesRead = 0 ;
572- boolean onlyFromMemstore = true ;
589+ // track the cells for metrics only if it is a user read request.
590+ boolean onlyFromMemstore = matcher .isUserScan ();
573591 try {
574592 LOOP : do {
575593 // Update and check the time limit based on the configured value of cellsPerTimeoutCheck
@@ -747,7 +765,7 @@ public boolean next(List<Cell> outResult, ScannerContext scannerContext) throws
747765 return scannerContext .setScannerState (NextState .NO_MORE_VALUES ).hasMoreValues ();
748766 } finally {
749767 // increment only if we have some result
750- if (count > 0 ) {
768+ if (count > 0 && matcher . isUserScan () ) {
751769 // if true increment memstore metrics, if not the mixed one
752770 updateMetricsStore (onlyFromMemstore );
753771 }
0 commit comments