Class PatternTimeoutFlatSelectAdapter<IN,OUT,T>
java.lang.Object
org.apache.flink.api.common.functions.AbstractRichFunction
org.apache.flink.cep.functions.PatternProcessFunction<IN,OUT>
org.apache.flink.cep.functions.adaptors.PatternFlatSelectAdapter<IN,OUT>
org.apache.flink.cep.functions.adaptors.PatternTimeoutFlatSelectAdapter<IN,OUT,T>
- All Implemented Interfaces:
Serializable,org.apache.flink.api.common.functions.Function,org.apache.flink.api.common.functions.RichFunction,TimedOutPartialMatchHandler<IN>
@Internal
public class PatternTimeoutFlatSelectAdapter<IN,OUT,T>
extends PatternFlatSelectAdapter<IN,OUT>
implements TimedOutPartialMatchHandler<IN>
Adapter that expresses combination of
PatternFlatSelectFunction and PatternTimeoutFlatSelectAdapter with PatternProcessFunction.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.flink.cep.functions.PatternProcessFunction
PatternProcessFunction.Context -
Constructor Summary
ConstructorsConstructorDescriptionPatternTimeoutFlatSelectAdapter(PatternFlatSelectFunction<IN, OUT> flatSelectFunction, PatternFlatTimeoutFunction<IN, T> flatTimeoutFunction, org.apache.flink.util.OutputTag<T> timedOutPartialMatchesTag) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidopen(org.apache.flink.api.common.functions.OpenContext openContext) voidprocessTimedOutMatch(Map<String, List<IN>> match, PatternProcessFunction.Context ctx) Called for every timed out partial match (due toPattern.within(Duration)).Methods inherited from class org.apache.flink.cep.functions.adaptors.PatternFlatSelectAdapter
processMatchMethods inherited from class org.apache.flink.api.common.functions.AbstractRichFunction
getIterationRuntimeContext, getRuntimeContext, setRuntimeContext
-
Constructor Details
-
PatternTimeoutFlatSelectAdapter
public PatternTimeoutFlatSelectAdapter(PatternFlatSelectFunction<IN, OUT> flatSelectFunction, PatternFlatTimeoutFunction<IN, T> flatTimeoutFunction, org.apache.flink.util.OutputTag<T> timedOutPartialMatchesTag)
-
-
Method Details
-
open
- Specified by:
openin interfaceorg.apache.flink.api.common.functions.RichFunction- Overrides:
openin classPatternFlatSelectAdapter<IN,OUT> - Throws:
Exception
-
close
- Specified by:
closein interfaceorg.apache.flink.api.common.functions.RichFunction- Overrides:
closein classPatternFlatSelectAdapter<IN,OUT> - Throws:
Exception
-
processTimedOutMatch
public void processTimedOutMatch(Map<String, List<IN>> match, PatternProcessFunction.Context ctx) throws ExceptionDescription copied from interface:TimedOutPartialMatchHandlerCalled for every timed out partial match (due toPattern.within(Duration)). It enables custom handling, e.g. one can emit the timed out results through a side output:private final OutputTag<T> timedOutPartialMatchesTag = ... private class MyFunction extends PatternProcessFunction<IN, OUT> implements TimedOutPartialMatchHandler<IN> { @Override public void processMatch(Map<String, List<IN>> match, Context ctx, Collector<OUT> out) throws Exception { ... } @Override void processTimedOutMatch(Map<String, List<IN>> match, PatternProcessFunction.Context ctx) throws Exception { ctx.output(timedOutPartialMatchesTag, match); } }TimeContext.timestamp()in this case returns the minimal time in which we can say that the partial match will not become a match, which is effectively the timestamp of the first element assigned to the partial match plus the value of within.- Specified by:
processTimedOutMatchin interfaceTimedOutPartialMatchHandler<IN>- Parameters:
match- map containing the timed out partial match. Events are identified by their names.ctx- enables access to time features and emitting results through side outputs- Throws:
Exception- This method may throw exceptions. Throwing an exception will cause the operation to fail and may trigger recovery.
-