Java Code Examples for org.apache.flink.cep.pattern.Pattern#begin()

The following examples show how to use org.apache.flink.cep.pattern.Pattern#begin() . 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: FlinkCepPatternLanguageListener.java    From flink-cep-dsl with Apache License 2.0 5 votes vote down vote up
@Override
public void enterClassIdentifier(PatternLanguageParser.ClassIdentifierContext ctx) {
    if (pattern == null) {
        pattern = Pattern.begin(ctx.getText(), afterMatchSkipStrategy);
    }
    else {
        pattern = patternCombiner.apply(pattern,ctx.getText());
    }
    outerContextMatcher.add(eventTypeMatcherFor(ctx.getText()));
}
 
Example 2
Source File: LongRidesCEPExercise.java    From flink-training-exercises with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

		ParameterTool params = ParameterTool.fromArgs(args);
		final String input = params.get("input", ExerciseBase.pathToRideData);

		final int servingSpeedFactor = 600; // events of 10 minutes are served in 1 second

		StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
		env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
		env.setParallelism(ExerciseBase.parallelism);

		// CheckpointedTaxiRideSource delivers events in order
		DataStream<TaxiRide> rides = env.addSource(rideSourceOrTest(new CheckpointedTaxiRideSource(input, servingSpeedFactor)));

		DataStream<TaxiRide> keyedRides = rides
			.keyBy("rideId");

		// A complete taxi ride has a START event followed by an END event
		// This pattern is incomplete ...
		Pattern<TaxiRide, TaxiRide> completedRides = Pattern.<TaxiRide>begin("start");

		// We want to find rides that have NOT been completed within 120 minutes.
		// This pattern matches rides that ARE completed.
		// Below we will ignore rides that match this pattern, and emit those that timeout.
		PatternStream<TaxiRide> patternStream = CEP.pattern(keyedRides, completedRides.within(Time.minutes(120)));

		OutputTag<TaxiRide> timedout = new OutputTag<TaxiRide>("timedout"){};

		SingleOutputStreamOperator<TaxiRide> longRides = patternStream.flatSelect(
				timedout,
				new TaxiRideTimedOut<TaxiRide>(),
				new FlatSelectNothing<TaxiRide>()
		);

		printOrTest(longRides.getSideOutput(timedout));

		throw new MissingSolutionException();

//		env.execute("Long Taxi Rides (CEP)");
	}
 
Example 3
Source File: CepProcessFunctionContextTest.java    From Flink-CEPplus with Apache License 2.0 3 votes vote down vote up
@Override
public NFA<Event> createNFA() {

	Pattern<Event, ?> pattern = Pattern.begin("1");

	return NFACompiler.compileFactory(pattern, false).createNFA();
}
 
Example 4
Source File: CepProcessFunctionContextTest.java    From flink with Apache License 2.0 3 votes vote down vote up
@Override
public NFA<Event> createNFA() {

	Pattern<Event, ?> pattern = Pattern.begin("1");

	return NFACompiler.compileFactory(pattern, false).createNFA();
}
 
Example 5
Source File: CepProcessFunctionContextTest.java    From flink with Apache License 2.0 3 votes vote down vote up
@Override
public NFA<Event> createNFA() {

	Pattern<Event, ?> pattern = Pattern.begin("1");

	return NFACompiler.compileFactory(pattern, false).createNFA();
}