代码如下:
Scan scan = new Scan();
scan.addFamily(Bytes.toBytes("cf"));
scan.setCaching(500);
AggregationClient ac = new AggregationClient(config);
long rowCount = ac.rowCount(Bytes.toBytes("eagleeye-log"), new LongColumnInterpreter(), scan);
System.out.println(rowCount);
config初始化
config = HBaseConfiguration.create();
Properties properties = ConfigUtils.readConfig(configFileName);
for (String key : properties.stringPropertyNames()) {
if (key.startsWith("config.hbase.")) {
String hbaseKey = key.substring("config.hbase.".length());
String value = properties.getProperty(key);
config.set(hbaseKey, value);
}
}
参考:http://www.binospace.com/index.php/make-your-hbase-better-2/