Java Code Examples for org.apache.flink.runtime.iterative.io.WorksetUpdateOutputCollector

The following examples show how to use org.apache.flink.runtime.iterative.io.WorksetUpdateOutputCollector. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: Flink-CEPplus   Author: ljygz   File: IterationIntermediateTask.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// set the last output collector of this task to reflect the iteration intermediate state update
	// a) workset update
	// b) solution set update
	// c) none

	Collector<OT> delegate = getLastOutputCollector();
	if (isWorksetUpdate) {
		// sanity check: we should not have a solution set and workset update at the same time
		// in an intermediate task
		if (isSolutionSetUpdate) {
			throw new IllegalStateException("Plan bug: Intermediate task performs workset and solutions set update.");
		}

		Collector<OT> outputCollector = createWorksetUpdateOutputCollector(delegate);

		// we need the WorksetUpdateOutputCollector separately to count the collected elements
		if (isWorksetIteration) {
			worksetUpdateOutputCollector = (WorksetUpdateOutputCollector<OT>) outputCollector;
		}

		setLastOutputCollector(outputCollector);
	} else if (isSolutionSetUpdate) {
		setLastOutputCollector(createSolutionSetUpdateOutputCollector(delegate));
	}
}
 
Example #2
Source Project: flink   Author: flink-tpc-ds   File: IterationIntermediateTask.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// set the last output collector of this task to reflect the iteration intermediate state update
	// a) workset update
	// b) solution set update
	// c) none

	Collector<OT> delegate = getLastOutputCollector();
	if (isWorksetUpdate) {
		// sanity check: we should not have a solution set and workset update at the same time
		// in an intermediate task
		if (isSolutionSetUpdate) {
			throw new IllegalStateException("Plan bug: Intermediate task performs workset and solutions set update.");
		}

		Collector<OT> outputCollector = createWorksetUpdateOutputCollector(delegate);

		// we need the WorksetUpdateOutputCollector separately to count the collected elements
		if (isWorksetIteration) {
			worksetUpdateOutputCollector = (WorksetUpdateOutputCollector<OT>) outputCollector;
		}

		setLastOutputCollector(outputCollector);
	} else if (isSolutionSetUpdate) {
		setLastOutputCollector(createSolutionSetUpdateOutputCollector(delegate));
	}
}
 
Example #3
Source Project: flink   Author: apache   File: IterationIntermediateTask.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// set the last output collector of this task to reflect the iteration intermediate state update
	// a) workset update
	// b) solution set update
	// c) none

	Collector<OT> delegate = getLastOutputCollector();
	if (isWorksetUpdate) {
		// sanity check: we should not have a solution set and workset update at the same time
		// in an intermediate task
		if (isSolutionSetUpdate) {
			throw new IllegalStateException("Plan bug: Intermediate task performs workset and solutions set update.");
		}

		Collector<OT> outputCollector = createWorksetUpdateOutputCollector(delegate);

		// we need the WorksetUpdateOutputCollector separately to count the collected elements
		if (isWorksetIteration) {
			worksetUpdateOutputCollector = (WorksetUpdateOutputCollector<OT>) outputCollector;
		}

		setLastOutputCollector(outputCollector);
	} else if (isSolutionSetUpdate) {
		setLastOutputCollector(createSolutionSetUpdateOutputCollector(delegate));
	}
}
 
Example #4
Source Project: Flink-CEPplus   Author: ljygz   File: IterationTailTask.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// sanity check: the tail has to update either the workset or the solution set
	if (!isWorksetUpdate && !isSolutionSetUpdate) {
		throw new RuntimeException("The iteration tail doesn't update workset or the solution set.");
	}

	// set the last output collector of this task to reflect the iteration tail state update:
	// a) workset update,
	// b) solution set update, or
	// c) merged workset and solution set update

	Collector<OT> outputCollector = null;
	if (isWorksetUpdate) {
		outputCollector = createWorksetUpdateOutputCollector();

		// we need the WorksetUpdateOutputCollector separately to count the collected elements
		if (isWorksetIteration) {
			worksetUpdateOutputCollector = (WorksetUpdateOutputCollector<OT>) outputCollector;
		}
	}

	if (isSolutionSetUpdate) {
		if (isWorksetIteration) {
			outputCollector = createSolutionSetUpdateOutputCollector(outputCollector);
		}
		// Bulk iteration with termination criterion
		else {
			outputCollector = new Collector<OT>() {
				@Override
				public void collect(OT record) {}

				@Override
				public void close() {}
			};
		}

		if (!isWorksetUpdate) {
			solutionSetUpdateBarrier = SolutionSetUpdateBarrierBroker.instance().get(brokerKey());
		}
	}

	setLastOutputCollector(outputCollector);
}
 
Example #5
Source Project: flink   Author: flink-tpc-ds   File: IterationTailTask.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// sanity check: the tail has to update either the workset or the solution set
	if (!isWorksetUpdate && !isSolutionSetUpdate) {
		throw new RuntimeException("The iteration tail doesn't update workset or the solution set.");
	}

	// set the last output collector of this task to reflect the iteration tail state update:
	// a) workset update,
	// b) solution set update, or
	// c) merged workset and solution set update

	Collector<OT> outputCollector = null;
	if (isWorksetUpdate) {
		outputCollector = createWorksetUpdateOutputCollector();

		// we need the WorksetUpdateOutputCollector separately to count the collected elements
		if (isWorksetIteration) {
			worksetUpdateOutputCollector = (WorksetUpdateOutputCollector<OT>) outputCollector;
		}
	}

	if (isSolutionSetUpdate) {
		if (isWorksetIteration) {
			outputCollector = createSolutionSetUpdateOutputCollector(outputCollector);
		}
		// Bulk iteration with termination criterion
		else {
			outputCollector = new Collector<OT>() {
				@Override
				public void collect(OT record) {}

				@Override
				public void close() {}
			};
		}

		if (!isWorksetUpdate) {
			solutionSetUpdateBarrier = SolutionSetUpdateBarrierBroker.instance().get(brokerKey());
		}
	}

	setLastOutputCollector(outputCollector);
}
 
Example #6
Source Project: flink   Author: apache   File: IterationTailTask.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// sanity check: the tail has to update either the workset or the solution set
	if (!isWorksetUpdate && !isSolutionSetUpdate) {
		throw new RuntimeException("The iteration tail doesn't update workset or the solution set.");
	}

	// set the last output collector of this task to reflect the iteration tail state update:
	// a) workset update,
	// b) solution set update, or
	// c) merged workset and solution set update

	Collector<OT> outputCollector = null;
	if (isWorksetUpdate) {
		outputCollector = createWorksetUpdateOutputCollector();

		// we need the WorksetUpdateOutputCollector separately to count the collected elements
		if (isWorksetIteration) {
			worksetUpdateOutputCollector = (WorksetUpdateOutputCollector<OT>) outputCollector;
		}
	}

	if (isSolutionSetUpdate) {
		if (isWorksetIteration) {
			outputCollector = createSolutionSetUpdateOutputCollector(outputCollector);
		}
		// Bulk iteration with termination criterion
		else {
			outputCollector = new Collector<OT>() {
				@Override
				public void collect(OT record) {}

				@Override
				public void close() {}
			};
		}

		if (!isWorksetUpdate) {
			solutionSetUpdateBarrier = SolutionSetUpdateBarrierBroker.instance().get(brokerKey());
		}
	}

	setLastOutputCollector(outputCollector);
}
 
Example #7
Source Project: Flink-CEPplus   Author: ljygz   File: AbstractIterativeTask.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new {@link WorksetUpdateOutputCollector}.
 *
 * <p>This collector is used by {@link IterationIntermediateTask} or {@link IterationTailTask} to update the
 * workset.
 *
 * <p>If a non-null delegate is given, the new {@link Collector} will write to the solution set and also call
 * collect(T) of the delegate.
 *
 * @param delegate null -OR- the delegate on which to call collect() by the newly created collector
 * @return a new {@link WorksetUpdateOutputCollector}
 */
protected Collector<OT> createWorksetUpdateOutputCollector(Collector<OT> delegate) {
	DataOutputView outputView = worksetBackChannel.getWriteEnd();
	TypeSerializer<OT> serializer = getOutputSerializer();
	return new WorksetUpdateOutputCollector<OT>(outputView, serializer, delegate);
}
 
Example #8
Source Project: flink   Author: flink-tpc-ds   File: AbstractIterativeTask.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new {@link WorksetUpdateOutputCollector}.
 *
 * <p>This collector is used by {@link IterationIntermediateTask} or {@link IterationTailTask} to update the
 * workset.
 *
 * <p>If a non-null delegate is given, the new {@link Collector} will write to the solution set and also call
 * collect(T) of the delegate.
 *
 * @param delegate null -OR- the delegate on which to call collect() by the newly created collector
 * @return a new {@link WorksetUpdateOutputCollector}
 */
protected Collector<OT> createWorksetUpdateOutputCollector(Collector<OT> delegate) {
	DataOutputView outputView = worksetBackChannel.getWriteEnd();
	TypeSerializer<OT> serializer = getOutputSerializer();
	return new WorksetUpdateOutputCollector<OT>(outputView, serializer, delegate);
}
 
Example #9
Source Project: flink   Author: apache   File: AbstractIterativeTask.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new {@link WorksetUpdateOutputCollector}.
 *
 * <p>This collector is used by {@link IterationIntermediateTask} or {@link IterationTailTask} to update the
 * workset.
 *
 * <p>If a non-null delegate is given, the new {@link Collector} will write to the solution set and also call
 * collect(T) of the delegate.
 *
 * @param delegate null -OR- the delegate on which to call collect() by the newly created collector
 * @return a new {@link WorksetUpdateOutputCollector}
 */
protected Collector<OT> createWorksetUpdateOutputCollector(Collector<OT> delegate) {
	DataOutputView outputView = worksetBackChannel.getWriteEnd();
	TypeSerializer<OT> serializer = getOutputSerializer();
	return new WorksetUpdateOutputCollector<OT>(outputView, serializer, delegate);
}