Example #1
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;
  }
Example #2
0
 @Override
 public Datum terminate(FunctionContext ctx) {
   AvgContext avgCtx = (AvgContext) ctx;
   return DatumFactory.createDouble(avgCtx.sum / avgCtx.count);
 }