Search in sources :

Example 1 with CountingCollector

use of org.apache.flink.runtime.operators.util.metrics.CountingCollector in project flink by apache.

the class AbstractCachedBuildSideJoinDriver method run.

@Override
public void run() throws Exception {
    final Counter numRecordsOut = taskContext.getMetricGroup().getIOMetricGroup().getNumRecordsOutCounter();
    final FlatJoinFunction<IT1, IT2, OT> matchStub = this.taskContext.getStub();
    final Collector<OT> collector = new CountingCollector<>(this.taskContext.getOutputCollector(), numRecordsOut);
    while (this.running && matchIterator != null && matchIterator.callWithNextKey(matchStub, collector)) {
    }
}
Also used : CountingCollector(org.apache.flink.runtime.operators.util.metrics.CountingCollector) Counter(org.apache.flink.metrics.Counter)

Example 2 with CountingCollector

use of org.apache.flink.runtime.operators.util.metrics.CountingCollector in project flink by apache.

the class CrossDriver method runBlockedOuterFirst.

private void runBlockedOuterFirst() throws Exception {
    if (LOG.isDebugEnabled()) {
        LOG.debug(this.taskContext.formatLogString("Running Cross with Block-Nested-Loops: " + "First input is outer (blocking) side, second input is inner (spilling) 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 BlockResettableMutableObjectIterator<T1> blockVals = new BlockResettableMutableObjectIterator<T1>(this.memManager, in1, serializer1, this.memPagesForBlockSide, this.taskContext.getContainingTask());
    this.blockIter = blockVals;
    final SpillingResettableMutableObjectIterator<T2> spillVals = new SpillingResettableMutableObjectIterator<T2>(in2, serializer2, this.memManager, this.taskContext.getIOManager(), this.memPagesForSpillingSide, this.taskContext.getContainingTask());
    this.spillIter = spillVals;
    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 && ((val2 = spillVals.next(val2Reuse)) != null)) {
                // for all values in the block
                while ((val1 = blockVals.next(val1Reuse)) != 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 && ((val2 = spillVals.next()) != null)) {
                // for all values in the block
                while ((val1 = blockVals.next()) != null) {
                    collector.collect(crosser.cross(val1, serializer2.copy(val2)));
                }
                blockVals.reset();
            }
            spillVals.reset();
        } while (this.running && blockVals.nextBlock());
    }
}
Also used : SpillingResettableMutableObjectIterator(org.apache.flink.runtime.operators.resettable.SpillingResettableMutableObjectIterator) BlockResettableMutableObjectIterator(org.apache.flink.runtime.operators.resettable.BlockResettableMutableObjectIterator) CountingCollector(org.apache.flink.runtime.operators.util.metrics.CountingCollector) Counter(org.apache.flink.metrics.Counter) CountingMutableObjectIterator(org.apache.flink.runtime.operators.util.metrics.CountingMutableObjectIterator)

Example 3 with CountingCollector

use of org.apache.flink.runtime.operators.util.metrics.CountingCollector in project flink by apache.

the class CrossDriver method runStreamedOuterSecond.

private void runStreamedOuterSecond() throws Exception {
    if (LOG.isDebugEnabled()) {
        LOG.debug(this.taskContext.formatLogString("Running Cross with Nested-Loops: " + "First input is inner (spilling) side, second input is outer 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 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
        while (this.running && (val2 = in2.next(val2Reuse)) != null) {
            // for all values from the spilling side
            while (this.running && (val1 = spillVals.next(val1Reuse)) != null) {
                collector.collect(crosser.cross(val1, val2));
            // crosser.cross(val1, val2Copy, collector);
            }
            spillVals.reset();
        }
    } else {
        T1 val1;
        T2 val2;
        // for all blocks
        while (this.running && (val2 = in2.next()) != null) {
            // for all values from the spilling side
            while (this.running && (val1 = spillVals.next()) != null) {
                collector.collect(crosser.cross(val1, serializer2.copy(val2)));
            }
            spillVals.reset();
        }
    }
}
Also used : SpillingResettableMutableObjectIterator(org.apache.flink.runtime.operators.resettable.SpillingResettableMutableObjectIterator) CountingCollector(org.apache.flink.runtime.operators.util.metrics.CountingCollector) Counter(org.apache.flink.metrics.Counter) CountingMutableObjectIterator(org.apache.flink.runtime.operators.util.metrics.CountingMutableObjectIterator)

Example 4 with CountingCollector

use of org.apache.flink.runtime.operators.util.metrics.CountingCollector 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)

Example 5 with CountingCollector

use of org.apache.flink.runtime.operators.util.metrics.CountingCollector in project flink by apache.

the class MapDriver 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 = this.taskContext.getInput(0);
    final MapFunction<IT, OT> function = this.taskContext.getStub();
    final Collector<OT> output = new CountingCollector<>(this.taskContext.getOutputCollector(), numRecordsOut);
    if (objectReuseEnabled) {
        IT record = this.taskContext.<IT>getInputSerializer(0).getSerializer().createInstance();
        while (this.running && ((record = input.next(record)) != null)) {
            numRecordsIn.inc();
            output.collect(function.map(record));
        }
    } else {
        IT record = null;
        while (this.running && ((record = input.next()) != null)) {
            numRecordsIn.inc();
            output.collect(function.map(record));
        }
    }
}
Also used : CountingCollector(org.apache.flink.runtime.operators.util.metrics.CountingCollector) Counter(org.apache.flink.metrics.Counter)

Aggregations

Counter (org.apache.flink.metrics.Counter)18 CountingCollector (org.apache.flink.runtime.operators.util.metrics.CountingCollector)18 CountingMutableObjectIterator (org.apache.flink.runtime.operators.util.metrics.CountingMutableObjectIterator)6 SpillingResettableMutableObjectIterator (org.apache.flink.runtime.operators.resettable.SpillingResettableMutableObjectIterator)4 BlockResettableMutableObjectIterator (org.apache.flink.runtime.operators.resettable.BlockResettableMutableObjectIterator)2 NonReusingMutableToRegularIteratorWrapper (org.apache.flink.runtime.util.NonReusingMutableToRegularIteratorWrapper)2 ReusingMutableToRegularIteratorWrapper (org.apache.flink.runtime.util.ReusingMutableToRegularIteratorWrapper)2 NoSuchElementException (java.util.NoSuchElementException)1 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)1 RuntimeContext (org.apache.flink.api.common.functions.RuntimeContext)1 RichInputFormat (org.apache.flink.api.common.io.RichInputFormat)1 InputSplit (org.apache.flink.core.io.InputSplit)1 SimpleCounter (org.apache.flink.metrics.SimpleCounter)1 CancelTaskException (org.apache.flink.runtime.execution.CancelTaskException)1 InputSplitProviderException (org.apache.flink.runtime.jobgraph.tasks.InputSplitProviderException)1 InternalOperatorIOMetricGroup (org.apache.flink.runtime.metrics.groups.InternalOperatorIOMetricGroup)1 ExceptionInChainedStubException (org.apache.flink.runtime.operators.chaining.ExceptionInChainedStubException)1 NonReusingKeyGroupedIterator (org.apache.flink.runtime.util.NonReusingKeyGroupedIterator)1 ReusingKeyGroupedIterator (org.apache.flink.runtime.util.ReusingKeyGroupedIterator)1