Search in sources :

Example 6 with BasicSingleInputStream

use of org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitBasic_source.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public BasicSingleInputStream visitBasic_source(@NotNull SiddhiQLParser.Basic_sourceContext ctx) {
    // basic_source
    // : io (basic_source_stream_handler)*
    // ;
    Source source = (Source) visit(ctx.source());
    BasicSingleInputStream basicSingleInputStream = new BasicSingleInputStream(null, source.streamId, source.isInnerStream);
    if (ctx.basic_source_stream_handlers() != null) {
        basicSingleInputStream.addStreamHandlers((List<StreamHandler>) visit(ctx.basic_source_stream_handlers()));
    }
    populateQueryContext(basicSingleInputStream, ctx);
    return basicSingleInputStream;
}
Also used : BasicSingleInputStream(org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream) StreamHandler(org.wso2.siddhi.query.api.execution.query.input.handler.StreamHandler)

Example 7 with BasicSingleInputStream

use of org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream 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 8 with BasicSingleInputStream

use of org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitStandard_stateful_source.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public StreamStateElement visitStandard_stateful_source(@NotNull SiddhiQLParser.Standard_stateful_sourceContext ctx) {
    if (ctx.event() != null) {
        activeStreams.add(visitEvent(ctx.event()));
    }
    BasicSingleInputStream basicSingleInputStream = (BasicSingleInputStream) visit(ctx.basic_source());
    if (ctx.event() != null) {
        if (basicSingleInputStream.isInnerStream()) {
            activeStreams.remove("#" + basicSingleInputStream.getStreamId());
        } else {
            activeStreams.remove(basicSingleInputStream.getStreamId());
        }
        StreamStateElement streamStateElement = new StreamStateElement(basicSingleInputStream.as((String) visit(ctx.event())));
        populateQueryContext(streamStateElement, ctx);
        return streamStateElement;
    } else {
        StreamStateElement streamStateElement = new StreamStateElement(basicSingleInputStream);
        populateQueryContext(streamStateElement, ctx);
        return streamStateElement;
    }
}
Also used : StreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.StreamStateElement) AbsentStreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) BasicSingleInputStream(org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream)

Example 9 with BasicSingleInputStream

use of org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitBasic_absent_pattern_source.

@Override
public Object visitBasic_absent_pattern_source(SiddhiQLParser.Basic_absent_pattern_sourceContext ctx) {
    // basic_absent_pattern_source
    // :NOT basic_source for_time
    // ;
    AbsentStreamStateElement stateElement = State.logicalNot(new StreamStateElement((BasicSingleInputStream) visit(ctx.basic_source())));
    stateElement.waitingTime((TimeConstant) visit(ctx.for_time()));
    populateQueryContext(stateElement, ctx);
    return stateElement;
}
Also used : StreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.StreamStateElement) AbsentStreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) BasicSingleInputStream(org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream) AbsentStreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)

Aggregations

BasicSingleInputStream (org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream)9 AbsentStreamStateElement (org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)4 StreamStateElement (org.wso2.siddhi.query.api.execution.query.input.state.StreamStateElement)4 StreamHandler (org.wso2.siddhi.query.api.execution.query.input.handler.StreamHandler)3 SingleInputStream (org.wso2.siddhi.query.api.execution.query.input.stream.SingleInputStream)3 OperationNotSupportedException (org.wso2.siddhi.core.exception.OperationNotSupportedException)2 CountStateElement (org.wso2.siddhi.query.api.execution.query.input.state.CountStateElement)2 EveryStateElement (org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement)2 NextStateElement (org.wso2.siddhi.query.api.execution.query.input.state.NextStateElement)2 StateElement (org.wso2.siddhi.query.api.execution.query.input.state.StateElement)2 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)1 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)1 ProcessStreamReceiver (org.wso2.siddhi.core.query.input.ProcessStreamReceiver)1 EntryValveProcessor (org.wso2.siddhi.core.query.input.stream.single.EntryValveProcessor)1 SingleStreamRuntime (org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime)1