Java Code Examples for org.apache.flink.cep.PatternStream#select()
The following examples show how to use
org.apache.flink.cep.PatternStream#select() .
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: PatternEvaluationTests.java From flink-cep-dsl with Apache License 2.0 | 6 votes |
private void executeTest(String pattern, List<Event> data) throws Exception { StreamExecutionEnvironment streamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment(); DataStream<Event> eventDataStream = streamExecutionEnvironment.fromCollection(data); PatternStream<Event> patternStream = Dsl.compile(pattern, eventDataStream); patternStream.select(new PatternSelectFunction<Event, Event>() { private static final long serialVersionUID = 7242171752905668044L; @Override public Event select(Map<String, List<Event>> map) { results.putAll(map); return null; } }); streamExecutionEnvironment.execute("test"); }
Example 2
Source File: PatternExecutor.java From flink-cep-dsl with Apache License 2.0 | 6 votes |
static void executeTest(String pattern, List<Event> data) throws Exception { StreamExecutionEnvironment streamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment(); DataStream<Event> eventDataStream = streamExecutionEnvironment.fromCollection(data); PatternStream<Event> patternStream = Dsl.compile(pattern, eventDataStream); patternStream.select(new PatternSelectFunction<Event, Event>() { private static final long serialVersionUID = 7242171752905668044L; @Override public Event select(Map<String, List<Event>> map) { results.add(map); return null; } }); streamExecutionEnvironment.execute("test"); }
Example 3
Source File: WeatherDataComplexEventProcessingExample2.java From FlinkExperiments with MIT License | 6 votes |
private static <TWarningType extends IWarning> DataStream<TWarningType> toWarningStream(DataStream<LocalWeatherData> localWeatherDataDataStream, IWarningPattern<LocalWeatherData, TWarningType> warningPattern) { PatternStream<LocalWeatherData> tempPatternStream = CEP.pattern( localWeatherDataDataStream.keyBy(new KeySelector<LocalWeatherData, String>() { @Override public String getKey(LocalWeatherData localWeatherData) throws Exception { return localWeatherData.getStation().getWban(); } }), warningPattern.getEventPattern()); DataStream<TWarningType> warnings = tempPatternStream.select(new PatternSelectFunction<LocalWeatherData, TWarningType>() { @Override public TWarningType select(Map<String, List<LocalWeatherData>> map) throws Exception { return warningPattern.create(map); } }, new GenericTypeInfo<TWarningType>(warningPattern.getWarningTargetType())); return warnings; }
Example 4
Source File: WeatherDataComplexEventProcessingExample.java From FlinkExperiments with MIT License | 6 votes |
private static <TWarningType extends IWarning> DataStream<TWarningType> toWarningStream(DataStream<LocalWeatherData> localWeatherDataDataStream, IWarningPattern<LocalWeatherData, TWarningType> warningPattern) { PatternStream<LocalWeatherData> tempPatternStream = CEP.pattern( localWeatherDataDataStream.keyBy(new KeySelector<LocalWeatherData, String>() { @Override public String getKey(LocalWeatherData localWeatherData) throws Exception { return localWeatherData.getStation().getWban(); } }), warningPattern.getEventPattern()); DataStream<TWarningType> warnings = tempPatternStream.select(new PatternSelectFunction<LocalWeatherData, TWarningType>() { @Override public TWarningType select(Map<String, List<LocalWeatherData>> map) throws Exception { return warningPattern.create(map); } }, new GenericTypeInfo<TWarningType>(warningPattern.getWarningTargetType())); return warnings; }