use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitAggregation_time_range.
@Override
public TimePeriod visitAggregation_time_range(@NotNull SiddhiQLParser.Aggregation_time_rangeContext ctx) {
// read left and right contexts
SiddhiQLParser.Aggregation_time_durationContext left = ctx.aggregation_time_duration().get(0);
SiddhiQLParser.Aggregation_time_durationContext right = ctx.aggregation_time_duration().get(1);
// Visit left and right expression using above contexts and create a new
// RangeTimeSpecifier object
TimePeriod.Duration leftTimeDuration = visitAggregation_time_duration(left);
TimePeriod.Duration rightTimeDuration = visitAggregation_time_duration(right);
TimePeriod timePeriod = TimePeriod.range(leftTimeDuration, rightTimeDuration);
populateQueryContext(timePeriod, ctx);
return timePeriod;
}
use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitAddition_math_operation.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Expression visitAddition_math_operation(@NotNull SiddhiQLParser.Addition_math_operationContext ctx) {
Expression expression;
if (ctx.add != null) {
expression = Expression.add((Expression) visit(ctx.math_operation(0)), (Expression) visit(ctx.math_operation(1)));
} else if (ctx.substract != null) {
expression = Expression.subtract((Expression) visit(ctx.math_operation(0)), (Expression) visit(ctx.math_operation(1)));
} else {
throw newSiddhiParserException(ctx);
}
populateQueryContext(expression, ctx);
return expression;
}
use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitOr_math_operation.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Object visitOr_math_operation(@NotNull SiddhiQLParser.Or_math_operationContext ctx) {
if (ctx.OR() != null) {
Expression expression = Expression.or((Expression) visit(ctx.math_operation(0)), (Expression) visit(ctx.math_operation(1)));
populateQueryContext(expression, ctx);
return expression;
} else {
throw newSiddhiParserException(ctx);
}
}
use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitPartition_with_stream.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public PartitionType visitPartition_with_stream(@NotNull SiddhiQLParser.Partition_with_streamContext ctx) {
String streamId = (String) visit(ctx.stream_id());
activeStreams.add(streamId);
try {
if (ctx.condition_ranges() != null) {
PartitionType partitionType = new RangePartitionType(streamId, (RangePartitionType.RangePartitionProperty[]) visit(ctx.condition_ranges()));
populateQueryContext(partitionType, ctx);
return partitionType;
} else if (ctx.attribute() != null) {
PartitionType partitionType = new ValuePartitionType(streamId, (Expression) visit(ctx.attribute()));
populateQueryContext(partitionType, ctx);
return partitionType;
} else {
throw newSiddhiParserException(ctx);
}
} finally {
activeStreams.clear();
}
}
use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitJoin_stream.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Object visitJoin_stream(@NotNull SiddhiQLParser.Join_streamContext ctx) {
// join_stream
// :left_source=join_source join right_source=join_source right_unidirectional=UNIDIRECTIONAL (ON expression)?
// within_time?
// |left_source=join_source join right_source=join_source (ON expression)? within_time?
// |left_source=join_source left_unidirectional=UNIDIRECTIONAL join right_source=join_source (ON expression)?
// within_time?
// ;
SingleInputStream leftStream = (SingleInputStream) visit(ctx.left_source);
SingleInputStream rightStream = (SingleInputStream) visit(ctx.right_source);
JoinInputStream.Type joinType = (JoinInputStream.Type) visit(ctx.join());
JoinInputStream.EventTrigger eventTrigger = null;
Expression onCondition = null;
Within within = null;
Expression per = null;
if (ctx.within_time_range() != null) {
within = (Within) visit(ctx.within_time_range());
}
if (ctx.per() != null) {
per = (Expression) visit(ctx.per());
}
if (ctx.expression() != null) {
onCondition = (Expression) visit(ctx.expression());
}
if (ctx.right_unidirectional != null) {
eventTrigger = JoinInputStream.EventTrigger.RIGHT;
} else if (ctx.left_unidirectional != null) {
eventTrigger = JoinInputStream.EventTrigger.LEFT;
} else {
eventTrigger = JoinInputStream.EventTrigger.ALL;
}
InputStream inputStream = InputStream.joinStream(leftStream, joinType, rightStream, onCondition, eventTrigger, within, per);
populateQueryContext(inputStream, ctx);
return inputStream;
}
Aggregations