From efc32c83ba21f59e68bbfd4d56ae777251b42b8b Mon Sep 17 00:00:00 2001 From: sershe Date: Fri, 19 Apr 2013 02:29:54 +0000 Subject: [PATCH] HBASE-8264 expose the number of seen KVs from StoreScanner git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1469668 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/hbase/regionserver/StoreScanner.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 fe77b11fb3f..fb0ac388404 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 @@ -73,6 +73,12 @@ public class StoreScanner extends NonLazyKeyValueScanner protected final long oldestUnexpiredTS; protected final int minVersions; + /** + * The number of KVs seen by the scanner. Includes explicitly skipped KVs, but not + * KVs skipped via seeking to next row/column. TODO: estimate them? + */ + private long kvsScanned = 0; + /** We don't ever expect to change this, the constant is just for clarity. */ static final boolean LAZY_SEEK_ENABLED_BY_DEFAULT = true; public static final String STORESCANNER_PARALLEL_SEEK_ENABLE = @@ -390,6 +396,7 @@ public class StoreScanner extends NonLazyKeyValueScanner int count = 0; LOOP: while((kv = this.heap.peek()) != null) { + ++kvsScanned; // Check that the heap gives us KVs in an increasing order. assert prevKV == null || comparator == null || comparator.compare(prevKV, kv) <= 0 : "Key " + prevKV + " followed by a " + "smaller key " + kv + " in cf " + store; @@ -649,5 +656,12 @@ public class StoreScanner extends NonLazyKeyValueScanner static void enableLazySeekGlobally(boolean enable) { lazySeekEnabledGlobally = enable; } + + /** + * @return The estimated number of KVs seen by this scanner (includes some skipped KVs). + */ + public long getEstimatedNumberOfKvsScanned() { + return this.kvsScanned; + } }