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:
Doug Meil 2012-01-11 21:54:23 +00:00
parent 90a11d367f
commit ce09411591
1 changed files with 6 additions and 2 deletions

View File

@ -263,8 +263,12 @@ Scan scan = new Scan();
scan.addColumn(Bytes.toBytes("cf"),Bytes.toBytes("attr"));
scan.setStartRow( Bytes.toBytes("row")); // start key is inclusive
scan.setStopRow( Bytes.toBytes("row" + (char)0)); // stop key is exclusive
for(Result result : htable.getScanner(scan)) {
// process Result instance
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!
}
</programlisting>
</para>