use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitLogical_absent_stateful_source.
@Override
public Object visitLogical_absent_stateful_source(SiddhiQLParser.Logical_absent_stateful_sourceContext ctx) {
// ;
if (ctx.logical_absent_stateful_source() != null) {
return visit(ctx.logical_absent_stateful_source());
} else if (ctx.AND() != null) {
if (ctx.basic_absent_pattern_source().size() == 2) {
StateElement stateElement = State.logicalNotAnd((AbsentStreamStateElement) visit(ctx.basic_absent_pattern_source(0)), (AbsentStreamStateElement) visit(ctx.basic_absent_pattern_source(1)));
populateQueryContext(stateElement, ctx);
return stateElement;
} else {
StreamStateElement presentStreamState = (StreamStateElement) visit(ctx.standard_stateful_source());
AbsentStreamStateElement absentStreamState;
if (!ctx.basic_absent_pattern_source().isEmpty()) {
absentStreamState = (AbsentStreamStateElement) visit(ctx.basic_absent_pattern_source(0));
} else {
absentStreamState = State.logicalNot(new StreamStateElement((BasicSingleInputStream) visit(ctx.basic_source())));
}
StateElement stateElement = State.logicalNotAnd(absentStreamState, presentStreamState);
populateQueryContext(stateElement, ctx);
return stateElement;
}
} else if (ctx.OR() != null) {
if (ctx.basic_absent_pattern_source().size() == 2) {
return State.logicalOr((AbsentStreamStateElement) visit(ctx.basic_absent_pattern_source(0)), (AbsentStreamStateElement) visit(ctx.basic_absent_pattern_source(1)));
} else {
StreamStateElement streamStateElement1 = (StreamStateElement) visit(ctx.standard_stateful_source());
AbsentStreamStateElement streamStateElement2 = (AbsentStreamStateElement) visit(ctx.basic_absent_pattern_source(0));
StateElement stateElement = State.logicalOr(streamStateElement2, streamStateElement1);
populateQueryContext(stateElement, ctx);
return stateElement;
}
} else {
throw newSiddhiParserException(ctx);
}
}
use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitSequence_collection_stateful_source.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public CountStateElement visitSequence_collection_stateful_source(@NotNull SiddhiQLParser.Sequence_collection_stateful_sourceContext ctx) {
// sequence_collection_stateful_source
// :standard_stateful_source ('<' collect '>'|zero_or_more='*'|zero_or_one='?'|one_or_more='+')
// ;
StreamStateElement streamStateElement = (StreamStateElement) visit(ctx.standard_stateful_source());
if (ctx.one_or_more != null) {
CountStateElement countStateElement = new CountStateElement(streamStateElement, 1, CountStateElement.ANY);
populateQueryContext(countStateElement, ctx);
return countStateElement;
} else if (ctx.zero_or_more != null) {
CountStateElement countStateElement = new CountStateElement(streamStateElement, 0, CountStateElement.ANY);
populateQueryContext(countStateElement, ctx);
return countStateElement;
} else if (ctx.zero_or_one != null) {
CountStateElement countStateElement = new CountStateElement(streamStateElement, 0, 1);
populateQueryContext(countStateElement, ctx);
return countStateElement;
} else if (ctx.collect() != null) {
Object[] minMax = (Object[]) visit(ctx.collect());
int min = CountStateElement.ANY;
int max = CountStateElement.ANY;
if (minMax[0] != null) {
min = (Integer) minMax[0];
}
if (minMax[1] != null) {
max = (Integer) minMax[1];
}
CountStateElement countStateElement = new CountStateElement(streamStateElement, min, max);
populateQueryContext(countStateElement, ctx);
return countStateElement;
} else {
throw newSiddhiParserException(ctx);
}
}
use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitStandard_stateful_source.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public StreamStateElement visitStandard_stateful_source(@NotNull SiddhiQLParser.Standard_stateful_sourceContext ctx) {
if (ctx.event() != null) {
activeStreams.add(visitEvent(ctx.event()));
}
BasicSingleInputStream basicSingleInputStream = (BasicSingleInputStream) visit(ctx.basic_source());
if (ctx.event() != null) {
if (basicSingleInputStream.isInnerStream()) {
activeStreams.remove("#" + basicSingleInputStream.getStreamId());
} else {
activeStreams.remove(basicSingleInputStream.getStreamId());
}
StreamStateElement streamStateElement = new StreamStateElement(basicSingleInputStream.as((String) visit(ctx.event())));
populateQueryContext(streamStateElement, ctx);
return streamStateElement;
} else {
StreamStateElement streamStateElement = new StreamStateElement(basicSingleInputStream);
populateQueryContext(streamStateElement, ctx);
return streamStateElement;
}
}
use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitPattern_collection_stateful_source.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public CountStateElement visitPattern_collection_stateful_source(@NotNull SiddhiQLParser.Pattern_collection_stateful_sourceContext ctx) {
StreamStateElement streamStateElement = (StreamStateElement) visit(ctx.standard_stateful_source());
if (ctx.collect() != null) {
Object[] minMax = (Object[]) visit(ctx.collect());
int min = CountStateElement.ANY;
int max = CountStateElement.ANY;
if (minMax[0] != null) {
min = (Integer) minMax[0];
}
if (minMax[1] != null) {
max = (Integer) minMax[1];
}
CountStateElement stateElement = new CountStateElement(streamStateElement, min, max);
populateQueryContext(stateElement, ctx);
return stateElement;
} else {
throw newSiddhiParserException(ctx);
}
}
use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitLogical_stateful_source.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Object visitLogical_stateful_source(@NotNull SiddhiQLParser.Logical_stateful_sourceContext ctx) {
if (ctx.AND() != null) {
StreamStateElement streamStateElement1 = (StreamStateElement) visit(ctx.standard_stateful_source(0));
StreamStateElement streamStateElement2 = (StreamStateElement) visit(ctx.standard_stateful_source(1));
StateElement stateElement = State.logicalAnd(streamStateElement1, streamStateElement2);
populateQueryContext(stateElement, ctx);
return stateElement;
} else if (ctx.OR() != null) {
StreamStateElement streamStateElement1 = (StreamStateElement) visit(ctx.standard_stateful_source(0));
StreamStateElement streamStateElement2 = (StreamStateElement) visit(ctx.standard_stateful_source(1));
StateElement stateElement = State.logicalOr(streamStateElement1, streamStateElement2);
populateQueryContext(stateElement, ctx);
return stateElement;
} else {
throw newSiddhiParserException(ctx);
}
}
Aggregations