`
san_yun
  • 浏览: 2594571 次
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

hbase实现count功能

阅读更多

代码如下:

		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/

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics