Search in sources :

Example 11 with Selector

use of org.wso2.siddhi.query.api.execution.query.selection.Selector in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitStore_query.

@Override
public Object visitStore_query(SiddhiQLParser.Store_queryContext ctx) {
    StoreQuery storeQuery = StoreQuery.query().from((InputStore) visit(ctx.store_input()));
    if (ctx.query_section() != null) {
        storeQuery = storeQuery.select((Selector) visit(ctx.query_section()));
    }
    populateQueryContext(storeQuery, ctx);
    return storeQuery;
}
Also used : StoreQuery(org.wso2.siddhi.query.api.execution.query.StoreQuery) BasicSelector(org.wso2.siddhi.query.api.execution.query.selection.BasicSelector) Selector(org.wso2.siddhi.query.api.execution.query.selection.Selector)

Example 12 with Selector

use of org.wso2.siddhi.query.api.execution.query.selection.Selector in project siddhi by wso2.

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;
}
Also used : SiddhiQLParser(org.wso2.siddhi.query.compiler.SiddhiQLParser) Variable(org.wso2.siddhi.query.api.expression.Variable) AggregationDefinition(org.wso2.siddhi.query.api.definition.AggregationDefinition) TimePeriod(org.wso2.siddhi.query.api.aggregation.TimePeriod) BasicSingleInputStream(org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream) BasicSelector(org.wso2.siddhi.query.api.execution.query.selection.BasicSelector)

Example 13 with Selector

use of org.wso2.siddhi.query.api.execution.query.selection.Selector in project siddhi by wso2.

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;
}
Also used : SiddhiQLParser(org.wso2.siddhi.query.compiler.SiddhiQLParser) Variable(org.wso2.siddhi.query.api.expression.Variable) BasicSelector(org.wso2.siddhi.query.api.execution.query.selection.BasicSelector) ArrayList(java.util.ArrayList) OutputAttribute(org.wso2.siddhi.query.api.execution.query.selection.OutputAttribute)

Aggregations

ArrayList (java.util.ArrayList)7 Variable (org.wso2.siddhi.query.api.expression.Variable)5 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)4 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)4 BasicSelector (org.wso2.siddhi.query.api.execution.query.selection.BasicSelector)4 OutputAttribute (org.wso2.siddhi.query.api.execution.query.selection.OutputAttribute)4 SiddhiQLParser (org.wso2.siddhi.query.compiler.SiddhiQLParser)4 ConstantExpressionExecutor (org.wso2.siddhi.core.executor.ConstantExpressionExecutor)3 ExpressionExecutor (org.wso2.siddhi.core.executor.ExpressionExecutor)3 QuerySelector (org.wso2.siddhi.core.query.selector.QuerySelector)3 AttributeProcessor (org.wso2.siddhi.core.query.selector.attribute.processor.AttributeProcessor)3 StoreQuery (org.wso2.siddhi.query.api.execution.query.StoreQuery)3 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)2 ConditionExpressionExecutor (org.wso2.siddhi.core.executor.condition.ConditionExpressionExecutor)2 Attribute (org.wso2.siddhi.query.api.definition.Attribute)2 Query (org.wso2.siddhi.query.api.execution.query.Query)2 ReturnStream (org.wso2.siddhi.query.api.execution.query.output.stream.ReturnStream)2 Selector (org.wso2.siddhi.query.api.execution.query.selection.Selector)2 HashMap (java.util.HashMap)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1