扫描器缓存
----------------
面向行级别的。
@Test
public void getScanCache() throws IOException {
Configuration conf = HBaseConfiguration.create();
Connection conn = ConnectionFactory.createConnection(conf);
TableName tname = TableName.valueOf("ns1:t1");
Scan scan = new Scan();
scan.setCaching(5000);
Table t = conn.getTable(tname);
ResultScanner rs = t.getScanner(scan);
long start = System.currentTimeMillis() ;
Iterator<Result> it = rs.iterator();
while(it.hasNext()){
Result r = it.next();
System.out.println(r.getColumnLatestCell(Bytes.toBytes("f1"), Bytes.toBytes("name")));
}
System.out.println(System.currentTimeMillis() - start);
}
批量扫描是面向列级别
--------------------
控制每次next()服务器端返回的列的个数。
scan.setBatch(5); //每次next返回5列。