首页 > 其他 > 详细

hbase中double类型数据做累加

时间:2017-08-26 14:46:41      阅读:1122      评论:0      收藏:0      [点我收藏+]
 public static Result incr(String tableFullName, String rowKey, String family, String qualifier, long amount) throws IOException {
        Table table = HBaseConnectionFactory.getConnection().getTable(TableName.valueOf(tableFullName));
        Increment increment = new Increment(Bytes.toBytes(rowKey));
        //  public Increment addColumn(byte [] family, byte [] qualifier, long amount)
        increment.addColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier), amount); // pv +2
        //increment.addColumn(Bytes.toBytes("info"), Bytes.toBytes("uv"), 1L); // uv +1
        return table.increment(increment);
    }

以上对long类型数据的累加,double类型的数据累加是将double类型*10000,这样将double转成一个long类型的数字进行累加,使用这种方法时要注意控制double类型数据的精度

hbase中double类型数据做累加

原文:http://www.cnblogs.com/rocky-AGE-24/p/7435284.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!