Hbase counter计数器

来源:互联网 发布:陕西大数据集团董事长 编辑:程序博客网 时间:2024/06/05 18:52

创建表名和列族名

create 't1','cf'

 

初始化counter为1 或 让counter+1

incr 't1','row1','cf:no',1

 

获取counter

get 't1','row1','cf:no'

 

获取counter

get_counter 't1','row1','cf:no'

 

@Testpublic  void testCounter() throws Exception{Table table = conn.getTable(TableName.valueOf("t1"));long counter = table.incrementColumnValue(Bytes.toBytes("row1"), Bytes.toBytes("cf"), Bytes.toBytes("no"), 1);System.out.println(counter);table.close();}

 

 

原创粉丝点击