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;
}
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);
}
}
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;
}
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;
}
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);
}
Aggregations