use of org.ballerinalang.siddhi.query.api.execution.query.selection.BasicSelector in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitGroup_by_query_selection.
@Override
public BasicSelector visitGroup_by_query_selection(@NotNull SiddhiQLParser.Group_by_query_selectionContext ctx) {
BasicSelector selector = new BasicSelector();
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()));
}
populateQueryContext(selector, ctx);
return selector;
}
use of org.ballerinalang.siddhi.query.api.execution.query.selection.BasicSelector in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitDefinition_aggregation.
@Override
public AggregationDefinition visitDefinition_aggregation(@NotNull SiddhiQLParser.Definition_aggregationContext ctx) {
// Read the name of the aggregation
String aggregationName = (String) visitAggregation_name(ctx.aggregation_name());
// Create the aggregation using the extracted aggregation name
AggregationDefinition aggregationDefinition = AggregationDefinition.id(aggregationName);
// Get all annotation and populate the aggregation
for (SiddhiQLParser.AnnotationContext annotationContext : ctx.annotation()) {
aggregationDefinition.annotation((Annotation) visit(annotationContext));
}
// Attach the input stream
BasicSingleInputStream basicSingleInputStream = (BasicSingleInputStream) visit(ctx.standard_stream());
aggregationDefinition.from(basicSingleInputStream);
// Extract the selector and attach it to the new aggregation
BasicSelector selector = (BasicSelector) visit(ctx.group_by_query_selection());
aggregationDefinition.select(selector);
// Get the variable (if available) and aggregate on that variable
if (ctx.attribute_reference() != null) {
Variable aggregatedBy = (Variable) visit(ctx.attribute_reference());
aggregationDefinition.aggregateBy(aggregatedBy);
}
// Extract the specified time-durations and attache it to the aggregation definition
TimePeriod timePeriod = (TimePeriod) visit(ctx.aggregation_time());
aggregationDefinition.every(timePeriod);
populateQueryContext(aggregationDefinition, ctx);
return aggregationDefinition;
}
Aggregations