Пример #1
0
 @Override
 public void merge(AggregationBuffer agg, Object partial) throws HiveException {
   if (partial != null) {
     MaxAgg myagg = (MaxAgg) agg;
     int r = ObjectInspectorUtils.compare(myagg.o, outputOI, partial, inputOI);
     if (myagg.o == null || r < 0) {
       myagg.o =
           ObjectInspectorUtils.copyToStandardObject(
               partial, inputOI, ObjectInspectorCopyOption.JAVA);
     }
   }
 }
    @Override
    public void merge(AggregationBuffer agg, Object partial) throws HiveException {
      if (partial != null) {
        MaxAgg maxagg = (MaxAgg) agg;
        List<Object> objects;
        if (partial instanceof Object[]) {
          objects = Arrays.asList((Object[]) partial);
        } else if (partial instanceof LazyBinaryStruct) {
          objects = ((LazyBinaryStruct) partial).getFieldsAsList();
        } else {
          throw new HiveException("Invalid type: " + partial.getClass().getName());
        }

        if (maxagg.objects == null) {
          int length = objects.size();
          maxagg.objects = new Object[length];
          for (int i = 0; i < length; i++) {
            maxagg.objects[i] =
                ObjectInspectorUtils.copyToStandardObject(objects.get(i), inputOIs[i]);
          }
        }
      }
    }
 @Override
 public void reset(AggregationBuffer agg) throws HiveException {
   MaxAgg maxagg = (MaxAgg) agg;
   maxagg.objects = null;
 }