org.apache.flink.streaming.api.functions.co.CoProcessFunction Java Examples
The following examples show how to use
org.apache.flink.streaming.api.functions.co.CoProcessFunction.
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: ProcessFunctionTestHarnesses.java From flink with Apache License 2.0 | 6 votes |
/** * Returns an initialized test harness for {@link CoProcessFunction} with two input streams. * * @param function instance of a {@link CoProcessFunction} under test * @param <IN1> type of first input stream elements * @param <IN2> type of second input stream elements * @param <OUT> type of output stream elements * @return {@link TwoInputStreamOperatorTestHarness} wrapped around {@code function} */ public static <IN1, IN2, OUT> TwoInputStreamOperatorTestHarness<IN1, IN2, OUT> forCoProcessFunction( final CoProcessFunction<IN1, IN2, OUT> function) throws Exception { TwoInputStreamOperatorTestHarness<IN1, IN2, OUT> testHarness = new TwoInputStreamOperatorTestHarness<>( new CoProcessOperator<>( Preconditions.checkNotNull(function)), 1, 1, 0); testHarness.open(); return testHarness; }
Example #2
Source File: ConnectedStreams.java From flink with Apache License 2.0 | 6 votes |
/** * 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 #3
Source File: ConnectedStreams.java From flink with Apache License 2.0 | 6 votes |
/** * 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 #4
Source File: ConnectedStreams.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * 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 #5
Source File: KeyedCoProcessOperatorWithWatermarkDelay.java From flink with Apache License 2.0 | 5 votes |
public KeyedCoProcessOperatorWithWatermarkDelay(CoProcessFunction<IN1, IN2, OUT> flatMapper, long watermarkDelay) { super(flatMapper); Preconditions.checkArgument(watermarkDelay >= 0, "The watermark delay should be non-negative."); if (watermarkDelay == 0) { // emits watermark without delay emitter = (Consumer<Watermark> & Serializable) (Watermark mark) -> output.emitWatermark(mark); } else { // emits watermark with delay emitter = (Consumer<Watermark> & Serializable) (Watermark mark) -> output .emitWatermark(new Watermark(mark.getTimestamp() - watermarkDelay)); } }
Example #6
Source File: CoProcessOperator.java From flink with Apache License 2.0 | 4 votes |
ContextImpl(CoProcessFunction<IN1, IN2, OUT> function, ProcessingTimeService timerService) { function.super(); this.timerService = checkNotNull(timerService); }
Example #7
Source File: LegacyKeyedCoProcessOperator.java From flink with Apache License 2.0 | 4 votes |
OnTimerContextImpl(CoProcessFunction<IN1, IN2, OUT> function, TimerService timerService) { function.super(); this.timerService = checkNotNull(timerService); }
Example #8
Source File: LegacyKeyedCoProcessOperator.java From flink with Apache License 2.0 | 4 votes |
ContextImpl(CoProcessFunction<IN1, IN2, OUT> function, TimerService timerService) { function.super(); this.timerService = checkNotNull(timerService); }
Example #9
Source File: LegacyKeyedCoProcessOperator.java From flink with Apache License 2.0 | 4 votes |
public LegacyKeyedCoProcessOperator(CoProcessFunction<IN1, IN2, OUT> flatMapper) { super(flatMapper); }
Example #10
Source File: CoProcessOperator.java From flink with Apache License 2.0 | 4 votes |
ContextImpl(CoProcessFunction<IN1, IN2, OUT> function, ProcessingTimeService timerService) { function.super(); this.timerService = checkNotNull(timerService); }
Example #11
Source File: CoProcessOperator.java From flink with Apache License 2.0 | 4 votes |
public CoProcessOperator(CoProcessFunction<IN1, IN2, OUT> flatMapper) { super(flatMapper); }
Example #12
Source File: ConnectedStreams.java From flink with Apache License 2.0 | 4 votes |
/** * 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}. */ @Internal public <R> SingleOutputStreamOperator<R> process( CoProcessFunction<IN1, IN2, R> coProcessFunction, TypeInformation<R> outputType) { TwoInputStreamOperator<IN1, IN2, R> operator; if ((inputStream1 instanceof KeyedStream) && (inputStream2 instanceof KeyedStream)) { operator = new LegacyKeyedCoProcessOperator<>(inputStream1.clean(coProcessFunction)); } else { operator = new CoProcessOperator<>(inputStream1.clean(coProcessFunction)); } return transform("Co-Process", outputType, operator); }
Example #13
Source File: LegacyKeyedCoProcessOperator.java From flink with Apache License 2.0 | 4 votes |
OnTimerContextImpl(CoProcessFunction<IN1, IN2, OUT> function, TimerService timerService) { function.super(); this.timerService = checkNotNull(timerService); }
Example #14
Source File: LegacyKeyedCoProcessOperator.java From flink with Apache License 2.0 | 4 votes |
ContextImpl(CoProcessFunction<IN1, IN2, OUT> function, TimerService timerService) { function.super(); this.timerService = checkNotNull(timerService); }
Example #15
Source File: LegacyKeyedCoProcessOperator.java From flink with Apache License 2.0 | 4 votes |
public LegacyKeyedCoProcessOperator(CoProcessFunction<IN1, IN2, OUT> flatMapper) { super(flatMapper); }
Example #16
Source File: CoProcessOperator.java From flink with Apache License 2.0 | 4 votes |
public CoProcessOperator(CoProcessFunction<IN1, IN2, OUT> flatMapper) { super(flatMapper); }
Example #17
Source File: ConnectedStreams.java From flink with Apache License 2.0 | 4 votes |
/** * 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}. */ @Internal public <R> SingleOutputStreamOperator<R> process( CoProcessFunction<IN1, IN2, R> coProcessFunction, TypeInformation<R> outputType) { TwoInputStreamOperator<IN1, IN2, R> operator; if ((inputStream1 instanceof KeyedStream) && (inputStream2 instanceof KeyedStream)) { operator = new LegacyKeyedCoProcessOperator<>(inputStream1.clean(coProcessFunction)); } else { operator = new CoProcessOperator<>(inputStream1.clean(coProcessFunction)); } return transform("Co-Process", outputType, operator); }
Example #18
Source File: KeyedCoProcessOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
OnTimerContextImpl(CoProcessFunction<IN1, IN2, OUT> function, TimerService timerService) { function.super(); this.timerService = checkNotNull(timerService); }
Example #19
Source File: KeyedCoProcessOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
ContextImpl(CoProcessFunction<IN1, IN2, OUT> function, TimerService timerService) { function.super(); this.timerService = checkNotNull(timerService); }
Example #20
Source File: KeyedCoProcessOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public KeyedCoProcessOperator(CoProcessFunction<IN1, IN2, OUT> coProcessFunction) { super(coProcessFunction); }
Example #21
Source File: CoProcessOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
ContextImpl(CoProcessFunction<IN1, IN2, OUT> function, ProcessingTimeService timerService) { function.super(); this.timerService = checkNotNull(timerService); }
Example #22
Source File: CoProcessOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public CoProcessOperator(CoProcessFunction<IN1, IN2, OUT> flatMapper) { super(flatMapper); }
Example #23
Source File: ConnectedStreams.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * 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}. */ @Internal public <R> SingleOutputStreamOperator<R> process( CoProcessFunction<IN1, IN2, R> coProcessFunction, TypeInformation<R> outputType) { TwoInputStreamOperator<IN1, IN2, R> operator; if ((inputStream1 instanceof KeyedStream) && (inputStream2 instanceof KeyedStream)) { operator = new KeyedCoProcessOperator<>(inputStream1.clean(coProcessFunction)); } else { operator = new CoProcessOperator<>(inputStream1.clean(coProcessFunction)); } return transform("Co-Process", outputType, operator); }