HBASE-4556 Fix all incorrect uses of InternalScanner.next(...)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1183016 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
larsh 2011-10-13 18:07:04 +00:00
parent 98bc9cc829
commit 9814ffbaf0
3 changed files with 15 additions and 10 deletions

View File

@ -354,6 +354,7 @@ Release 0.92.0 - Unreleased
HBASE-4555 TestShell seems passed, but actually errors seen in test output
file (Mingjie Lai)
HBASE-4582 Store.java cleanup (failing TestHeapSize and has warnings)
HBASE-4556 Fix all incorrect uses of InternalScanner.next(...) (Lars H)
TESTS
HBASE-4450 test for number of blocks read: to serve as baseline for expected

View File

@ -1146,7 +1146,9 @@ public class Store implements HeapSize {
// we have to use a do/while loop.
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>();
// Limit to "hbase.hstore.compaction.kv.max" (default 10) to avoid OOME
while (scanner.next(kvs,this.compactionKVMax)) {
boolean hasMore;
do {
hasMore = scanner.next(kvs, this.compactionKVMax);
if (writer == null && !kvs.isEmpty()) {
writer = createWriterInTmp(maxKeyCount,
this.compactionCompression);
@ -1176,7 +1178,7 @@ public class Store implements HeapSize {
}
}
kvs.clear();
}
} while (hasMore);
} finally {
if (scanner != null) {
scanner.close();

View File

@ -19,6 +19,12 @@
*/
package org.apache.hadoop.hbase.util;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Random;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
@ -44,12 +50,6 @@ import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.InternalScanner;
import org.apache.hadoop.hbase.regionserver.wal.HLog;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Random;
/**
* A non-instantiable class that has a static method capable of compacting
* a table by merging adjacent regions.
@ -370,14 +370,16 @@ class HMerge {
try {
List<KeyValue> results = new ArrayList<KeyValue>();
while(rootScanner.next(results)) {
boolean hasMore;
do {
hasMore = rootScanner.next(results);
for(KeyValue kv: results) {
HRegionInfo info = Writables.getHRegionInfoOrNull(kv.getValue());
if (info != null) {
metaRegions.add(info);
}
}
}
} while (hasMore);
} finally {
rootScanner.close();
try {