Examples of HiveDecimal


Examples of org.apache.hadoop.hive.common.type.HiveDecimal

  protected HiveDecimalWritable evaluate(HiveDecimal left, HiveDecimal right) {
    if (right.compareTo(HiveDecimal.ZERO) == 0) {
      return null;
    }

    HiveDecimal dec = left.remainder(right).add(right).remainder(right);
    if (dec == null) {
      return null;
    }

    decimalWritable.set(dec);
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

    return longWritable;
  }

  @Override
  protected HiveDecimalWritable evaluate(HiveDecimalWritable input) {
    HiveDecimal bd = input.getHiveDecimal();
    decimalWritable.set(bd.setScale(0, HiveDecimal.ROUND_FLOOR));
    return decimalWritable;
  }
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

      return null;
    }

    // Handle decimal separately.
    if (resultOI.getPrimitiveCategory() == PrimitiveCategory.DECIMAL) {
      HiveDecimal hdLeft = PrimitiveObjectInspectorUtils.getHiveDecimal(left, leftOI);
      HiveDecimal hdRight = PrimitiveObjectInspectorUtils.getHiveDecimal(right, rightOI);
      if (hdLeft == null || hdRight == null) {
        return null;
      }
      HiveDecimalWritable result = evaluate(hdLeft, hdRight);
      return resultOI.getPrimitiveWritableObject(result);
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

          v = Byte.valueOf(expr.getText().substring(
                0, expr.getText().length() - 1));
        } else if (expr.getText().endsWith("BD")) {
          // Literal decimal
          String strVal = expr.getText().substring(0, expr.getText().length() - 2);
          HiveDecimal hd = HiveDecimal.create(strVal);
          int prec = 1;
          int scale = 0;
          if (hd != null) {
            prec = hd.precision();
            scale = hd.scale();
          }
          DecimalTypeInfo typeInfo = TypeInfoFactory.getDecimalTypeInfo(prec, scale);
          return new ExprNodeConstantDesc(typeInfo, strVal);
        } else {
          v = Double.valueOf(expr.getText());
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

    }

    @Override
    protected void doIterate(AverageAggregationBuffer<HiveDecimal> aggregation,
        PrimitiveObjectInspector oi, Object parameter) {
      HiveDecimal value = PrimitiveObjectInspectorUtils.getHiveDecimal(parameter, oi);
      aggregation.count++;
      if (aggregation.sum != null) {
        aggregation.sum = aggregation.sum.add(value);
      }
    }
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

    }

    @Override
    protected void doMerge(AverageAggregationBuffer<HiveDecimal> aggregation, Long partialCount,
        ObjectInspector sumFieldOI, Object partialSum) {
      HiveDecimal value = ((HiveDecimalObjectInspector)sumFieldOI).getPrimitiveJavaObject(partialSum);
      if (value == null) {
        aggregation.sum = null;
      }
      aggregation.count += partialCount;
      if (aggregation.sum != null) {
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

    return doubleWritable;
  }

  @Override
  protected HiveDecimalWritable evaluate(HiveDecimal left, HiveDecimal right) {
    HiveDecimal dec = left.subtract(right);
    if (dec == null) {
      return null;
    }
    decimalWritable.set(dec);
    return decimalWritable;
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

  protected HiveDecimalWritable evaluate(HiveDecimal left, HiveDecimal right) {
    if (right.compareTo(HiveDecimal.ZERO) == 0) {
      return null;
    }

    HiveDecimal dec = left.divide(right);
    if (dec == null) {
      return null;
    }

    decimalWritable.set(dec);
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

      return floatWritable;
    case DOUBLE:
      doubleWritable.set(-(((DoubleWritable)input).get()));
      return doubleWritable;
    case DECIMAL:
      HiveDecimal dec = ((HiveDecimalWritable)input).getHiveDecimal();
      decimalWritable.set(dec.negate());
      return decimalWritable;
    default:
      // Should never happen.
      throw new RuntimeException("Unexpected type in evaluating " + opName + ": " +
          resultOI.getPrimitiveCategory());
View Full Code Here

Examples of org.apache.hadoop.hive.common.type.HiveDecimal

  protected HiveDecimalWritable evaluate(HiveDecimal left, HiveDecimal right) {
    if (right.compareTo(HiveDecimal.ZERO) == 0) {
      return null;
    }

    HiveDecimal dec = left.remainder(right);
    if (dec == null) {
      return null;
    }

    decimalWritable.set(dec);
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.