HBase 数量统计出错解决方案

HBase 使用AggregationClient 做数量统计:

报错:

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

解决方案:

hbase-site.xml 添加

<property>
<name>hbase.coprocessor.user.region.classes</name>
<value>org.apache.hadoop.hbase.coprocessor.AggregateImplementation</value>
</property>

建表是或者修改表要添加

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();

原文:https://blog.csdn.net/hhl2046/article/details/52387225

猜你喜欢

转载自blog.csdn.net/u011974797/article/details/81531490