Something wrong with the until condition FLINK-CEP

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Something wrong with the until condition FLINK-CEP

bupt_ljy

Hi all,

   I seem to find a problem of until condition in testGreedyUntilZeroOrMoreWithDummyEventsAfterQuantifier in GreedyITCase.java. I modify the unit test a little bit like this:


    @Test
public void testGreedyUntilZeroOrMoreWithDummyEventsAfterQuantifier() throws Exception {
List<StreamRecord<Event>> inputEvents = new ArrayList<>();

Event c = new Event(40, "c", 1.0);
Event a1 = new Event(41, "a", 2.0);
Event a2 = new Event(42, "d", 2.0);

inputEvents.add(new StreamRecord<>(c, 1));
inputEvents.add(new StreamRecord<>(a1, 2));
inputEvents.add(new StreamRecord<>(a2, 3));

// c a* d
Pattern<Event, ?> pattern = Pattern.<Event>begin("start").where(new SimpleCondition<Event>() {
private static final long serialVersionUID = 5726188262756267490L;

@Override
public boolean filter(Event value) throws Exception {
return value.getName().equals("c");
}
}).followedBy("middle").where(new SimpleCondition<Event>() {
private static final long serialVersionUID = 5726188262756267490L;

@Override
public boolean filter(Event value) throws Exception {
return value.getName().equals("a");
}
}).oneOrMore().greedy().until(new SimpleCondition<Event>() {
private static final long serialVersionUID = 5726188262756267490L;

@Override
public boolean filter(Event value) throws Exception {
return value.getPrice() > 3.0;
}
}).followedBy("end").where(new SimpleCondition<Event>() {
private static final long serialVersionUID = 5726188262756267490L;

@Override
public boolean filter(Event value) throws Exception {
return value.getName().equals("d");
}
});

NFA<Event> nfa = compile(pattern, false);

final List<List<Event>> resultingPatterns = feedNFA(inputEvents, nfa);

compareMaps(resultingPatterns, Lists.<List<Event>>newArrayList(
Lists.newArrayList(c, a1, a2)
));
}

I think this should fail because no events satisfies the until condition, but it works.
Flink version is 1.6.

Best,
Jiayi Liao
Reply | Threaded
Open this post in threaded view
|

Re: Something wrong with the until condition FLINK-CEP

bupt_ljy

Sorry, it seems that I misunderstood the concept of the composition of the until condition and oneOrMore.


 Original Message 
Sender: bupt_ljy<[hidden email]>
Recipient: user<[hidden email]>
Date: Tuesday, Dec 11, 2018 14:00
Subject: Something wrong with the until condition FLINK-CEP

Hi all,

   I seem to find a problem of until condition in testGreedyUntilZeroOrMoreWithDummyEventsAfterQuantifier in GreedyITCase.java. I modify the unit test a little bit like this:


    @Test
public void testGreedyUntilZeroOrMoreWithDummyEventsAfterQuantifier() throws Exception {
List<StreamRecord<Event>> inputEvents = new ArrayList<>();

Event c = new Event(40, "c", 1.0);
Event a1 = new Event(41, "a", 2.0);
Event a2 = new Event(42, "d", 2.0);

inputEvents.add(new StreamRecord<>(c, 1));
inputEvents.add(new StreamRecord<>(a1, 2));
inputEvents.add(new StreamRecord<>(a2, 3));

// c a* d
Pattern<Event, ?> pattern = Pattern.<Event>begin("start").where(new SimpleCondition<Event>() {
private static final long serialVersionUID = 5726188262756267490L;

@Override
public boolean filter(Event value) throws Exception {
return value.getName().equals("c");
}
}).followedBy("middle").where(new SimpleCondition<Event>() {
private static final long serialVersionUID = 5726188262756267490L;

@Override
public boolean filter(Event value) throws Exception {
return value.getName().equals("a");
}
}).oneOrMore().greedy().until(new SimpleCondition<Event>() {
private static final long serialVersionUID = 5726188262756267490L;

@Override
public boolean filter(Event value) throws Exception {
return value.getPrice() > 3.0;
}
}).followedBy("end").where(new SimpleCondition<Event>() {
private static final long serialVersionUID = 5726188262756267490L;

@Override
public boolean filter(Event value) throws Exception {
return value.getName().equals("d");
}
});

NFA<Event> nfa = compile(pattern, false);

final List<List<Event>> resultingPatterns = feedNFA(inputEvents, nfa);

compareMaps(resultingPatterns, Lists.<List<Event>>newArrayList(
Lists.newArrayList(c, a1, a2)
));
}

I think this should fail because no events satisfies the until condition, but it works.
Flink version is 1.6.

Best,
Jiayi Liao