use of org.apache.flink.runtime.operators.util.metrics.CountingCollector in project flink by apache.
the class AllReduceDriver method run.
@Override
public void run() throws Exception {
if (LOG.isDebugEnabled()) {
LOG.debug(this.taskContext.formatLogString("AllReduce preprocessing done. Running Reducer code."));
}
final Counter numRecordsIn = this.taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsInCounter();
final Counter numRecordsOut = this.taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsOutCounter();
final ReduceFunction<T> stub = this.taskContext.getStub();
final MutableObjectIterator<T> input = this.input;
final TypeSerializer<T> serializer = this.serializer;
final Collector<T> collector = new CountingCollector<>(this.taskContext.getOutputCollector(), numRecordsOut);
T val1;
if ((val1 = input.next()) == null) {
return;
}
numRecordsIn.inc();
if (objectReuseEnabled) {
// We only need two objects. The first reference stores results and is
// eventually collected. New values are read into the second.
T val2 = serializer.createInstance();
T value = val1;
while (running && (val2 = input.next(val2)) != null) {
numRecordsIn.inc();
value = stub.reduce(value, val2);
// by the user, so swap the reuse objects,
if (value == val2) {
T tmp = val1;
val1 = val2;
val2 = tmp;
}
}
collector.collect(value);
} else {
T val2;
while (running && (val2 = input.next()) != null) {
numRecordsIn.inc();
val1 = stub.reduce(val1, val2);
}
collector.collect(val1);
}
}
use of org.apache.flink.runtime.operators.util.metrics.CountingCollector in project flink by apache.
the class CoGroupDriver method run.
@Override
public void run() throws Exception {
final Counter numRecordsOut = this.taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsOutCounter();
final CoGroupFunction<IT1, IT2, OT> coGroupStub = this.taskContext.getStub();
final Collector<OT> collector = new CountingCollector<>(this.taskContext.getOutputCollector(), numRecordsOut);
final CoGroupTaskIterator<IT1, IT2> coGroupIterator = this.coGroupIterator;
while (this.running && coGroupIterator.next()) {
coGroupStub.coGroup(coGroupIterator.getValues1(), coGroupIterator.getValues2(), collector);
}
}
use of org.apache.flink.runtime.operators.util.metrics.CountingCollector in project flink by apache.
the class JoinDriver method run.
@Override
public void run() throws Exception {
final Counter numRecordsOut = this.taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsOutCounter();
final FlatJoinFunction<IT1, IT2, OT> joinStub = this.taskContext.getStub();
final Collector<OT> collector = new CountingCollector<>(this.taskContext.getOutputCollector(), numRecordsOut);
final JoinTaskIterator<IT1, IT2, OT> joinIterator = this.joinIterator;
while (this.running && joinIterator.callWithNextKey(joinStub, collector)) ;
}
use of org.apache.flink.runtime.operators.util.metrics.CountingCollector 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.operators.util.metrics.CountingCollector in project flink by apache.
the class CrossDriver method runBlockedOuterSecond.
private void runBlockedOuterSecond() throws Exception {
if (LOG.isDebugEnabled()) {
LOG.debug(this.taskContext.formatLogString("Running Cross with Block-Nested-Loops: " + "First input is inner (spilling) side, second input is outer (blocking) side."));
}
final Counter numRecordsIn = taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsInCounter();
final Counter numRecordsOut = taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsOutCounter();
final MutableObjectIterator<T1> in1 = new CountingMutableObjectIterator<>(this.taskContext.<T1>getInput(0), numRecordsIn);
final MutableObjectIterator<T2> in2 = new CountingMutableObjectIterator<>(this.taskContext.<T2>getInput(1), numRecordsIn);
final TypeSerializer<T1> serializer1 = this.taskContext.<T1>getInputSerializer(0).getSerializer();
final TypeSerializer<T2> serializer2 = this.taskContext.<T2>getInputSerializer(1).getSerializer();
final SpillingResettableMutableObjectIterator<T1> spillVals = new SpillingResettableMutableObjectIterator<T1>(in1, serializer1, this.memManager, this.taskContext.getIOManager(), this.memPagesForSpillingSide, this.taskContext.getContainingTask());
this.spillIter = spillVals;
final BlockResettableMutableObjectIterator<T2> blockVals = new BlockResettableMutableObjectIterator<T2>(this.memManager, in2, serializer2, this.memPagesForBlockSide, this.taskContext.getContainingTask());
this.blockIter = blockVals;
final CrossFunction<T1, T2, OT> crosser = this.taskContext.getStub();
final Collector<OT> collector = new CountingCollector<>(this.taskContext.getOutputCollector(), numRecordsOut);
if (objectReuseEnabled) {
final T1 val1Reuse = serializer1.createInstance();
final T2 val2Reuse = serializer2.createInstance();
T1 val1;
T2 val2;
// for all blocks
do {
// for all values from the spilling side
while (this.running && ((val1 = spillVals.next(val1Reuse)) != null)) {
// for all values in the block
while (this.running && ((val2 = blockVals.next(val2Reuse)) != null)) {
collector.collect(crosser.cross(val1, val2));
}
blockVals.reset();
}
spillVals.reset();
} while (this.running && blockVals.nextBlock());
} else {
T1 val1;
T2 val2;
// for all blocks
do {
// for all values from the spilling side
while (this.running && ((val1 = spillVals.next()) != null)) {
// for all values in the block
while (this.running && ((val2 = blockVals.next()) != null)) {
collector.collect(crosser.cross(serializer1.copy(val1), val2));
}
blockVals.reset();
}
spillVals.reset();
} while (this.running && blockVals.nextBlock());
}
}
Aggregations