org.apache.flink.cep.operator.CepOperator Java Examples

The following examples show how to use org.apache.flink.cep.operator.CepOperator. 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: CepOperatorBuilder.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public <K> CepOperator<Event, K, OUT> build() {
	return new CepOperator<>(Event.createTypeSerializer(),
		isProcessingTime,
		nfaFactory,
		comparator,
		skipStrategy,
		function,
		lateDataOutputTag);
}
 
Example #2
Source File: CepOperatorBuilder.java    From flink with Apache License 2.0 5 votes vote down vote up
public <K> CepOperator<Event, K, OUT> build() {
	return new CepOperator<>(Event.createTypeSerializer(),
		isProcessingTime,
		nfaFactory,
		comparator,
		skipStrategy,
		function,
		lateDataOutputTag);
}
 
Example #3
Source File: CepOperatorBuilder.java    From flink with Apache License 2.0 5 votes vote down vote up
public <K> CepOperator<Event, K, OUT> build() {
	return new CepOperator<>(Event.createTypeSerializer(),
		isProcessingTime,
		nfaFactory,
		comparator,
		skipStrategy,
		function,
		lateDataOutputTag);
}
 
Example #4
Source File: PatternStreamBuilder.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a data stream containing results of {@link PatternProcessFunction} to fully matching event patterns.
 *
 * @param processFunction function to be applied to matching event sequences
 * @param outTypeInfo output TypeInformation of
 *        {@link PatternProcessFunction#processMatch(Map, PatternProcessFunction.Context, Collector)}
 * @param <OUT> type of output events
 * @return Data stream containing fully matched event sequence with applied {@link PatternProcessFunction}
 */
<OUT, K> SingleOutputStreamOperator<OUT> build(
		final TypeInformation<OUT> outTypeInfo,
		final PatternProcessFunction<IN, OUT> processFunction) {

	checkNotNull(outTypeInfo);
	checkNotNull(processFunction);

	final TypeSerializer<IN> inputSerializer = inputStream.getType().createSerializer(inputStream.getExecutionConfig());
	final boolean isProcessingTime = inputStream.getExecutionEnvironment().getStreamTimeCharacteristic() == TimeCharacteristic.ProcessingTime;

	final boolean timeoutHandling = processFunction instanceof TimedOutPartialMatchHandler;
	final NFACompiler.NFAFactory<IN> nfaFactory = NFACompiler.compileFactory(pattern, timeoutHandling);

	final CepOperator<IN, K, OUT> operator = new CepOperator<>(
		inputSerializer,
		isProcessingTime,
		nfaFactory,
		comparator,
		pattern.getAfterMatchSkipStrategy(),
		processFunction,
		lateDataOutputTag);

	final SingleOutputStreamOperator<OUT> patternStream;
	if (inputStream instanceof KeyedStream) {
		KeyedStream<IN, K> keyedStream = (KeyedStream<IN, K>) inputStream;

		patternStream = keyedStream.transform(
			"CepOperator",
			outTypeInfo,
			operator);
	} else {
		KeySelector<IN, Byte> keySelector = new NullByteKeySelector<>();

		patternStream = inputStream.keyBy(keySelector).transform(
			"GlobalCepOperator",
			outTypeInfo,
			operator
		).forceNonParallel();
	}

	return patternStream;
}
 
Example #5
Source File: PatternStreamBuilder.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a data stream containing results of {@link PatternProcessFunction} to fully matching event patterns.
 *
 * @param processFunction function to be applied to matching event sequences
 * @param outTypeInfo output TypeInformation of
 *        {@link PatternProcessFunction#processMatch(Map, PatternProcessFunction.Context, Collector)}
 * @param <OUT> type of output events
 * @return Data stream containing fully matched event sequence with applied {@link PatternProcessFunction}
 */
<OUT, K> SingleOutputStreamOperator<OUT> build(
		final TypeInformation<OUT> outTypeInfo,
		final PatternProcessFunction<IN, OUT> processFunction) {

	checkNotNull(outTypeInfo);
	checkNotNull(processFunction);

	final TypeSerializer<IN> inputSerializer = inputStream.getType().createSerializer(inputStream.getExecutionConfig());
	final boolean isProcessingTime = inputStream.getExecutionEnvironment().getStreamTimeCharacteristic() == TimeCharacteristic.ProcessingTime;

	final boolean timeoutHandling = processFunction instanceof TimedOutPartialMatchHandler;
	final NFACompiler.NFAFactory<IN> nfaFactory = NFACompiler.compileFactory(pattern, timeoutHandling);

	final CepOperator<IN, K, OUT> operator = new CepOperator<>(
		inputSerializer,
		isProcessingTime,
		nfaFactory,
		comparator,
		pattern.getAfterMatchSkipStrategy(),
		processFunction,
		lateDataOutputTag);

	final SingleOutputStreamOperator<OUT> patternStream;
	if (inputStream instanceof KeyedStream) {
		KeyedStream<IN, K> keyedStream = (KeyedStream<IN, K>) inputStream;

		patternStream = keyedStream.transform(
			"CepOperator",
			outTypeInfo,
			operator);
	} else {
		KeySelector<IN, Byte> keySelector = new NullByteKeySelector<>();

		patternStream = inputStream.keyBy(keySelector).transform(
			"GlobalCepOperator",
			outTypeInfo,
			operator
		).forceNonParallel();
	}

	return patternStream;
}
 
Example #6
Source File: PatternStreamBuilder.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a data stream containing results of {@link PatternProcessFunction} to fully matching event patterns.
 *
 * @param processFunction function to be applied to matching event sequences
 * @param outTypeInfo output TypeInformation of
 *        {@link PatternProcessFunction#processMatch(Map, PatternProcessFunction.Context, Collector)}
 * @param <OUT> type of output events
 * @return Data stream containing fully matched event sequence with applied {@link PatternProcessFunction}
 */
<OUT, K> SingleOutputStreamOperator<OUT> build(
		final TypeInformation<OUT> outTypeInfo,
		final PatternProcessFunction<IN, OUT> processFunction) {

	checkNotNull(outTypeInfo);
	checkNotNull(processFunction);

	final TypeSerializer<IN> inputSerializer = inputStream.getType().createSerializer(inputStream.getExecutionConfig());
	final boolean isProcessingTime = inputStream.getExecutionEnvironment().getStreamTimeCharacteristic() == TimeCharacteristic.ProcessingTime;

	final boolean timeoutHandling = processFunction instanceof TimedOutPartialMatchHandler;
	final NFACompiler.NFAFactory<IN> nfaFactory = NFACompiler.compileFactory(pattern, timeoutHandling);

	final CepOperator<IN, K, OUT> operator = new CepOperator<>(
		inputSerializer,
		isProcessingTime,
		nfaFactory,
		comparator,
		pattern.getAfterMatchSkipStrategy(),
		processFunction,
		lateDataOutputTag);

	final SingleOutputStreamOperator<OUT> patternStream;
	if (inputStream instanceof KeyedStream) {
		KeyedStream<IN, K> keyedStream = (KeyedStream<IN, K>) inputStream;

		patternStream = keyedStream.transform(
			"CepOperator",
			outTypeInfo,
			operator);
	} else {
		KeySelector<IN, Byte> keySelector = new NullByteKeySelector<>();

		patternStream = inputStream.keyBy(keySelector).transform(
			"GlobalCepOperator",
			outTypeInfo,
			operator
		).forceNonParallel();
	}

	return patternStream;
}