use of io.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitPattern_stream.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Object visitPattern_stream(@NotNull SiddhiQLParser.Pattern_streamContext ctx) {
// pattern_stream
// : every_pattern_source_chain within_time?
// | every_absent_pattern_source_chain within_time?
// ;
StateElement stateElement;
if (ctx.every_pattern_source_chain() != null) {
stateElement = ((StateElement) visit(ctx.every_pattern_source_chain()));
} else {
stateElement = ((StateElement) visit(ctx.absent_pattern_source_chain()));
}
TimeConstant within = null;
if (ctx.within_time() != null) {
within = (TimeConstant) visit(ctx.within_time());
}
StateInputStream stateInputStream = new StateInputStream(StateInputStream.Type.PATTERN, stateElement, within);
populateQueryContext(stateInputStream, ctx);
return stateInputStream;
}
use of io.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.
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 io.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;
}
use of io.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.
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 io.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;
}
Aggregations