如何在hbase中确定结果大小?

如何在hbase中确定结果大小?,hbase,Hbase,我想将hbase中的记录从rowkey x扫描到rowkey y,我还想在这些扫描上指定一个过滤器,我知道当我们执行这样的操作时,我们会得到ResultScanner对象,有没有办法只获得结果的大小(在服务器端计算) 通常,我希望在mongo或sql中使用类似count()的操作,而无需迭代resultscanner 感谢您的帮助简单的方法是只请求可用的最小列,如果您为扫描提供了可接受的缓存,则该列可以正常工作 如果是大型客户端扫描,或者如果您想在RegionServer上执行所有操作,可以使

我想将hbase中的记录从rowkey x扫描到rowkey y,我还想在这些扫描上指定一个过滤器,我知道当我们执行这样的操作时,我们会得到ResultScanner对象,有没有办法只获得结果的大小(在服务器端计算)

通常,我希望在mongo或sql中使用类似count()的操作,而无需迭代resultscanner


感谢您的帮助

简单的方法是只请求可用的最小列,如果您为扫描提供了可接受的缓存,则该列可以正常工作


如果是大型客户端扫描,或者如果您想在RegionServer上执行所有操作,可以使用AggregationClient协处理器(0.92+,必须先启用)。如果扫描量很大,MapReduce作业是你最好的朋友

Working AggregationClient示例摘自:


如果您需要实时响应,则必须实施和维护

public class MyAggregationClient {

    private static final byte[] TABLE_NAME = Bytes.toBytes("mytable");
    private static final byte[] CF = Bytes.toBytes("d");

    public static void main(String[] args) throws Throwable {

        Configuration customConf = new Configuration();
        customConf.setStrings("hbase.zookeeper.quorum",
                "node0,node1,node2");
        // Increase RPC timeout, in case of a slow computation
        customConf.setLong("hbase.rpc.timeout", 600000);
        // Default is 1, set to a higher value for faster scanner.next(..)
        customConf.setLong("hbase.client.scanner.caching", 1000);
        Configuration configuration = HBaseConfiguration.create(customConf);
        AggregationClient aggregationClient = new AggregationClient(
                configuration);
        Scan scan = new Scan();
        scan.addFamily(CF);
        long rowCount = aggregationClient.rowCount(TABLE_NAME, null, scan);
        System.out.println("row count is " + rowCount);

    }
}