From 7f2b33dbbf90474a8f73e4d38ea8f6817ee3dcdb Mon Sep 17 00:00:00 2001 From: eshcar Date: Sun, 17 May 2015 23:01:40 +0300 Subject: [PATCH] HBASE-13071 synchronous scanner -- cache size-in-bytes bug fix Signed-off-by: stack --- .../hbase/client/ClientAsyncPrefetchScanner.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientAsyncPrefetchScanner.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientAsyncPrefetchScanner.java index c4eb4783c7b..f0903dba0f0 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientAsyncPrefetchScanner.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientAsyncPrefetchScanner.java @@ -104,10 +104,7 @@ public class ClientAsyncPrefetchScanner extends ClientScanner { while (isPrefetchRunning()) { // prefetch running or still pending if (getCacheCount() > 0) { - Result res = cache.poll(); - long estimatedSize = calcEstimatedSize(res); - addEstimatedSize(-estimatedSize); - return res; + return pollCache(); } else { // (busy) wait for a record - sleep Threads.sleep(1); @@ -115,7 +112,7 @@ public class ClientAsyncPrefetchScanner extends ClientScanner { } if (getCacheCount() > 0) { - return cache.poll(); + return pollCache(); } // if we exhausted this scanner before calling close, write out the scan metrics @@ -209,6 +206,12 @@ public class ClientAsyncPrefetchScanner extends ClientScanner { return cacheSizeInBytes.get(); } + private Result pollCache() { + Result res = cache.poll(); + long estimatedSize = calcEstimatedSize(res); + addEstimatedSize(-estimatedSize); + return res; + } private class PrefetchRunnable implements Runnable {