zoukankan      html  css  js  c++  java
  • 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类型数据的精度

  • 相关阅读:
    BZOJ3000 斯特林公式
    组合数学一些结论
    CSP2019-JS 游记(总结)
    Atcoder AGC1~10 problem list
    ioi2015hw
    NOI2017解题报告
    HNOI2021游记
    4月做题记录
    WC2021题解
    P4592 [TJOI2018]异或
  • 原文地址:https://www.cnblogs.com/rocky-AGE-24/p/7435284.html
Copyright © 2011-2022 走看看