I am trying to create a CEP pattern that matches "at least" occurrence. Modifying the example code:
middle.oneOrMore().where(new IterativeCondition<SubEvent>() {
@Override
public boolean filter(SubEvent value, Context<SubEvent> ctx) throws Exception {
if (!value.getName().startsWith("foo")) {
return false;
}
double sum = value.getPrice();
for (Event event : ctx.getEventsForPattern("middle")) {
sum += event.getPrice();
}
return Double.compare(sum, 5.0) < 0;
}
});
into
middle.oneOrMore().where(new IterativeCondition<SubEvent>() {
@Override
public boolean filter(SubEvent value, Context<SubEvent> ctx) throws Exception {
if (!value.getName().startsWith("foo")) {
return false;
}
long count = 0;
for (Event event : ctx.getEventsForPattern("start")) {
count = count + 1;
}
return count >= MIN_COUNT;
}
});
does not solve my problem because the condition will keep failing and never be able to contribute to count.
I found in https://ci.apache.org/projects/flink/flink-docs-release-1.3/dev/libs/cep.html that there are
// expecting 4 occurrences
start.times(4);
// expecting 0 or 4 occurrences
start.times(4).optional();
// expecting 1 or more occurrences
start.oneOrMore();
// expecting 0 or more occurrences
start.oneOrMore().optional();
Is there anything like start.atLeast(5) exist?