use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.
the class MinIncrementalAttributeAggregator method init.
@Override
public void init(String attributeName, Attribute.Type attributeType) {
if (attributeName == null) {
throw new SiddhiAppCreationException("Min incremental attribute aggregation cannot be executed " + "when no parameters are given");
}
if (attributeType.equals(Attribute.Type.INT) || attributeType.equals(Attribute.Type.LONG) || attributeType.equals(Attribute.Type.DOUBLE) || attributeType.equals(Attribute.Type.FLOAT)) {
this.baseAttributes = new Attribute[] { new Attribute("AGG_MIN_".concat(attributeName), attributeType) };
this.baseAttributesInitialValues = new Expression[] { Expression.variable(attributeName) };
this.returnType = attributeType;
assert baseAttributes.length == baseAttributesInitialValues.length;
} else {
throw new SiddhiAppRuntimeException("Min aggregation cannot be executed on attribute type " + attributeType.toString());
}
}
use of org.wso2.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 (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;
}
use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitNot_math_operation.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Expression visitNot_math_operation(@NotNull SiddhiQLParser.Not_math_operationContext ctx) {
Expression expression = Expression.not((Expression) visit(ctx.math_operation()));
populateQueryContext(expression, ctx);
return expression;
}
use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.
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.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitQuery_section.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Selector visitQuery_section(@NotNull SiddhiQLParser.Query_sectionContext ctx) {
// query_section
// :(SELECT ('*'| (output_attribute (',' output_attribute)* ))) group_by? having?
// ;
Selector selector = new Selector();
List<OutputAttribute> attributeList = new ArrayList<OutputAttribute>(ctx.output_attribute().size());
for (SiddhiQLParser.Output_attributeContext output_attributeContext : ctx.output_attribute()) {
attributeList.add((OutputAttribute) visit(output_attributeContext));
}
selector.addSelectionList(attributeList);
if (ctx.group_by() != null) {
selector.addGroupByList((List<Variable>) visit(ctx.group_by()));
}
if (ctx.having() != null) {
selector.having((Expression) visit(ctx.having()));
}
if (ctx.order_by() != null) {
selector.addOrderByList((List<OrderByAttribute>) visit(ctx.order_by()));
}
if (ctx.limit() != null) {
selector.limit((Constant) visit(ctx.limit()));
}
populateQueryContext(selector, ctx);
return selector;
}
Aggregations