use of org.ballerinalang.siddhi.query.api.expression.Expression in project ballerina by ballerina-lang.
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;
}
use of org.ballerinalang.siddhi.query.api.expression.Expression in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitStore_input.
@Override
public Object visitStore_input(SiddhiQLParser.Store_inputContext ctx) {
String sourceId = (String) visit(ctx.source_id());
String alias = null;
if (ctx.alias() != null) {
alias = (String) visit(ctx.source_id());
}
Store store = InputStore.store(alias, sourceId);
Expression expression = null;
if (ctx.expression() != null) {
expression = (Expression) visit(ctx.expression());
}
populateQueryContext(store, ctx);
if (ctx.per() != null) {
return store.on(expression, (Within) visit(ctx.within_time_range()), (Expression) visit(ctx.per()));
} else if (expression != null) {
return store.on(expression);
} else {
return store;
}
}
use of org.ballerinalang.siddhi.query.api.expression.Expression in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitGreaterthan_lessthan_math_operation.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Expression visitGreaterthan_lessthan_math_operation(@NotNull SiddhiQLParser.Greaterthan_lessthan_math_operationContext ctx) {
Expression expression;
if (ctx.gt != null) {
expression = Expression.compare((Expression) visit(ctx.math_operation(0)), Compare.Operator.GREATER_THAN, (Expression) visit(ctx.math_operation(1)));
} else if (ctx.lt != null) {
expression = Expression.compare((Expression) visit(ctx.math_operation(0)), Compare.Operator.LESS_THAN, (Expression) visit(ctx.math_operation(1)));
} else if (ctx.gt_eq != null) {
expression = Expression.compare((Expression) visit(ctx.math_operation(0)), Compare.Operator.GREATER_THAN_EQUAL, (Expression) visit(ctx.math_operation(1)));
} else if (ctx.lt_eq != null) {
expression = Expression.compare((Expression) visit(ctx.math_operation(0)), Compare.Operator.LESS_THAN_EQUAL, (Expression) visit(ctx.math_operation(1)));
} else {
throw newSiddhiParserException(ctx);
}
populateQueryContext(expression, ctx);
return expression;
}
use of org.ballerinalang.siddhi.query.api.expression.Expression in project ballerina by ballerina-lang.
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.ballerinalang.siddhi.query.api.expression.Expression in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitNull_check.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Object visitNull_check(@NotNull SiddhiQLParser.Null_checkContext ctx) {
Expression expression;
if (ctx.stream_reference() != null) {
StreamReference streamReference = (StreamReference) visit(ctx.stream_reference());
if (streamReference.isInnerStream) {
// InnerStream
if (streamReference.streamIndex != null) {
expression = Expression.isNullInnerStream(streamReference.streamId, streamReference.streamIndex);
} else {
expression = Expression.isNullInnerStream(streamReference.streamId);
}
} else {
if (activeStreams.contains(streamReference.streamId)) {
// Stream
if (streamReference.streamIndex != null) {
expression = Expression.isNullStream(streamReference.streamId, streamReference.streamIndex);
} else {
expression = Expression.isNullStream(streamReference.streamId);
}
} else {
// Attribute
expression = Expression.isNull(Expression.variable(streamReference.streamId));
}
}
} else if (ctx.function_operation() != null) {
expression = Expression.isNull((Expression) visit(ctx.function_operation()));
} else {
// attribute_reference
expression = Expression.isNull((Expression) visit(ctx.attribute_reference()));
}
populateQueryContext(expression, ctx);
return expression;
}
Aggregations