Search in sources :

Example 6 with TimeConstant

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

Example 7 with TimeConstant

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

Example 8 with TimeConstant

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

the class PatternQueryTestCase method testPatternQuery11.

// from e1=Stream1[price >= 30] -> not Stream1[ price >= 20] for 1 sec -> e3=Stream2[ price >= e1.price]
// select e1.symbol, avg(e2.price ) as avgPrice
// group by e1.symbol
// having avgPrice>50;
// insert into OutputStream
@Test
public void testPatternQuery11() {
    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)))), new TimeConstant(1000)), State.stream(InputStream.stream("e3", "Stream2").filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.variable("price").ofStream("e1"))))))));
    query.select(Selector.selector().select("symbol", Expression.variable("symbol").ofStream("e1")).select("avgPrice", Expression.function("avg", Expression.variable("price").ofStream("e2"))).groupBy(Expression.variable("symbol").ofStream("e1")).having(Expression.compare(Expression.variable("avgPrice"), Compare.Operator.GREATER_THAN, Expression.value(50))));
    query.insertInto("OutputStream");
}
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 9 with TimeConstant

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

the class SiddhiQLBaseVisitorImpl method visitSecond_value.

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

Example 10 with TimeConstant

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

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

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