use of io.siddhi.query.api.expression.Expression in project siddhi by wso2.
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 (!streamReference.isFaultStream && activeStreams.contains(streamReference.streamId)) {
// Stream
if (streamReference.streamIndex != null) {
expression = Expression.isNullStream(streamReference.streamId, streamReference.streamIndex);
} else {
expression = Expression.isNullStream(streamReference.streamId);
}
} else if (streamReference.isFaultStream && activeStreams.contains(SiddhiConstants.FAULT_STREAM_FLAG + streamReference.streamId)) {
// FaultStream
if (streamReference.streamIndex != null) {
expression = Expression.isNullFaultStream(streamReference.streamId, streamReference.streamIndex);
} else {
expression = Expression.isNullFaultStream(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;
}
use of io.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)?
//
// |left_source=join_source join right_source=join_source (ON expression)?
// |left_source=join_source left_unidirectional=UNIDIRECTIONAL join right_source=join_source (ON expression)?
//
// ;
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 io.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 io.siddhi.query.api.expression.Expression in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitMultiplication_math_operation.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Expression visitMultiplication_math_operation(@NotNull SiddhiQLParser.Multiplication_math_operationContext ctx) {
Expression expression;
if (ctx.multiply != null) {
expression = Expression.multiply((Expression) visit(ctx.math_operation(0)), (Expression) visit(ctx.math_operation(1)));
} else if (ctx.devide != null) {
expression = Expression.divide((Expression) visit(ctx.math_operation(0)), (Expression) visit(ctx.math_operation(1)));
} else if (ctx.mod != null) {
expression = Expression.mod((Expression) visit(ctx.math_operation(0)), (Expression) visit(ctx.math_operation(1)));
} else {
throw newSiddhiParserException(ctx);
}
populateQueryContext(expression, ctx);
return expression;
}
use of io.siddhi.query.api.expression.Expression in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitEquality_math_operation.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Expression visitEquality_math_operation(@NotNull SiddhiQLParser.Equality_math_operationContext ctx) {
if (ctx.eq != null) {
Expression expression = Expression.compare((Expression) visit(ctx.math_operation(0)), Compare.Operator.EQUAL, (Expression) visit(ctx.math_operation(1)));
populateQueryContext(expression, ctx);
return expression;
} else if (ctx.not_eq != null) {
Expression expression = Expression.compare((Expression) visit(ctx.math_operation(0)), Compare.Operator.NOT_EQUAL, (Expression) visit(ctx.math_operation(1)));
populateQueryContext(expression, ctx);
return expression;
} else {
throw newSiddhiParserException(ctx);
}
}
Aggregations