Index: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java (revision 1573923) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java (working copy) @@ -517,24 +517,16 @@ @Override public int reseekTo(byte[] key, int offset, int length) throws IOException { - int compared; if (isSeeked()) { - compared = compareKey(reader.getComparator(), key, offset, length); - if (compared < 1) { - // If the required key is less than or equal to current key, then - // don't do anything. - return compared; - } else { - if (this.nextIndexedKey != null && - (this.nextIndexedKey == HConstants.NO_NEXT_INDEXED_KEY || - reader.getComparator().compareFlatKey(key, offset, length, - nextIndexedKey, 0, nextIndexedKey.length) < 0)) { - // The reader shall continue to scan the current data block instead of querying the - // block index as long as it knows the target key is strictly smaller than - // the next indexed key or the current data block is the last data block. - return loadBlockAndSeekToKey(this.block, this.nextIndexedKey, - false, key, offset, length, false); - } + if (this.nextIndexedKey != null && + (this.nextIndexedKey == HConstants.NO_NEXT_INDEXED_KEY || + reader.getComparator().compareFlatKey(key, offset, length, + nextIndexedKey, 0, nextIndexedKey.length) < 0)) { + // The reader shall continue to scan the current data block instead of querying the + // block index as long as it knows the target key is strictly smaller than + // the next indexed key or the current data block is the last data block. + return loadBlockAndSeekToKey(this.block, this.nextIndexedKey, + false, key, offset, length, false); } } // Don't rewind on a reseek operation, because reseek implies that we are Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java (revision 1573923) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java (working copy) @@ -292,19 +292,6 @@ KeyValueScanner scanner; while ((scanner = heap.poll()) != null) { - KeyValue topKey = scanner.peek(); - if (comparator.getComparator().compare(seekKey, topKey) <= 0) { - // Top KeyValue is at-or-after Seek KeyValue. We only know that all - // scanners are at or after seekKey (because fake keys of - // scanners where a lazy-seek operation has been done are not greater - // than their real next keys) but we still need to enforce our - // invariant that the top scanner has done a real seek. This way - // StoreScanner and RegionScanner do not have to worry about fake keys. - heap.add(scanner); - current = pollRealKV(); - return current != null; - } - boolean seekResult; if (isLazy && heap.size() > 0) { // If there is only one scanner left, we don't do lazy seek. @@ -318,6 +305,10 @@ scanner.close(); } else { heap.add(scanner); + // We still need to enforce our invariant that the top scanner has done a real seek. + // This way StoreScanner and RegionScanner do not have to worry about fake keys. + current = pollRealKV(); + return current != null; } }