像HBase中的SQL LIMIT这样的命令

问题描述:

HBase是否有像 SQL LIMIT 查询那样的命令?

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

我可以通过 setStart setEnd ,但我不想迭代所有行。

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

从HBase shell可以使用LIMIT:

From the HBase shell you can use LIMIT:

hbase> scan 'test-table', {'LIMIT' => 5}

在Java API中,您可以使用 Scan.setMaxResultSize(N) scan.setMaxResultsPerColumnFamily(N)

From the Java API you can use Scan.setMaxResultSize(N) or scan.setMaxResultsPerColumnFamily(N).

  • HBase API docs - Scan.setMaxResultSize
  • HBase API docs - Scan.setMaxResultsPerColumnFamily