Search in sources :

Example 1 with ReusingKeyGroupedIterator

use of org.apache.flink.runtime.util.ReusingKeyGroupedIterator in project flink by apache.

the class GroupReduceDriver method run.

@Override
public void run() throws Exception {
    if (LOG.isDebugEnabled()) {
        LOG.debug(this.taskContext.formatLogString("GroupReducer preprocessing done. Running GroupReducer code."));
    }
    final Counter numRecordsOut = this.taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsOutCounter();
    // cache references on the stack
    final GroupReduceFunction<IT, OT> stub = this.taskContext.getStub();
    final Collector<OT> output = new CountingCollector<>(this.taskContext.getOutputCollector(), numRecordsOut);
    if (objectReuseEnabled) {
        final ReusingKeyGroupedIterator<IT> iter = new ReusingKeyGroupedIterator<IT>(this.input, this.serializer, this.comparator);
        // run stub implementation
        while (this.running && iter.nextKey()) {
            stub.reduce(iter.getValues(), output);
        }
    } else {
        final NonReusingKeyGroupedIterator<IT> iter = new NonReusingKeyGroupedIterator<IT>(this.input, this.comparator);
        // run stub implementation
        while (this.running && iter.nextKey()) {
            stub.reduce(iter.getValues(), output);
        }
    }
}
Also used : CountingCollector(org.apache.flink.runtime.operators.util.metrics.CountingCollector) Counter(org.apache.flink.metrics.Counter) NonReusingKeyGroupedIterator(org.apache.flink.runtime.util.NonReusingKeyGroupedIterator) ReusingKeyGroupedIterator(org.apache.flink.runtime.util.ReusingKeyGroupedIterator) NonReusingKeyGroupedIterator(org.apache.flink.runtime.util.NonReusingKeyGroupedIterator)

Aggregations

Counter (org.apache.flink.metrics.Counter)1 CountingCollector (org.apache.flink.runtime.operators.util.metrics.CountingCollector)1 NonReusingKeyGroupedIterator (org.apache.flink.runtime.util.NonReusingKeyGroupedIterator)1 ReusingKeyGroupedIterator (org.apache.flink.runtime.util.ReusingKeyGroupedIterator)1