Search in sources :

Example 1 with TimeConstant

use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.

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(org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant)

Example 2 with TimeConstant

use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitOutput_rate.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public OutputRate visitOutput_rate(@NotNull SiddhiQLParser.Output_rateContext ctx) {
    if (ctx.SNAPSHOT() != null) {
        SnapshotOutputRate snapshotOutputRate = new SnapshotOutputRate(((TimeConstant) visit(ctx.time_value())).value());
        populateQueryContext(snapshotOutputRate, ctx);
        return snapshotOutputRate;
    } else if (ctx.time_value() != null) {
        TimeOutputRate timeOutputRate = new TimeOutputRate(((TimeConstant) visit(ctx.time_value())).value());
        if (ctx.output_rate_type() != null) {
            timeOutputRate.output((OutputRate.Type) visit(ctx.output_rate_type()));
        }
        populateQueryContext(timeOutputRate, ctx);
        return timeOutputRate;
    } else if (ctx.EVENTS() != null) {
        EventOutputRate eventOutputRate = new EventOutputRate(Integer.parseInt(ctx.INT_LITERAL().getText()));
        if (ctx.output_rate_type() != null) {
            eventOutputRate.output((OutputRate.Type) visit(ctx.output_rate_type()));
        }
        populateQueryContext(eventOutputRate, ctx);
        return eventOutputRate;
    } else {
        throw newSiddhiParserException(ctx);
    }
}
Also used : SnapshotOutputRate(org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.SnapshotOutputRate) RangePartitionType(org.ballerinalang.siddhi.query.api.execution.partition.RangePartitionType) ValuePartitionType(org.ballerinalang.siddhi.query.api.execution.partition.ValuePartitionType) PartitionType(org.ballerinalang.siddhi.query.api.execution.partition.PartitionType) EventOutputRate(org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.EventOutputRate) SnapshotOutputRate(org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.SnapshotOutputRate) TimeOutputRate(org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.TimeOutputRate) OutputRate(org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.OutputRate) EventOutputRate(org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.EventOutputRate) TimeOutputRate(org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.TimeOutputRate) TimeConstant(org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant)

Example 3 with TimeConstant

use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitWeek_value.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public TimeConstant visitWeek_value(@NotNull SiddhiQLParser.Week_valueContext ctx) {
    TimeConstant timeConstant = Expression.Time.week(Long.parseLong(ctx.INT_LITERAL().getText().replaceFirst("[lL]", "")));
    populateQueryContext(timeConstant, ctx);
    return timeConstant;
}
Also used : TimeConstant(org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant)

Example 4 with TimeConstant

use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitMinute_value.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public TimeConstant visitMinute_value(@NotNull SiddhiQLParser.Minute_valueContext ctx) {
    TimeConstant timeConstant = Expression.Time.minute(Long.parseLong(ctx.INT_LITERAL().getText().replaceFirst("[lL]", "")));
    populateQueryContext(timeConstant, ctx);
    return timeConstant;
}
Also used : TimeConstant(org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant)

Example 5 with TimeConstant

use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.

the class AbsentPatternTestCase method test4.

@Test
public void test4() throws SiddhiParserException {
    Query query = SiddhiCompiler.parseQuery("from e1=Stream1[price>20] -> not Stream2[price>e1.price] for 2 sec " + "select e1.symbol as symbol1 " + "insert into OutputStream ;");
    AssertJUnit.assertNotNull(query);
    Query api = Query.query();
    api.from(InputStream.patternStream(State.next(State.stream(InputStream.stream("e1", "Stream1").filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN, Expression.value(20)))), State.logicalNot(State.stream(InputStream.stream("Stream2").filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN, Expression.variable("price").ofStream("e1"))))).waitingTime(new TimeConstant(2000))))).select(Selector.selector().select("symbol1", Expression.variable("symbol").ofStream("e1"))).insertInto("OutputStream");
    AssertJUnit.assertEquals(api, query);
}
Also used : Query(org.ballerinalang.siddhi.query.api.execution.query.Query) TimeConstant(org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant) Test(org.testng.annotations.Test)

Aggregations

TimeConstant (org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant)15 Query (org.ballerinalang.siddhi.query.api.execution.query.Query)2 Test (org.testng.annotations.Test)2 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)1 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)1 ParseTree (org.antlr.v4.runtime.tree.ParseTree)1 PartitionType (org.ballerinalang.siddhi.query.api.execution.partition.PartitionType)1 RangePartitionType (org.ballerinalang.siddhi.query.api.execution.partition.RangePartitionType)1 ValuePartitionType (org.ballerinalang.siddhi.query.api.execution.partition.ValuePartitionType)1 AbsentStreamStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)1 CountStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement)1 EveryStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement)1 NextStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement)1 StateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement)1 StreamStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement)1 EventOutputRate (org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.EventOutputRate)1 OutputRate (org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.OutputRate)1 SnapshotOutputRate (org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.SnapshotOutputRate)1 TimeOutputRate (org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.TimeOutputRate)1 BoolConstant (org.ballerinalang.siddhi.query.api.expression.constant.BoolConstant)1