Search in sources :

Example 16 with TimeConstant

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;
}
Also used : TimeConstant(io.siddhi.query.api.expression.constant.TimeConstant)

Example 17 with 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);
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) SiddhiQLBaseVisitorImpl(io.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl) CharStream(org.antlr.v4.runtime.CharStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree) TimeConstant(io.siddhi.query.api.expression.constant.TimeConstant)

Example 18 with TimeConstant

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"))))))));
}
Also used : Query(io.siddhi.query.api.execution.query.Query) TimeConstant(io.siddhi.query.api.expression.constant.TimeConstant) Test(org.testng.annotations.Test)

Aggregations

TimeConstant (io.siddhi.query.api.expression.constant.TimeConstant)18 Query (io.siddhi.query.api.execution.query.Query)4 Test (org.testng.annotations.Test)4 AbsentStreamStateElement (io.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)2 CountStateElement (io.siddhi.query.api.execution.query.input.state.CountStateElement)2 EveryStateElement (io.siddhi.query.api.execution.query.input.state.EveryStateElement)2 NextStateElement (io.siddhi.query.api.execution.query.input.state.NextStateElement)2 StateElement (io.siddhi.query.api.execution.query.input.state.StateElement)2 StreamStateElement (io.siddhi.query.api.execution.query.input.state.StreamStateElement)2 StateInputStream (io.siddhi.query.api.execution.query.input.stream.StateInputStream)2 PartitionType (io.siddhi.query.api.execution.partition.PartitionType)1 RangePartitionType (io.siddhi.query.api.execution.partition.RangePartitionType)1 ValuePartitionType (io.siddhi.query.api.execution.partition.ValuePartitionType)1 EventOutputRate (io.siddhi.query.api.execution.query.output.ratelimit.EventOutputRate)1 OutputRate (io.siddhi.query.api.execution.query.output.ratelimit.OutputRate)1 SnapshotOutputRate (io.siddhi.query.api.execution.query.output.ratelimit.SnapshotOutputRate)1 TimeOutputRate (io.siddhi.query.api.execution.query.output.ratelimit.TimeOutputRate)1 BoolConstant (io.siddhi.query.api.expression.constant.BoolConstant)1 Constant (io.siddhi.query.api.expression.constant.Constant)1 DoubleConstant (io.siddhi.query.api.expression.constant.DoubleConstant)1