diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedStoreScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedStoreScanner.java index 7bd580d..e35400d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedStoreScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedStoreScanner.java @@ -124,7 +124,6 @@ class ReversedStoreScanner extends StoreScanner implements KeyValueScanner { public boolean seekToPreviousRow(KeyValue key) throws IOException { lock.lock(); try { - checkReseek(); return this.heap.seekToPreviousRow(key); } finally { lock.unlock(); @@ -136,7 +135,6 @@ class ReversedStoreScanner extends StoreScanner implements KeyValueScanner { public boolean backwardSeek(KeyValue key) throws IOException { lock.lock(); try { - checkReseek(); return this.heap.backwardSeek(key); } finally { lock.unlock(); 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 e30bf59..31f1210 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 @@ -420,8 +420,6 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner public boolean seek(KeyValue key) throws IOException { lock.lock(); try { - // reset matcher state, in case that underlying store changed - checkReseek(); return this.heap.seek(key); } finally { lock.unlock(); @@ -438,10 +436,6 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner public boolean next(List outResult, int limit) throws IOException { lock.lock(); try { - if (checkReseek()) { - return true; - } - // if the heap was left null, then the scanners had previously run out anyways, close and // return. if (this.heap == null) { @@ -619,9 +613,8 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner try { if (this.closing) return; - // All public synchronized API calls will call 'checkReseek' which will cause - // the scanner stack to reseek if this.heap==null && this.lastTop != null. - // But if two calls to updateReaders() happen without a 'next' or 'peek' then we + // We will cause the scanner stack to reseek if this.lastTop != null. + // But if this.lastTop was null, this.heap remain null. Then we // will end up calling this.peek() which would cause a reseek in the middle of a updateReaders // which is NOT what we want, not to mention could cause an NPE. So we early out here. if (this.heap == null) return; @@ -629,37 +622,22 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner // this could be null. this.lastTop = this.peek(); - //DebugPrint.println("SS updateReaders, topKey = " + lastTop); - // close scanners to old obsolete Store files this.heap.close(); // bubble thru and close all scanners. this.heap = null; // the re-seeks could be slow (access HDFS) free up memory ASAP - // Let the next() call handle re-creating and seeking - } finally { - lock.unlock(); - } - } - - /** - * @return true if top of heap has changed (and KeyValueHeap has to try the - * next KV) - * @throws IOException - */ - protected boolean checkReseek() throws IOException { - if (this.heap == null && this.lastTop != null) { + if (this.lastTop != null) { resetScannerStack(this.lastTop); if (this.heap.peek() == null || store.getComparator().compareRows(this.lastTop, this.heap.peek()) != 0) { LOG.debug("Storescanner.peek() is changed where before = " + this.lastTop.toString() + ",and after = " + this.heap.peek()); - this.lastTop = null; - return true; } this.lastTop = null; // gone! } - // else dont need to reseek - return false; + } finally { + lock.unlock(); + } } protected void resetScannerStack(KeyValue lastTopKey) throws IOException { @@ -730,10 +708,6 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner public boolean reseek(KeyValue kv) throws IOException { lock.lock(); try { - //Heap will not be null, if this is called from next() which. - //If called from RegionScanner.reseek(...) make sure the scanner - //stack is reset if needed. - checkReseek(); if (explicitColumnQuery && lazySeekEnabledGlobally) { return heap.requestSeek(kv, true, useRowColBloom); }