Search in sources :

Example 1 with TimeConstant

use of io.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")))), new TimeConstant(2000))))).select(Selector.selector().select("symbol1", Expression.variable("symbol").ofStream("e1"))).insertInto("OutputStream");
    AssertJUnit.assertEquals(api, query);
}
Also used : Query(io.siddhi.query.api.execution.query.Query) TimeConstant(io.siddhi.query.api.expression.constant.TimeConstant) Test(org.testng.annotations.Test)

Example 2 with TimeConstant

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

the class SiddhiQLBaseVisitorImpl method visitMonth_value.

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

Example 3 with TimeConstant

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

the class SiddhiQLBaseVisitorImpl method visitDay_value.

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

Example 4 with TimeConstant

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

the class SiddhiQLBaseVisitorImpl method visitMillisecond_value.

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

Example 5 with TimeConstant

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

the class SiddhiQLBaseVisitorImpl method visitSequence_stream.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public StateInputStream visitSequence_stream(@NotNull SiddhiQLParser.Sequence_streamContext ctx) {
    // sequence_stream
    // :every_sequence_source_chain within_time?
    // |every_absent_sequence_source_chain within_time?
    // ;
    StateInputStream stateInputStream;
    TimeConstant within = null;
    if (ctx.within_time() != null) {
        within = (TimeConstant) visit(ctx.within_time());
    }
    if (ctx.every_sequence_source_chain() != null) {
        stateInputStream = new StateInputStream(StateInputStream.Type.SEQUENCE, (StateElement) visitEvery_sequence_source_chain(ctx.every_sequence_source_chain()), within);
    } else {
        stateInputStream = new StateInputStream(StateInputStream.Type.SEQUENCE, (StateElement) visitEvery_absent_sequence_source_chain(ctx.every_absent_sequence_source_chain()), within);
    }
    populateQueryContext(stateInputStream, ctx);
    return stateInputStream;
}
Also used : EveryStateElement(io.siddhi.query.api.execution.query.input.state.EveryStateElement) StreamStateElement(io.siddhi.query.api.execution.query.input.state.StreamStateElement) NextStateElement(io.siddhi.query.api.execution.query.input.state.NextStateElement) AbsentStreamStateElement(io.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) StateElement(io.siddhi.query.api.execution.query.input.state.StateElement) CountStateElement(io.siddhi.query.api.execution.query.input.state.CountStateElement) StateInputStream(io.siddhi.query.api.execution.query.input.stream.StateInputStream) TimeConstant(io.siddhi.query.api.expression.constant.TimeConstant)

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