use of org.apache.flink.cep.nfa.aftermatch.SkipPastLastStrategy in project flink by apache.
the class AfterMatchSkipITCase method testSharedBufferIsProperlyCleared.
@Test
public void testSharedBufferIsProperlyCleared() throws Exception {
List<StreamRecord<Event>> inputEvents = new ArrayList<>();
for (int i = 0; i < 4; i++) {
inputEvents.add(new StreamRecord<>(new Event(1, "a", 1.0), i));
}
SkipPastLastStrategy matchSkipStrategy = AfterMatchSkipStrategy.skipPastLastEvent();
Pattern<Event, ?> pattern = Pattern.<Event>begin("start", matchSkipStrategy).where(new SimpleCondition<Event>() {
private static final long serialVersionUID = 5726188262756267490L;
@Override
public boolean filter(Event value) throws Exception {
return true;
}
}).times(2);
SharedBuffer<Event> sharedBuffer = TestSharedBuffer.createTestBuffer(Event.createTypeSerializer());
NFATestHarness nfaTestHarness = NFATestHarness.forPattern(pattern).withSharedBuffer(sharedBuffer).build();
nfaTestHarness.feedRecords(inputEvents);
assertThat(sharedBuffer.isEmpty(), Matchers.is(true));
}
Aggregations