Search in sources :

Example 16 with TimeConstant

use of org.wso2.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitTime_value.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public TimeConstant visitTime_value(@NotNull SiddhiQLParser.Time_valueContext ctx) {
    TimeConstant timeValueInMillis = Expression.Time.milliSec(0);
    if (ctx.millisecond_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.millisecond_value())).value());
    }
    if (ctx.second_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.second_value())).value());
    }
    if (ctx.minute_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.minute_value())).value());
    }
    if (ctx.hour_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.hour_value())).value());
    }
    if (ctx.day_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.day_value())).value());
    }
    if (ctx.week_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.week_value())).value());
    }
    if (ctx.month_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.month_value())).value());
    }
    if (ctx.year_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.year_value())).value());
    }
    populateQueryContext(timeValueInMillis, ctx);
    return timeValueInMillis;
}
Also used : TimeConstant(org.wso2.siddhi.query.api.expression.constant.TimeConstant)

Example 17 with TimeConstant

use of org.wso2.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitRight_absent_sequence_source.

@Override
public Object visitRight_absent_sequence_source(SiddhiQLParser.Right_absent_sequence_sourceContext ctx) {
    if (ctx.right_absent_sequence_source().size() == 1 && ctx.basic_absent_pattern_source() == null && ctx.sequence_source_chain() == null) {
        // '('right_absent_pattern_source')' within_time?
        StateElement stateElement = (StateElement) visit(ctx.right_absent_sequence_source(0));
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
        populateQueryContext(stateElement, ctx);
        return stateElement;
    } else {
        NextStateElement nextStateElement = new NextStateElement((StateElement) visit(ctx.getChild(0)), (StateElement) visit(ctx.getChild(2)));
        populateQueryContext(nextStateElement, ctx);
        return nextStateElement;
    }
}
Also used : NextStateElement(org.wso2.siddhi.query.api.execution.query.input.state.NextStateElement) EveryStateElement(org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement) StreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.StreamStateElement) NextStateElement(org.wso2.siddhi.query.api.execution.query.input.state.NextStateElement) StateElement(org.wso2.siddhi.query.api.execution.query.input.state.StateElement) CountStateElement(org.wso2.siddhi.query.api.execution.query.input.state.CountStateElement) AbsentStreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)

Example 18 with TimeConstant

use of org.wso2.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitAbsent_sequence_source_chain.

@Override
public Object visitAbsent_sequence_source_chain(SiddhiQLParser.Absent_sequence_source_chainContext ctx) {
    // absent_sequence_source_chain
    // : '('absent_sequence_source_chain')' within_time?
    // | basic_absent_pattern_source
    // | left_absent_sequence_source
    // | right_absent_sequence_source
    // ;
    StateElement stateElement;
    if (ctx.absent_sequence_source_chain() != null) {
        stateElement = (StateElement) visit(ctx.absent_sequence_source_chain());
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
    } else {
        stateElement = (StateElement) visit(ctx.getChild(0));
    }
    populateQueryContext(stateElement, ctx);
    return stateElement;
}
Also used : EveryStateElement(org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement) StreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.StreamStateElement) NextStateElement(org.wso2.siddhi.query.api.execution.query.input.state.NextStateElement) StateElement(org.wso2.siddhi.query.api.execution.query.input.state.StateElement) CountStateElement(org.wso2.siddhi.query.api.execution.query.input.state.CountStateElement) AbsentStreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)

Example 19 with TimeConstant

use of org.wso2.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.

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.wso2.siddhi.query.api.execution.query.Query) TimeConstant(org.wso2.siddhi.query.api.expression.constant.TimeConstant) Test(org.testng.annotations.Test)

Example 20 with TimeConstant

use of org.wso2.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitAbsent_pattern_source_chain.

@Override
public Object visitAbsent_pattern_source_chain(SiddhiQLParser.Absent_pattern_source_chainContext ctx) {
    if (ctx.absent_pattern_source_chain() != null) {
        StateElement stateElement = (StateElement) visit(ctx.absent_pattern_source_chain());
        if (ctx.EVERY() != null) {
            stateElement = new EveryStateElement(stateElement);
        }
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
        populateQueryContext(stateElement, ctx);
        return stateElement;
    } else {
        return visit(ctx.getChild(0));
    }
}
Also used : EveryStateElement(org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement) StreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.StreamStateElement) NextStateElement(org.wso2.siddhi.query.api.execution.query.input.state.NextStateElement) StateElement(org.wso2.siddhi.query.api.execution.query.input.state.StateElement) CountStateElement(org.wso2.siddhi.query.api.execution.query.input.state.CountStateElement) AbsentStreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) EveryStateElement(org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement)

Aggregations

TimeConstant (org.wso2.siddhi.query.api.expression.constant.TimeConstant)15 AbsentStreamStateElement (org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)12 StreamStateElement (org.wso2.siddhi.query.api.execution.query.input.state.StreamStateElement)12 CountStateElement (org.wso2.siddhi.query.api.execution.query.input.state.CountStateElement)11 EveryStateElement (org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement)11 NextStateElement (org.wso2.siddhi.query.api.execution.query.input.state.NextStateElement)11 StateElement (org.wso2.siddhi.query.api.execution.query.input.state.StateElement)11 Test (org.testng.annotations.Test)2 Query (org.wso2.siddhi.query.api.execution.query.Query)2 StateInputStream (org.wso2.siddhi.query.api.execution.query.input.stream.StateInputStream)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.wso2.siddhi.query.api.execution.partition.PartitionType)1 RangePartitionType (org.wso2.siddhi.query.api.execution.partition.RangePartitionType)1 ValuePartitionType (org.wso2.siddhi.query.api.execution.partition.ValuePartitionType)1 BasicSingleInputStream (org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream)1 EventOutputRate (org.wso2.siddhi.query.api.execution.query.output.ratelimit.EventOutputRate)1 OutputRate (org.wso2.siddhi.query.api.execution.query.output.ratelimit.OutputRate)1 SnapshotOutputRate (org.wso2.siddhi.query.api.execution.query.output.ratelimit.SnapshotOutputRate)1