use of io.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitYear_value.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public TimeConstant visitYear_value(@NotNull SiddhiQLParser.Year_valueContext ctx) {
TimeConstant timeConstant = Expression.Time.year(Long.parseLong(ctx.INT_LITERAL().getText().replaceFirst("[lL]", "")));
populateQueryContext(timeConstant, ctx);
return timeConstant;
}
use of io.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.
the class SiddhiCompiler method parseTimeConstantDefinition.
public static TimeConstant parseTimeConstantDefinition(String timeConstantDefinition) throws SiddhiParserException {
CharStream input = CharStreams.fromString(timeConstantDefinition);
SiddhiQLLexer lexer = new SiddhiQLLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(SiddhiErrorListener.INSTANCE);
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLParser parser = new SiddhiQLParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(SiddhiErrorListener.INSTANCE);
ParseTree tree = parser.time_value();
SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
return (TimeConstant) eval.visit(tree);
}
use of io.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.
the class SimpleQueryTestCase method testQuery10.
@Test
public void testQuery10() {
TimeConstant timeConstant = new TimeConstant(1000);
Query query = Query.query();
query.from(InputStream.patternStream(State.next(State.stream(InputStream.stream("e1", "Stream1").filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(30)))), State.next(State.logicalNot(State.stream(InputStream.stream("Stream1").filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(20)))), timeConstant.week(1)), State.stream(InputStream.stream("e3", "Stream2").filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.variable("price").ofStream("e1"))))))));
}
Aggregations