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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2021-11-15
  • 2022-12-23
猜你喜欢
  • 2022-01-17
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案