当前位置: 首页>>代码示例>>Java>>正文


Java PatternSelectFunction类代码示例

本文整理汇总了Java中org.apache.flink.cep.PatternSelectFunction的典型用法代码示例。如果您正苦于以下问题:Java PatternSelectFunction类的具体用法?Java PatternSelectFunction怎么用?Java PatternSelectFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PatternSelectFunction类属于org.apache.flink.cep包,在下文中一共展示了PatternSelectFunction类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.flink.cep.PatternSelectFunction; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

	Properties properties = new Properties();
	properties.setProperty("bootstrap.servers", "localhost:9092");
	properties.setProperty("group.id", "test");

	DataStream<TemperatureEvent> inputEventStream = env.addSource(
			new FlinkKafkaConsumer09<TemperatureEvent>("test", new EventDeserializationSchema(), properties));

	Pattern<TemperatureEvent, ?> warningPattern = Pattern.<TemperatureEvent> begin("first")
			.subtype(TemperatureEvent.class).where(new FilterFunction<TemperatureEvent>() {
				private static final long serialVersionUID = 1L;

				public boolean filter(TemperatureEvent value) {
					if (value.getTemperature() >= 26.0) {
						return true;
					}
					return false;
				}
			}).within(Time.seconds(10));

	DataStream<Alert> patternStream = CEP.pattern(inputEventStream, warningPattern)
			.select(new PatternSelectFunction<TemperatureEvent, Alert>() {
				private static final long serialVersionUID = 1L;

				public Alert select(Map<String, TemperatureEvent> event) throws Exception {

					return new Alert("Temperature Rise Detected:" + event.get("first").getTemperature()
							+ " on machine name:" + event.get("first").getMachineName());
				}

			});

	patternStream.print();
	env.execute("CEP on Temperature Sensor");
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Apache-Flink,代码行数:38,代码来源:KafkaApp.java

示例2: toWarningStream

import org.apache.flink.cep.PatternSelectFunction; //导入依赖的package包/类
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;
}
 
开发者ID:bytefish,项目名称:FlinkExperiments,代码行数:20,代码来源:WeatherDataComplexEventProcessingExample2.java

示例3: SelectTimeoutCepOperator

import org.apache.flink.cep.PatternSelectFunction; //导入依赖的package包/类
public SelectTimeoutCepOperator(
	TypeSerializer<IN> inputSerializer,
	boolean isProcessingTime,
	NFACompiler.NFAFactory<IN> nfaFactory,
	final EventComparator<IN> comparator,
	AfterMatchSkipStrategy skipStrategy,
	PatternSelectFunction<IN, OUT1> flatSelectFunction,
	PatternTimeoutFunction<IN, OUT2> flatTimeoutFunction,
	OutputTag<OUT2> outputTag) {
	super(
		inputSerializer,
		isProcessingTime,
		nfaFactory,
		comparator,
		skipStrategy,
		new SelectWrapper<>(flatSelectFunction, flatTimeoutFunction));
	this.timedOutOutputTag = outputTag;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:SelectTimeoutCepOperator.java

示例4: getKeyedCepOpearator

import org.apache.flink.cep.PatternSelectFunction; //导入依赖的package包/类
public static <K> SelectCepOperator<Event, K, Map<String, List<Event>>> getKeyedCepOpearator(
	boolean isProcessingTime,
	NFACompiler.NFAFactory<Event> nfaFactory,
	EventComparator<Event> comparator) {
	return new SelectCepOperator<>(
		Event.createTypeSerializer(),
		isProcessingTime,
		nfaFactory,
		comparator,
		null,
		new PatternSelectFunction<Event, Map<String, List<Event>>>() {
			@Override
			public Map<String, List<Event>> select(Map<String, List<Event>> pattern) throws Exception {
				return pattern;
			}
		});
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:CepOperatorTestUtilities.java

示例5: main

import org.apache.flink.cep.PatternSelectFunction; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	DataStream<TemperatureEvent> inputEventStream = env.fromElements(new TemperatureEvent("xyz", 22.0),
			new TemperatureEvent("xyz", 20.1), new TemperatureEvent("xyz", 21.1), new TemperatureEvent("xyz", 22.2),
			new TemperatureEvent("xyz", 29.1), new TemperatureEvent("xyz", 22.3), new TemperatureEvent("xyz", 22.1),
			new TemperatureEvent("xyz", 22.4), new TemperatureEvent("xyz", 22.7),
			new TemperatureEvent("xyz", 27.0));

	Pattern<TemperatureEvent, ?> warningPattern = Pattern.<TemperatureEvent> begin("first")
			.subtype(TemperatureEvent.class).where(new FilterFunction<TemperatureEvent>() {
				private static final long serialVersionUID = 1L;

				public boolean filter(TemperatureEvent value) {
					if (value.getTemperature() >= 26.0) {
						return true;
					}
					return false;
				}
			}).within(Time.seconds(10));

	DataStream<Alert> patternStream = CEP.pattern(inputEventStream, warningPattern)
			.select(new PatternSelectFunction<TemperatureEvent, Alert>() {
				private static final long serialVersionUID = 1L;

				public Alert select(Map<String, TemperatureEvent> event) throws Exception {

					return new Alert("Temperature Rise Detected");
				}

			});

	patternStream.print();
	env.execute("CEP on Temperature Sensor");
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Apache-Flink,代码行数:35,代码来源:App.java

示例6: SelectCepOperator

import org.apache.flink.cep.PatternSelectFunction; //导入依赖的package包/类
public SelectCepOperator(
	TypeSerializer<IN> inputSerializer,
	boolean isProcessingTime,
	NFACompiler.NFAFactory<IN> nfaFactory,
	EventComparator<IN> comparator,
	AfterMatchSkipStrategy skipStrategy,
	PatternSelectFunction<IN, OUT> function) {
	super(inputSerializer, isProcessingTime, nfaFactory, comparator, skipStrategy, function);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:SelectCepOperator.java

示例7: getFlatSelectFunction

import org.apache.flink.cep.PatternSelectFunction; //导入依赖的package包/类
PatternSelectFunction<IN, OUT1> getFlatSelectFunction() {
	return flatSelectFunction;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:4,代码来源:SelectTimeoutCepOperator.java

示例8: SelectWrapper

import org.apache.flink.cep.PatternSelectFunction; //导入依赖的package包/类
public SelectWrapper(
	PatternSelectFunction<IN, OUT1> flatSelectFunction,
	PatternTimeoutFunction<IN, OUT2> flatTimeoutFunction) {
	this.flatSelectFunction = flatSelectFunction;
	this.flatTimeoutFunction = flatTimeoutFunction;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:7,代码来源:SelectTimeoutCepOperator.java


注:本文中的org.apache.flink.cep.PatternSelectFunction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。