You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by dm...@apache.org on 2012/01/11 22:54:24 UTC

svn commit: r1230271 - /hbase/trunk/src/docbkx/book.xml

Author: dmeil
Date: Wed Jan 11 21:54:23 2012
New Revision: 1230271

URL: http://svn.apache.org/viewvc?rev=1230271&view=rev
Log:
hbase-5180 book.xml  - the scanner example wasn't closing the ResultScanner.  That's not good practice.

Modified:
    hbase/trunk/src/docbkx/book.xml

Modified: hbase/trunk/src/docbkx/book.xml
URL: http://svn.apache.org/viewvc/hbase/trunk/src/docbkx/book.xml?rev=1230271&r1=1230270&r2=1230271&view=diff
==============================================================================
--- hbase/trunk/src/docbkx/book.xml (original)
+++ hbase/trunk/src/docbkx/book.xml Wed Jan 11 21:54:23 2012
@@ -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>