I'm trying to apply AfterMatchSkipStrategy skipPastLastEvent()
into my pattern. But the problem is that i'm getting the same results as of the case when I don't apply the skipstrategy (NoSkip)
.
Discards every partial match that started after the match started but before it ended is the description for the skip strategy SKIP_PAST_LAST_EVENT
. And as far as i understood all the partial matches would be discarded as soon as a pattern is matched.
AfterMatchSkipStrategy skipStrategy = AfterMatchSkipStrategy.skipPastLastEvent();
Pattern<GraphMap, ? > pattern2 = Pattern.<GraphMap>begin("start", skipStrategy).where(new IterativeCondition<GraphMap>() {
@Override
public boolean filter(GraphMap graphMap, Context<GraphMap> context) throws Exception {
if (graphMap.getSubjectValue().equals("basketballplayer1"))
return graphMap.getObjectValueString().equals("Miss");
return false;
}
}).followedBy("middle").where(new IterativeCondition<GraphMap>() {
@Override
public boolean filter(GraphMap graphMap, Context<GraphMap> context) throws Exception {
for( GraphMap previousGraphMap : context.getEventsForPattern("start")){
if (graphMap.getSubjectValue().equals(previousGraphMap.getSubjectValue())){
return graphMap.getObjectValueString().equals("Basket");
}
}
return false;
}
}).oneOrMore().followedBy("end").where(new IterativeCondition<GraphMap>() {
@Override
public boolean filter(GraphMap graphMap, Context<GraphMap> context) throws Exception {
for ( GraphMap previousGraphMap : context.getEventsForPattern("middle")){
if( graphMap.getSubjectValue().equals(previousGraphMap.getSubjectValue())){
return graphMap.getObjectValueString().equals("Miss");
}
}
return false;
}
}).within(Time.seconds(10))
The Above is my Pattern sequence. In this case the output i require are sequence of (Miss Basket+ Miss) by a basketball player1. But when i have input like
Miss, Miss, Basket, Basket, Miss
I'm getting all the Matches like:
[Miss, Basket, Basket, Miss] ,
[Miss, Basket, Miss]
[Miss, Basket, Miss] {of the second miss in the sequence} etc.
Is there something i'm doing Wrong? The output i wanted was only [Miss, Basket, Basket, Miss]
and not all the other patterns as in NoSkip would give me.
Thanks in advance for any replies. It would be a huge help.