Package org.apache.hadoop.hive.common.type

Examples of org.apache.hadoop.hive.common.type.HiveDecimal.compareTo()


  public void testRoundWithDigits() {
    DecimalColumnVector dcv = new DecimalColumnVector(4 ,20, 3);
    HiveDecimal d1 = HiveDecimal.create("19.56778");
    HiveDecimal expected1 = HiveDecimal.create("19.568");
    DecimalUtil.round(0, d1, dcv);
    Assert.assertEquals(0, expected1.compareTo(dcv.vector[0].getHiveDecimal()));

    // As of HIVE-8745, these decimal values should be trimmed of trailing zeros.
    HiveDecimal d2 = HiveDecimal.create("23.56700");
    Assert.assertEquals(3, d2.scale());
    HiveDecimal expected2 = HiveDecimal.create("23.567");
View Full Code Here


    // As of HIVE-8745, these decimal values should be trimmed of trailing zeros.
    HiveDecimal d2 = HiveDecimal.create("23.56700");
    Assert.assertEquals(3, d2.scale());
    HiveDecimal expected2 = HiveDecimal.create("23.567");
    DecimalUtil.round(0, d2, dcv);
    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0].getHiveDecimal()));

    HiveDecimal d3 = HiveDecimal.create("-25.34567");
    HiveDecimal expected3 = HiveDecimal.create("-25.346");
    DecimalUtil.round(0, d3, dcv);
    Assert.assertEquals(0, expected3.compareTo(dcv.vector[0].getHiveDecimal()));
View Full Code Here

    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0].getHiveDecimal()));

    HiveDecimal d3 = HiveDecimal.create("-25.34567");
    HiveDecimal expected3 = HiveDecimal.create("-25.346");
    DecimalUtil.round(0, d3, dcv);
    Assert.assertEquals(0, expected3.compareTo(dcv.vector[0].getHiveDecimal()));

    HiveDecimal d4 = HiveDecimal.create("-17.23400");
    Assert.assertEquals(3, d4.scale());
    HiveDecimal expected4 = HiveDecimal.create("-17.234");
    DecimalUtil.round(0, d4, dcv);
View Full Code Here

      @Override
      protected void update(Object p, PrimitiveObjectInspector inputOI) {
        HiveDecimal v = PrimitiveObjectInspectorUtils.getHiveDecimal(p, inputOI);
        //Update min counter if new value is less than min seen so far
        if (min == null || v.compareTo(min) < 0) {
          min = v;
        }
        //Update max counter if new value is greater than max seen so far
        if (max == null || v.compareTo(max) > 0) {
          max = v;
View Full Code Here

        //Update min counter if new value is less than min seen so far
        if (min == null || v.compareTo(min) < 0) {
          min = v;
        }
        //Update max counter if new value is greater than max seen so far
        if (max == null || v.compareTo(max) > 0) {
          max = v;
        }
        // Add value to NumDistinctValue Estimator
        numDV.addToEstimator(v);
      }
View Full Code Here

    }

    HiveDecimal av = a.getHiveDecimal();
    HiveDecimal bv = b.getHiveDecimal();

    if (bv.compareTo(HiveDecimal.ZERO) == 0) {
      return null;
    }

    try {
      decimalWritable.set(av.remainder(bv).add(bv).remainder(bv));
View Full Code Here

    }

    HiveDecimal av = a.getHiveDecimal();
    HiveDecimal bv = b.getHiveDecimal();

    if (bv.compareTo(HiveDecimal.ZERO) == 0) {
      return null;
    }

    try {
      decimalWritable.set(av.remainder(bv));
View Full Code Here

        HiveDecimalObjectInspector boi = (HiveDecimalObjectInspector) poi;
        HiveDecimal dec = boi.getPrimitiveJavaObject(o);

        // get the sign of the big decimal
        int sign = dec.compareTo(HiveDecimal.ZERO);

        // we'll encode the absolute value (sign is separate)
        dec = dec.abs();

        // get the scale factor to turn big decimal into a decimal < 1
View Full Code Here

          try {

            HiveDecimal v = PrimitiveObjectInspectorUtils.getHiveDecimal(p, inputOI);

            //Update min counter if new value is less than min seen so far
            if (v.compareTo(myagg.min) < 0) {
              myagg.min = v;
            }

            //Update max counter if new value is greater than max seen so far
            if (v.compareTo(myagg.max) > 0) {
View Full Code Here

            if (v.compareTo(myagg.min) < 0) {
              myagg.min = v;
            }

            //Update max counter if new value is greater than max seen so far
            if (v.compareTo(myagg.max) > 0) {
              myagg.max = v;
            }

            // Add value to NumDistinctValue Estimator
            myagg.numDV.addToEstimator(v);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.