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