Example #1
0
  public StringifiedAccumulatorResult[] getAggregatedUserAccumulatorsStringified() {
    Map<String, Accumulator<?, ?>> userAccumulators = new HashMap<String, Accumulator<?, ?>>();

    for (ExecutionVertex vertex : taskVertices) {
      Map<String, Accumulator<?, ?>> next =
          vertex.getCurrentExecutionAttempt().getUserAccumulators();
      if (next != null) {
        AccumulatorHelper.mergeInto(userAccumulators, next);
      }
    }

    return StringifiedAccumulatorResult.stringifyAccumulatorResults(userAccumulators);
  }
Example #2
0
  public JobExecutionResult execute(Plan program) throws Exception {
    long startTime = System.currentTimeMillis();

    initCache(program.getCachedFiles());
    Collection<? extends GenericDataSinkBase<?>> sinks = program.getDataSinks();
    for (Operator<?> sink : sinks) {
      execute(sink);
    }

    long endTime = System.currentTimeMillis();
    Map<String, Object> accumulatorResults = AccumulatorHelper.toResultMap(accumulators);
    return new JobExecutionResult(null, endTime - startTime, accumulatorResults);
  }
    @Override
    protected <AggInputT, AggOutputT> Aggregator<AggInputT, AggOutputT> createAggregatorInternal(
        String name, Combine.CombineFn<AggInputT, ?, AggOutputT> combiner) {
      Accumulator acc = getRuntimeContext().getAccumulator(name);
      if (acc != null) {
        AccumulatorHelper.compareAccumulatorTypes(
            name, SerializableFnAggregatorWrapper.class, acc.getClass());
        return (Aggregator<AggInputT, AggOutputT>) acc;
      }

      SerializableFnAggregatorWrapper<AggInputT, AggOutputT> accumulator =
          new SerializableFnAggregatorWrapper<>(combiner);
      getRuntimeContext().addAccumulator(name, accumulator);
      return accumulator;
    }