Java Code Examples for org.apache.flink.api.java.typeutils.TypeExtractor#getBinaryOperatorReturnType()

The following examples show how to use org.apache.flink.api.java.typeutils.TypeExtractor#getBinaryOperatorReturnType() . 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: ConnectedStreams.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Applies a CoMap transformation on a {@link ConnectedStreams} and maps
 * the output to a common type. The transformation calls a
 * {@link CoMapFunction#map1} for each element of the first input and
 * {@link CoMapFunction#map2} for each element of the second input. Each
 * CoMapFunction call returns exactly one element.
 *
 * @param coMapper The CoMapFunction used to jointly transform the two input DataStreams
 * @return The transformed {@link DataStream}
 */
public <R> SingleOutputStreamOperator<R> map(CoMapFunction<IN1, IN2, R> coMapper) {

	TypeInformation<R> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
		coMapper,
		CoMapFunction.class,
		0,
		1,
		2,
		TypeExtractor.NO_INDEX,
		getType1(),
		getType2(),
		Utils.getCallLocationName(),
		true);

	return transform("Co-Map", outTypeInfo, new CoStreamMap<>(inputStream1.clean(coMapper)));

}
 
Example 2
Source File: ConnectedStreams.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Applies a CoMap transformation on a {@link ConnectedStreams} and maps
 * the output to a common type. The transformation calls a
 * {@link CoMapFunction#map1} for each element of the first input and
 * {@link CoMapFunction#map2} for each element of the second input. Each
 * CoMapFunction call returns exactly one element.
 *
 * @param coMapper The CoMapFunction used to jointly transform the two input DataStreams
 * @return The transformed {@link DataStream}
 */
public <R> SingleOutputStreamOperator<R> map(CoMapFunction<IN1, IN2, R> coMapper) {

	TypeInformation<R> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
		coMapper,
		CoMapFunction.class,
		0,
		1,
		2,
		TypeExtractor.NO_INDEX,
		getType1(),
		getType2(),
		Utils.getCallLocationName(),
		true);

	return map(coMapper, outTypeInfo);
}
 
Example 3
Source File: JoinedStreams.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Completes the join operation with the user function that is executed
 * for each combination of elements with the same key in a window.
 *
 * <p>Note: This method's return type does not support setting an operator-specific parallelism.
 * Due to binary backwards compatibility, this cannot be altered. Use the
 * {@link #with(FlatJoinFunction)}, method to set an operator-specific parallelism.
 */
public <T> DataStream<T> apply(FlatJoinFunction<T1, T2, T> function) {
	TypeInformation<T> resultType = TypeExtractor.getBinaryOperatorReturnType(
		function,
		FlatJoinFunction.class,
		0,
		1,
		2,
		new int[]{2, 0},
		input1.getType(),
		input2.getType(),
		"Join",
		false);

	return apply(function, resultType);
}
 
Example 4
Source File: JoinedStreams.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Completes the join operation with the user function that is executed
 * for each combination of elements with the same key in a window.
 *
 * <p>Note: This method's return type does not support setting an operator-specific parallelism.
 * Due to binary backwards compatibility, this cannot be altered. Use the {@link #with(JoinFunction)}
 * method to set an operator-specific parallelism.
 */
public <T> DataStream<T> apply(JoinFunction<T1, T2, T> function) {
	TypeInformation<T> resultType = TypeExtractor.getBinaryOperatorReturnType(
		function,
		JoinFunction.class,
		0,
		1,
		2,
		TypeExtractor.NO_INDEX,
		input1.getType(),
		input2.getType(),
		"Join",
		false);

	return apply(function, resultType);
}
 
Example 5
Source File: BroadcastConnectedStream.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Assumes as inputs a {@link BroadcastStream} and a non-keyed {@link DataStream} and applies the given
 * {@link BroadcastProcessFunction} on them, thereby creating a transformed output stream.
 *
 * @param function The {@link BroadcastProcessFunction} that is called for each element in the stream.
 * @param <OUT> The type of the output elements.
 * @return The transformed {@link DataStream}.
 */
@PublicEvolving
public <OUT> SingleOutputStreamOperator<OUT> process(final BroadcastProcessFunction<IN1, IN2, OUT> function) {

	TypeInformation<OUT> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
			function,
			BroadcastProcessFunction.class,
			0,
			1,
			2,
			TypeExtractor.NO_INDEX,
			getType1(),
			getType2(),
			Utils.getCallLocationName(),
			true);

	return process(function, outTypeInfo);
}
 
Example 6
Source File: ConnectedStreams.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Applies the given {@link CoProcessFunction} on the connected input streams,
 * thereby creating a transformed output stream.
 *
 * <p>The function will be called for every element in the input streams and can produce zero or
 * more output elements. Contrary to the {@link #flatMap(CoFlatMapFunction)} function, this
 * function can also query the time and set timers. When reacting to the firing of set timers
 * the function can directly emit elements and/or register yet more timers.
 *
 * @param coProcessFunction The {@link CoProcessFunction} that is called for each element
 *                      in the stream.
 *
 * @param <R> The type of elements emitted by the {@code CoProcessFunction}.
 *
 * @return The transformed {@link DataStream}.
 */
@PublicEvolving
public <R> SingleOutputStreamOperator<R> process(
		CoProcessFunction<IN1, IN2, R> coProcessFunction) {

	TypeInformation<R> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
		coProcessFunction,
		CoProcessFunction.class,
		0,
		1,
		2,
		TypeExtractor.NO_INDEX,
		getType1(),
		getType2(),
		Utils.getCallLocationName(),
		true);

	return process(coProcessFunction, outTypeInfo);
}
 
Example 7
Source File: ConnectedStreams.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Applies the given {@link KeyedCoProcessFunction} on the connected input keyed streams,
 * thereby creating a transformed output stream.
 *
 * <p>The function will be called for every element in the input keyed streams and can produce zero or
 * more output elements. Contrary to the {@link #flatMap(CoFlatMapFunction)} function, this
 * function can also query the time and set timers. When reacting to the firing of set timers
 * the function can directly emit elements and/or register yet more timers.
 *
 * @param keyedCoProcessFunction The {@link KeyedCoProcessFunction} that is called for each element
 *                      in the stream.
 *
 * @param <R> The type of elements emitted by the {@code CoProcessFunction}.
 *
 * @return The transformed {@link DataStream}.
 */
@PublicEvolving
public <K, R> SingleOutputStreamOperator<R> process(
	KeyedCoProcessFunction<K, IN1, IN2, R> keyedCoProcessFunction) {

	TypeInformation<R> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
		keyedCoProcessFunction,
		KeyedCoProcessFunction.class,
		1,
		2,
		3,
		TypeExtractor.NO_INDEX,
		getType1(),
		getType2(),
		Utils.getCallLocationName(),
		true);

	return process(keyedCoProcessFunction, outTypeInfo);
}
 
Example 8
Source File: ConnectedStreams.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Applies the given {@link KeyedCoProcessFunction} on the connected input keyed streams,
 * thereby creating a transformed output stream.
 *
 * <p>The function will be called for every element in the input keyed streams and can produce zero or
 * more output elements. Contrary to the {@link #flatMap(CoFlatMapFunction)} function, this
 * function can also query the time and set timers. When reacting to the firing of set timers
 * the function can directly emit elements and/or register yet more timers.
 *
 * @param keyedCoProcessFunction The {@link KeyedCoProcessFunction} that is called for each element
 *                      in the stream.
 *
 * @param <R> The type of elements emitted by the {@code CoProcessFunction}.
 *
 * @return The transformed {@link DataStream}.
 */
@PublicEvolving
public <K, R> SingleOutputStreamOperator<R> process(
	KeyedCoProcessFunction<K, IN1, IN2, R> keyedCoProcessFunction) {

	TypeInformation<R> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
		keyedCoProcessFunction,
		KeyedCoProcessFunction.class,
		1,
		2,
		3,
		TypeExtractor.NO_INDEX,
		getType1(),
		getType2(),
		Utils.getCallLocationName(),
		true);

	return process(keyedCoProcessFunction, outTypeInfo);
}
 
Example 9
Source File: ConnectedStreams.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Applies a CoFlatMap transformation on a {@link ConnectedStreams} and
 * maps the output to a common type. The transformation calls a
 * {@link CoFlatMapFunction#flatMap1} for each element of the first input
 * and {@link CoFlatMapFunction#flatMap2} for each element of the second
 * input. Each CoFlatMapFunction call returns any number of elements
 * including none.
 *
 * @param coFlatMapper
 *            The CoFlatMapFunction used to jointly transform the two input
 *            DataStreams
 * @return The transformed {@link DataStream}
 */
public <R> SingleOutputStreamOperator<R> flatMap(
		CoFlatMapFunction<IN1, IN2, R> coFlatMapper) {

	TypeInformation<R> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
		coFlatMapper,
		CoFlatMapFunction.class,
		0,
		1,
		2,
		TypeExtractor.NO_INDEX,
		getType1(),
		getType2(),
		Utils.getCallLocationName(),
		true);

	return flatMap(coFlatMapper, outTypeInfo);
}
 
Example 10
Source File: ConnectedStreams.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Applies a CoFlatMap transformation on a {@link ConnectedStreams} and
 * maps the output to a common type. The transformation calls a
 * {@link CoFlatMapFunction#flatMap1} for each element of the first input
 * and {@link CoFlatMapFunction#flatMap2} for each element of the second
 * input. Each CoFlatMapFunction call returns any number of elements
 * including none.
 *
 * @param coFlatMapper
 *            The CoFlatMapFunction used to jointly transform the two input
 *            DataStreams
 * @return The transformed {@link DataStream}
 */
public <R> SingleOutputStreamOperator<R> flatMap(
		CoFlatMapFunction<IN1, IN2, R> coFlatMapper) {

	TypeInformation<R> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
		coFlatMapper,
		CoFlatMapFunction.class,
		0,
		1,
		2,
		TypeExtractor.NO_INDEX,
		getType1(),
		getType2(),
		Utils.getCallLocationName(),
		true);

	return transform("Co-Flat Map", outTypeInfo, new CoStreamFlatMap<>(inputStream1.clean(coFlatMapper)));
}
 
Example 11
Source File: JoinedStreams.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Completes the join operation with the user function that is executed
 * for each combination of elements with the same key in a window.
 *
 * <p>Note: This method's return type does not support setting an operator-specific parallelism.
 * Due to binary backwards compatibility, this cannot be altered. Use the {@link #with(JoinFunction)}
 * method to set an operator-specific parallelism.
 */
public <T> DataStream<T> apply(JoinFunction<T1, T2, T> function) {
	TypeInformation<T> resultType = TypeExtractor.getBinaryOperatorReturnType(
		function,
		JoinFunction.class,
		0,
		1,
		2,
		TypeExtractor.NO_INDEX,
		input1.getType(),
		input2.getType(),
		"Join",
		false);

	return apply(function, resultType);
}
 
Example 12
Source File: JoinedStreams.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Completes the join operation with the user function that is executed
 * for each combination of elements with the same key in a window.
 *
 * <p>Note: This method's return type does not support setting an operator-specific parallelism.
 * Due to binary backwards compatibility, this cannot be altered. Use the
 * {@link #with(FlatJoinFunction)}, method to set an operator-specific parallelism.
 */
public <T> DataStream<T> apply(FlatJoinFunction<T1, T2, T> function) {
	TypeInformation<T> resultType = TypeExtractor.getBinaryOperatorReturnType(
		function,
		FlatJoinFunction.class,
		0,
		1,
		2,
		new int[]{2, 0},
		input1.getType(),
		input2.getType(),
		"Join",
		false);

	return apply(function, resultType);
}
 
Example 13
Source File: JoinedStreams.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Completes the join operation with the user function that is executed
 * for each combination of elements with the same key in a window.
 *
 * <p>Note: This method's return type does not support setting an operator-specific parallelism.
 * Due to binary backwards compatibility, this cannot be altered. Use the {@link #with(JoinFunction)}
 * method to set an operator-specific parallelism.
 */
public <T> DataStream<T> apply(JoinFunction<T1, T2, T> function) {
	TypeInformation<T> resultType = TypeExtractor.getBinaryOperatorReturnType(
		function,
		JoinFunction.class,
		0,
		1,
		2,
		TypeExtractor.NO_INDEX,
		input1.getType(),
		input2.getType(),
		"Join",
		false);

	return apply(function, resultType);
}
 
Example 14
Source File: BroadcastConnectedStream.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Assumes as inputs a {@link BroadcastStream} and a non-keyed {@link DataStream} and applies the given
 * {@link BroadcastProcessFunction} on them, thereby creating a transformed output stream.
 *
 * @param function The {@link BroadcastProcessFunction} that is called for each element in the stream.
 * @param <OUT> The type of the output elements.
 * @return The transformed {@link DataStream}.
 */
@PublicEvolving
public <OUT> SingleOutputStreamOperator<OUT> process(final BroadcastProcessFunction<IN1, IN2, OUT> function) {

	TypeInformation<OUT> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
			function,
			BroadcastProcessFunction.class,
			0,
			1,
			2,
			TypeExtractor.NO_INDEX,
			getType1(),
			getType2(),
			Utils.getCallLocationName(),
			true);

	return process(function, outTypeInfo);
}
 
Example 15
Source File: BroadcastConnectedStream.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Assumes as inputs a {@link BroadcastStream} and a {@link KeyedStream} and applies the given
 * {@link KeyedBroadcastProcessFunction} on them, thereby creating a transformed output stream.
 *
 * @param function The {@link KeyedBroadcastProcessFunction} that is called for each element in the stream.
 * @param <KS> The type of the keys in the keyed stream.
 * @param <OUT> The type of the output elements.
 * @return The transformed {@link DataStream}.
 */
@PublicEvolving
public <KS, OUT> SingleOutputStreamOperator<OUT> process(final KeyedBroadcastProcessFunction<KS, IN1, IN2, OUT> function) {

	TypeInformation<OUT> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
			function,
			KeyedBroadcastProcessFunction.class,
			1,
			2,
			3,
			TypeExtractor.NO_INDEX,
			getType1(),
			getType2(),
			Utils.getCallLocationName(),
			true);

	return process(function, outTypeInfo);
}
 
Example 16
Source File: KeyedStream.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Completes the join operation with the given user function that is executed for each joined pair
 * of elements.
 *
 * @param processJoinFunction The user-defined process join function.
 * @param <OUT> The output type.
 * @return The transformed {@link DataStream}.
 */
@PublicEvolving
public <OUT> SingleOutputStreamOperator<OUT> process(ProcessJoinFunction<IN1, IN2, OUT> processJoinFunction) {
	Preconditions.checkNotNull(processJoinFunction);

	final TypeInformation<OUT> outputType = TypeExtractor.getBinaryOperatorReturnType(
		processJoinFunction,
		ProcessJoinFunction.class,
		0,
		1,
		2,
		TypeExtractor.NO_INDEX,
		left.getType(),
		right.getType(),
		Utils.getCallLocationName(),
		true
	);

	return process(processJoinFunction, outputType);
}
 
Example 17
Source File: ConnectedStreams.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Applies the given {@link CoProcessFunction} on the connected input streams,
 * thereby creating a transformed output stream.
 *
 * <p>The function will be called for every element in the input streams and can produce zero or
 * more output elements. Contrary to the {@link #flatMap(CoFlatMapFunction)} function, this
 * function can also query the time and set timers. When reacting to the firing of set timers
 * the function can directly emit elements and/or register yet more timers.
 *
 * @param coProcessFunction The {@link CoProcessFunction} that is called for each element
 *                      in the stream.
 *
 * @param <R> The type of elements emitted by the {@code CoProcessFunction}.
 *
 * @return The transformed {@link DataStream}.
 */
@PublicEvolving
public <R> SingleOutputStreamOperator<R> process(
		CoProcessFunction<IN1, IN2, R> coProcessFunction) {

	TypeInformation<R> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
		coProcessFunction,
		CoProcessFunction.class,
		0,
		1,
		2,
		TypeExtractor.NO_INDEX,
		getType1(),
		getType2(),
		Utils.getCallLocationName(),
		true);

	return process(coProcessFunction, outTypeInfo);
}
 
Example 18
Source File: ConnectedStreams.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Applies a CoFlatMap transformation on a {@link ConnectedStreams} and
 * maps the output to a common type. The transformation calls a
 * {@link CoFlatMapFunction#flatMap1} for each element of the first input
 * and {@link CoFlatMapFunction#flatMap2} for each element of the second
 * input. Each CoFlatMapFunction call returns any number of elements
 * including none.
 *
 * @param coFlatMapper
 *            The CoFlatMapFunction used to jointly transform the two input
 *            DataStreams
 * @return The transformed {@link DataStream}
 */
public <R> SingleOutputStreamOperator<R> flatMap(
		CoFlatMapFunction<IN1, IN2, R> coFlatMapper) {

	TypeInformation<R> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
		coFlatMapper,
		CoFlatMapFunction.class,
		0,
		1,
		2,
		TypeExtractor.NO_INDEX,
		getType1(),
		getType2(),
		Utils.getCallLocationName(),
		true);

	return transform("Co-Flat Map", outTypeInfo, new CoStreamFlatMap<>(inputStream1.clean(coFlatMapper)));
}
 
Example 19
Source File: ConnectedStreams.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Applies a CoMap transformation on a {@link ConnectedStreams} and maps
 * the output to a common type. The transformation calls a
 * {@link CoMapFunction#map1} for each element of the first input and
 * {@link CoMapFunction#map2} for each element of the second input. Each
 * CoMapFunction call returns exactly one element.
 *
 * @param coMapper The CoMapFunction used to jointly transform the two input DataStreams
 * @return The transformed {@link DataStream}
 */
public <R> SingleOutputStreamOperator<R> map(CoMapFunction<IN1, IN2, R> coMapper) {

	TypeInformation<R> outTypeInfo = TypeExtractor.getBinaryOperatorReturnType(
		coMapper,
		CoMapFunction.class,
		0,
		1,
		2,
		TypeExtractor.NO_INDEX,
		getType1(),
		getType2(),
		Utils.getCallLocationName(),
		true);

	return transform("Co-Map", outTypeInfo, new CoStreamMap<>(inputStream1.clean(coMapper)));

}
 
Example 20
Source File: JoinedStreams.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Completes the join operation with the user function that is executed
 * for each combination of elements with the same key in a window.
 *
 * <p>Note: This method's return type does not support setting an operator-specific parallelism.
 * Due to binary backwards compatibility, this cannot be altered. Use the
 * {@link #with(FlatJoinFunction)}, method to set an operator-specific parallelism.
 */
public <T> DataStream<T> apply(FlatJoinFunction<T1, T2, T> function) {
	TypeInformation<T> resultType = TypeExtractor.getBinaryOperatorReturnType(
		function,
		FlatJoinFunction.class,
		0,
		1,
		2,
		new int[]{2, 0},
		input1.getType(),
		input2.getType(),
		"Join",
		false);

	return apply(function, resultType);
}