1. Example code:
Scan
scan1 = new Scan();
ResultScanner
scanner1 = table.getScanner(scan1);
for
(Result res : scanner1) {
System.out.println(res);
}
scanner1.close();
2. When iterating ResultScanner we execute next() method.
3. Each call to next() will be a
separate RPC for each row—even when you use the
next(int nbRows) method,
because it is nothing else but a client-side loop over
next() calls4. Would make sense to fetch more than one row per RPC if possible. This is called scanner caching and is disabled by default.
5. Caching improves performance but impacts memory, since sing row can be constucted of hundreds columns and they will be fetched.And this should fit into client process. Batching feauture limits number of fetched columns per bulk.
6. Improved example
Scan scan = new Scan();
scan.setCaching(caching);
scan.setBatch(batch);
ResultScanner scanner = table.getScanner(scan);
for (Result result : scanner)
Example of fetches and RPCs ( from book :HBase,Defenitive Guide)