Search in sources :

Example 1 with NonReusingMutableToRegularIteratorWrapper

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

the class MapPartitionDriver method run.

@Override
public void run() throws Exception {
    final Counter numRecordsIn = this.taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsInCounter();
    final Counter numRecordsOut = this.taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsOutCounter();
    // cache references on the stack
    final MutableObjectIterator<IT> input = new CountingMutableObjectIterator<>(this.taskContext.<IT>getInput(0), numRecordsIn);
    final MapPartitionFunction<IT, OT> function = this.taskContext.getStub();
    final Collector<OT> output = new CountingCollector<>(this.taskContext.getOutputCollector(), numRecordsOut);
    if (objectReuseEnabled) {
        final ReusingMutableToRegularIteratorWrapper<IT> inIter = new ReusingMutableToRegularIteratorWrapper<IT>(input, this.taskContext.<IT>getInputSerializer(0).getSerializer());
        function.mapPartition(inIter, output);
    } else {
        final NonReusingMutableToRegularIteratorWrapper<IT> inIter = new NonReusingMutableToRegularIteratorWrapper<IT>(input, this.taskContext.<IT>getInputSerializer(0).getSerializer());
        function.mapPartition(inIter, output);
    }
}
Also used : CountingCollector(org.apache.flink.runtime.operators.util.metrics.CountingCollector) Counter(org.apache.flink.metrics.Counter) CountingMutableObjectIterator(org.apache.flink.runtime.operators.util.metrics.CountingMutableObjectIterator) ReusingMutableToRegularIteratorWrapper(org.apache.flink.runtime.util.ReusingMutableToRegularIteratorWrapper) NonReusingMutableToRegularIteratorWrapper(org.apache.flink.runtime.util.NonReusingMutableToRegularIteratorWrapper) NonReusingMutableToRegularIteratorWrapper(org.apache.flink.runtime.util.NonReusingMutableToRegularIteratorWrapper)

Example 2 with NonReusingMutableToRegularIteratorWrapper

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

the class AllGroupCombineDriver method run.

@Override
public void run() throws Exception {
    if (LOG.isDebugEnabled()) {
        LOG.debug("AllGroupCombine starting.");
    }
    final Counter numRecordsIn = this.taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsInCounter();
    final Counter numRecordsOut = this.taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsOutCounter();
    final TypeSerializerFactory<IN> serializerFactory = this.taskContext.getInputSerializer(0);
    TypeSerializer<IN> serializer = serializerFactory.getSerializer();
    final MutableObjectIterator<IN> in = new CountingMutableObjectIterator<>(this.taskContext.<IN>getInput(0), numRecordsIn);
    final GroupCombineFunction<IN, OUT> reducer = this.taskContext.getStub();
    final Collector<OUT> output = new CountingCollector<>(this.taskContext.getOutputCollector(), numRecordsOut);
    if (objectReuseEnabled) {
        final ReusingMutableToRegularIteratorWrapper<IN> inIter = new ReusingMutableToRegularIteratorWrapper<IN>(in, serializer);
        if (inIter.hasNext()) {
            reducer.combine(inIter, output);
        }
    } else {
        final NonReusingMutableToRegularIteratorWrapper<IN> inIter = new NonReusingMutableToRegularIteratorWrapper<IN>(in, serializer);
        if (inIter.hasNext()) {
            reducer.combine(inIter, output);
        }
    }
}
Also used : CountingCollector(org.apache.flink.runtime.operators.util.metrics.CountingCollector) Counter(org.apache.flink.metrics.Counter) CountingMutableObjectIterator(org.apache.flink.runtime.operators.util.metrics.CountingMutableObjectIterator) NonReusingMutableToRegularIteratorWrapper(org.apache.flink.runtime.util.NonReusingMutableToRegularIteratorWrapper) ReusingMutableToRegularIteratorWrapper(org.apache.flink.runtime.util.ReusingMutableToRegularIteratorWrapper) NonReusingMutableToRegularIteratorWrapper(org.apache.flink.runtime.util.NonReusingMutableToRegularIteratorWrapper)

Aggregations

Counter (org.apache.flink.metrics.Counter)2 CountingCollector (org.apache.flink.runtime.operators.util.metrics.CountingCollector)2 CountingMutableObjectIterator (org.apache.flink.runtime.operators.util.metrics.CountingMutableObjectIterator)2 NonReusingMutableToRegularIteratorWrapper (org.apache.flink.runtime.util.NonReusingMutableToRegularIteratorWrapper)2 ReusingMutableToRegularIteratorWrapper (org.apache.flink.runtime.util.ReusingMutableToRegularIteratorWrapper)2