HBase 数量统计

HBase 使用AggregationClient 做数量统计:

报错:

org.apache.hadoop.hbase.exceptions.UnknownProtocolException: org.apache.hadoop.hbase.exceptions.UnknownProtocolException: No registered coprocessor service found for name AggregateService in region



hbase-site.xml 添加

hbase.coprocessor.user.region.classes
org.apache.hadoop.hbase.coprocessor.AggregateImplementation

建表是或者修改表要添加
HTableDescriptor htd = admin.getTableDescriptor(tableName);
htd.addCoprocessor("org.apache.hadoop.hbase.coprocessor.AggregateImplementation");

调用
Scan scan = new Scan();
SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes("info"),
Bytes.toBytes("id"), CompareOp.LESS_OR_EQUAL, Bytes.toBytes(10000));
scan.setFilter(filter);
AggregationClient aggregationClient = new AggregationClient(conf);
long count = aggregationClient.rowCount(tableName, new LongColumnInterpreter(), scan);
aggregationClient.close();


你可能感兴趣的:(HBase)