hbase-5180 book.xml - the scanner example wasn't closing the ResultScanner. That's not good practice.
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1230271 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
90a11d367f
commit
ce09411591
|
@ -263,8 +263,12 @@ Scan scan = new Scan();
|
||||||
scan.addColumn(Bytes.toBytes("cf"),Bytes.toBytes("attr"));
|
scan.addColumn(Bytes.toBytes("cf"),Bytes.toBytes("attr"));
|
||||||
scan.setStartRow( Bytes.toBytes("row")); // start key is inclusive
|
scan.setStartRow( Bytes.toBytes("row")); // start key is inclusive
|
||||||
scan.setStopRow( Bytes.toBytes("row" + (char)0)); // stop key is exclusive
|
scan.setStopRow( Bytes.toBytes("row" + (char)0)); // stop key is exclusive
|
||||||
for(Result result : htable.getScanner(scan)) {
|
ResultScanner rs = htable.getScanner(scan);
|
||||||
// process Result instance
|
try {
|
||||||
|
for (Result r = rs.next(); r != null; r = rs.next()) {
|
||||||
|
// process result...
|
||||||
|
} finally {
|
||||||
|
rs.close(); // always close the ResultScanner!
|
||||||
}
|
}
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
Loading…
Reference in New Issue