Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java (revision 1379915) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java (working copy) @@ -358,13 +358,13 @@ KeyValue kv; KeyValue prevKV = null; - List results = new ArrayList(); // 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 @@ 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 @@ 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 @@ 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 @@ } } - if (!results.isEmpty()) { - // copy jazz - outResult.addAll(results); + if (count > 0) { return true; }