HBASE-14826 Small improvement in KVHeap seek() API (Ram)

This commit is contained in:
ramkrishna 2015-11-24 10:16:35 +05:30
parent daba867734
commit afc5439be5
1 changed files with 6 additions and 4 deletions

View File

@ -297,11 +297,9 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
if (current == null) { if (current == null) {
return false; return false;
} }
heap.add(current);
current = null;
KeyValueScanner scanner; KeyValueScanner scanner = current;
while ((scanner = heap.poll()) != null) { while (scanner != null) {
Cell topKey = scanner.peek(); Cell topKey = scanner.peek();
if (comparator.getComparator().compare(seekKey, topKey) <= 0) { if (comparator.getComparator().compare(seekKey, topKey) <= 0) {
// Top KeyValue is at-or-after Seek KeyValue. We only know that all // Top KeyValue is at-or-after Seek KeyValue. We only know that all
@ -329,6 +327,10 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner
} else { } else {
heap.add(scanner); heap.add(scanner);
} }
scanner = heap.poll();
if (scanner == null) {
current = null;
}
} }
// Heap is returning empty, scanner is done // Heap is returning empty, scanner is done