☆☆☆★☆☆☆

唯有努力才能活成自己想要活成的样子

导航

hbase的api操作之scan

扫描器缓存
----------------
    面向行级别的。
    @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列。

 

posted on 2019-04-22 23:19  Yr-Zhang  阅读(1444)  评论(0编辑  收藏  举报