HBASE-6711 Avoid local results copy in StoreScanner

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1380868 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
larsh 2012-09-04 20:34:53 +00:00
parent d97362910c
commit ef562b7760
1 changed files with 5 additions and 15 deletions

View File

@ -358,13 +358,13 @@ public class StoreScanner extends NonLazyKeyValueScanner
KeyValue kv;
KeyValue prevKV = null;
List<KeyValue> results = new ArrayList<KeyValue>();
// Only do a sanity-check if store and comparator are available.
KeyValue.KVComparator comparator =
store != null ? store.getComparator() : null;
long cumulativeMetric = 0;
int count = 0;
try {
LOOP: while((kv = this.heap.peek()) != null) {
// Check that the heap gives us KVs in an increasing order.
@ -387,7 +387,6 @@ public class StoreScanner extends NonLazyKeyValueScanner
this.countPerRow > (storeLimit + storeOffset)) {
// do what SEEK_NEXT_ROW does.
if (!matcher.moreRowsMayExistAfter(kv)) {
outResult.addAll(results);
return false;
}
reseek(matcher.getKeyForNextRow(kv));
@ -400,12 +399,12 @@ public class StoreScanner extends NonLazyKeyValueScanner
if (metric != null) {
cumulativeMetric += kv.getLength();
}
results.add(kv);
outResult.add(kv);
count++;
}
if (qcode == ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_ROW) {
if (!matcher.moreRowsMayExistAfter(kv)) {
outResult.addAll(results);
return false;
}
reseek(matcher.getKeyForNextRow(kv));
@ -415,29 +414,22 @@ public class StoreScanner extends NonLazyKeyValueScanner
this.heap.next();
}
if (limit > 0 && (results.size() == limit)) {
if (limit > 0 && (count == limit)) {
break LOOP;
}
continue;
case DONE:
// copy jazz
outResult.addAll(results);
return true;
case DONE_SCAN:
close();
// copy jazz
outResult.addAll(results);
return false;
case SEEK_NEXT_ROW:
// This is just a relatively simple end of scan fix, to short-cut end
// us if there is an endKey in the scan.
if (!matcher.moreRowsMayExistAfter(kv)) {
outResult.addAll(results);
return false;
}
@ -472,9 +464,7 @@ public class StoreScanner extends NonLazyKeyValueScanner
}
}
if (!results.isEmpty()) {
// copy jazz
outResult.addAll(results);
if (count > 0) {
return true;
}