Index: src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java (revision 1380849) +++ src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java (working copy) @@ -346,13 +346,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. @@ -366,11 +366,11 @@ case INCLUDE_AND_SEEK_NEXT_COL: Filter f = matcher.getFilter(); - results.add(f == null ? kv : f.transform(kv)); + outResult.add(f == null ? kv : f.transform(kv)); + count++; if (qcode == ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_ROW) { if (!matcher.moreRowsMayExistAfter(kv)) { - outResult.addAll(results); return false; } reseek(matcher.getKeyForNextRow(kv)); @@ -381,29 +381,23 @@ } cumulativeMetric += kv.getLength(); - 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; } @@ -438,9 +432,7 @@ } } - if (!results.isEmpty()) { - // copy jazz - outResult.addAll(results); + if (count > 0) { return true; }