Command like SQL LIMIT in HBase

前端 未结 5 1057
暗喜
暗喜 2021-01-31 13:55

Does HBase have any command that works like SQL LIMIT query?

I can do it by setStart and setEnd, but I do not want to iterate all

5条回答
  •  情话喂你
    2021-01-31 14:35

    There is a filter called PageFilter. Its meant for this purpose.

    Scan scan = new Scan(Bytes.toBytes("smith-"));
    scan.addColumn(Bytes.toBytes("personal"), Bytes.toBytes("givenName"));
    scan.addColumn(Bytes.toBytes("contactinfo"), Bytes.toBytes("email"));
    scan.setFilter(new PageFilter(25));
    ResultScanner scanner = table.getScanner(scan);
    for (Result result : scanner) {
        // ...
    }
    

    http://java.dzone.com/articles/handling-big-data-hbase-part-4

提交回复
热议问题