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);
}
}
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);
}
}
}
Aggregations