Esempio n. 1
0
 @Override
 public void merge(FunctionContext ctx, Tuple part) {
   AvgContext avgCtx = (AvgContext) ctx;
   ArrayDatum array = (ArrayDatum) part.get(0);
   avgCtx.sum += array.get(0).asDouble();
   avgCtx.count += array.get(1).asLong();
 }
Esempio n. 2
0
  @Override
  public Datum getPartialResult(FunctionContext ctx) {
    AvgContext avgCtx = (AvgContext) ctx;
    ArrayDatum part = new ArrayDatum(2);
    part.put(0, DatumFactory.createDouble(avgCtx.sum));
    part.put(1, DatumFactory.createLong(avgCtx.count));

    return part;
  }