hbase中double类型数据做累加

 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类型数据的精度

原文地址:https://www.cnblogs.com/rocky-AGE-24/p/7435284.html