如果你忘记了关闭ResultScanners,会导致RegionServer出现问题。
所以一定要把ResultScanner包含在try/catch 块中...
Scan scan = new Scan();
// set attrs...
ResultScanner rs = htable.getScanner(scan);
try {
for (Result r = rs.next(); r != null; r = rs.next()) {
// process result...
} finally {
rs.close(); // always close the ResultScanner!
}
htable.close();
这与其说是提高性能,倒不如说是避免发生性能问题。