org.apache.flink.streaming.api.transformations.UnionTransformation Java Examples

The following examples show how to use org.apache.flink.streaming.api.transformations.UnionTransformation. 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 File: DataStream.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link DataStream} by merging {@link DataStream} outputs of
 * the same type with each other. The DataStreams merged using this operator
 * will be transformed simultaneously.
 *
 * @param streams
 *            The DataStreams to union output with.
 * @return The {@link DataStream}.
 */
@SafeVarargs
public final DataStream<T> union(DataStream<T>... streams) {
	List<StreamTransformation<T>> unionedTransforms = new ArrayList<>();
	unionedTransforms.add(this.transformation);

	for (DataStream<T> newStream : streams) {
		if (!getType().equals(newStream.getType())) {
			throw new IllegalArgumentException("Cannot union streams of different types: "
					+ getType() + " and " + newStream.getType());
		}

		unionedTransforms.add(newStream.getTransformation());
	}
	return new DataStream<>(this.environment, new UnionTransformation<>(unionedTransforms));
}
 
Example #2
Source File: DataStream.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link DataStream} by merging {@link DataStream} outputs of
 * the same type with each other. The DataStreams merged using this operator
 * will be transformed simultaneously.
 *
 * @param streams
 *            The DataStreams to union output with.
 * @return The {@link DataStream}.
 */
@SafeVarargs
public final DataStream<T> union(DataStream<T>... streams) {
	List<Transformation<T>> unionedTransforms = new ArrayList<>();
	unionedTransforms.add(this.transformation);

	for (DataStream<T> newStream : streams) {
		if (!getType().equals(newStream.getType())) {
			throw new IllegalArgumentException("Cannot union streams of different types: "
					+ getType() + " and " + newStream.getType());
		}

		unionedTransforms.add(newStream.getTransformation());
	}
	return new DataStream<>(this.environment, new UnionTransformation<>(unionedTransforms));
}
 
Example #3
Source File: DataStream.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link DataStream} by merging {@link DataStream} outputs of
 * the same type with each other. The DataStreams merged using this operator
 * will be transformed simultaneously.
 *
 * @param streams
 *            The DataStreams to union output with.
 * @return The {@link DataStream}.
 */
@SafeVarargs
public final DataStream<T> union(DataStream<T>... streams) {
	List<Transformation<T>> unionedTransforms = new ArrayList<>();
	unionedTransforms.add(this.transformation);

	for (DataStream<T> newStream : streams) {
		if (!getType().equals(newStream.getType())) {
			throw new IllegalArgumentException("Cannot union streams of different types: "
					+ getType() + " and " + newStream.getType());
		}

		unionedTransforms.add(newStream.getTransformation());
	}
	return new DataStream<>(this.environment, new UnionTransformation<>(unionedTransforms));
}
 
Example #4
Source File: StreamGraphGenerator.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Transforms a {@code UnionTransformation}.
 *
 * <p>This is easy, we only have to transform the inputs and return all the IDs in a list so
 * that downstream operations can connect to all upstream nodes.
 */
private <T> Collection<Integer> transformUnion(UnionTransformation<T> union) {
	List<StreamTransformation<T>> inputs = union.getInputs();
	List<Integer> resultIds = new ArrayList<>();

	for (StreamTransformation<T> input: inputs) {
		resultIds.addAll(transform(input));
	}

	return resultIds;
}
 
Example #5
Source File: StreamGraphGenerator.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private <T> void validateSplitTransformation(StreamTransformation<T> input) {
	if (input instanceof SelectTransformation || input instanceof SplitTransformation) {
		throw new IllegalStateException("Consecutive multiple splits are not supported. Splits are deprecated. Please use side-outputs.");
	} else if (input instanceof SideOutputTransformation) {
		throw new IllegalStateException("Split after side-outputs are not supported. Splits are deprecated. Please use side-outputs.");
	} else if (input instanceof UnionTransformation) {
		for (StreamTransformation<T> transformation : ((UnionTransformation<T>) input).getInputs()) {
			validateSplitTransformation(transformation);
		}
	} else if (input instanceof PartitionTransformation) {
		validateSplitTransformation(((PartitionTransformation) input).getInput());
	} else {
		return;
	}
}
 
Example #6
Source File: StreamGraphGenerator.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Transforms a {@code UnionTransformation}.
 *
 * <p>This is easy, we only have to transform the inputs and return all the IDs in a list so
 * that downstream operations can connect to all upstream nodes.
 */
private <T> Collection<Integer> transformUnion(UnionTransformation<T> union) {
	List<Transformation<T>> inputs = union.getInputs();
	List<Integer> resultIds = new ArrayList<>();

	for (Transformation<T> input: inputs) {
		resultIds.addAll(transform(input));
	}

	return resultIds;
}
 
Example #7
Source File: StreamGraphGenerator.java    From flink with Apache License 2.0 5 votes vote down vote up
private <T> void validateSplitTransformation(Transformation<T> input) {
	if (input instanceof SelectTransformation || input instanceof SplitTransformation) {
		throw new IllegalStateException("Consecutive multiple splits are not supported. Splits are deprecated. Please use side-outputs.");
	} else if (input instanceof SideOutputTransformation) {
		throw new IllegalStateException("Split after side-outputs are not supported. Splits are deprecated. Please use side-outputs.");
	} else if (input instanceof UnionTransformation) {
		for (Transformation<T> transformation : ((UnionTransformation<T>) input).getInputs()) {
			validateSplitTransformation(transformation);
		}
	} else if (input instanceof PartitionTransformation) {
		validateSplitTransformation(((PartitionTransformation) input).getInput());
	} else {
		return;
	}
}
 
Example #8
Source File: StreamGraphGenerator.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Transforms a {@code UnionTransformation}.
 *
 * <p>This is easy, we only have to transform the inputs and return all the IDs in a list so
 * that downstream operations can connect to all upstream nodes.
 */
private <T> Collection<Integer> transformUnion(UnionTransformation<T> union) {
	List<Transformation<T>> inputs = union.getInputs();
	List<Integer> resultIds = new ArrayList<>();

	for (Transformation<T> input: inputs) {
		resultIds.addAll(transform(input));
	}

	return resultIds;
}
 
Example #9
Source File: StreamGraphGenerator.java    From flink with Apache License 2.0 5 votes vote down vote up
private <T> void validateSplitTransformation(Transformation<T> input) {
	if (input instanceof SelectTransformation || input instanceof SplitTransformation) {
		throw new IllegalStateException("Consecutive multiple splits are not supported. Splits are deprecated. Please use side-outputs.");
	} else if (input instanceof SideOutputTransformation) {
		throw new IllegalStateException("Split after side-outputs are not supported. Splits are deprecated. Please use side-outputs.");
	} else if (input instanceof UnionTransformation) {
		for (Transformation<T> transformation : ((UnionTransformation<T>) input).getInputs()) {
			validateSplitTransformation(transformation);
		}
	} else if (input instanceof PartitionTransformation) {
		validateSplitTransformation(((PartitionTransformation) input).getInput());
	} else {
		return;
	}
}