示例#1
0
    @Override
    public void merge(AggregationBuffer agg, Object partial) throws HiveException {
      if (partial != null) {
        SumHiveDecimalAgg myagg = (SumHiveDecimalAgg) agg;
        if (myagg.sum == null) {
          return;
        }

        myagg.empty = false;
        if (isWindowingDistinct()) {
          throw new HiveException(
              "Distinct windowing UDAF doesn't support merge and terminatePartial");
        } else {
          myagg.sum = myagg.sum.add(PrimitiveObjectInspectorUtils.getHiveDecimal(partial, inputOI));
        }
      }
    }
示例#2
0
 @Override
 public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
   assert (parameters.length == 1);
   try {
     if (isEligibleValue((SumHiveDecimalAgg) agg, parameters[0])) {
       ((SumHiveDecimalAgg) agg).empty = false;
       ((SumHiveDecimalAgg) agg).sum =
           ((SumHiveDecimalAgg) agg)
               .sum.add(PrimitiveObjectInspectorUtils.getHiveDecimal(parameters[0], inputOI));
     }
   } catch (NumberFormatException e) {
     if (!warned) {
       warned = true;
       LOG.warn(getClass().getSimpleName() + " " + StringUtils.stringifyException(e));
       LOG.warn(getClass().getSimpleName() + " ignoring similar exceptions.");
     }
   }
 }