Search in sources :

Example 6 with BasicSingleInputStream

use of io.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, source.isFaultStream);
    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(io.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream) StreamHandler(io.siddhi.query.api.execution.query.input.handler.StreamHandler)

Example 7 with BasicSingleInputStream

use of io.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 if (basicSingleInputStream.isFaultStream()) {
            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(io.siddhi.query.api.execution.query.input.state.StreamStateElement) AbsentStreamStateElement(io.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) BasicSingleInputStream(io.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream)

Example 8 with BasicSingleInputStream

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

the class SiddhiQLBaseVisitorImpl method visitLogical_absent_stateful_source.

@Override
public Object visitLogical_absent_stateful_source(SiddhiQLParser.Logical_absent_stateful_sourceContext ctx) {
    // ;
    if (ctx.logical_absent_stateful_source() != null) {
        return visit(ctx.logical_absent_stateful_source());
    } else if (ctx.AND() != null) {
        if (ctx.basic_absent_pattern_source().size() == 2) {
            StateElement stateElement = State.logicalNotAnd((AbsentStreamStateElement) visit(ctx.basic_absent_pattern_source(0)), (AbsentStreamStateElement) visit(ctx.basic_absent_pattern_source(1)));
            populateQueryContext(stateElement, ctx);
            return stateElement;
        } else {
            StreamStateElement presentStreamState = (StreamStateElement) visit(ctx.standard_stateful_source());
            AbsentStreamStateElement absentStreamState;
            if (!ctx.basic_absent_pattern_source().isEmpty()) {
                absentStreamState = (AbsentStreamStateElement) visit(ctx.basic_absent_pattern_source(0));
            } else {
                absentStreamState = State.logicalNot(new StreamStateElement((BasicSingleInputStream) visit(ctx.basic_source())), null);
            }
            StateElement stateElement = State.logicalNotAnd(absentStreamState, presentStreamState);
            populateQueryContext(stateElement, ctx);
            return stateElement;
        }
    } else if (ctx.OR() != null) {
        if (ctx.basic_absent_pattern_source().size() == 2) {
            return State.logicalOr((AbsentStreamStateElement) visit(ctx.basic_absent_pattern_source(0)), (AbsentStreamStateElement) visit(ctx.basic_absent_pattern_source(1)));
        } else {
            StreamStateElement streamStateElement1 = (StreamStateElement) visit(ctx.standard_stateful_source());
            AbsentStreamStateElement streamStateElement2 = (AbsentStreamStateElement) visit(ctx.basic_absent_pattern_source(0));
            StateElement stateElement = State.logicalOr(streamStateElement2, streamStateElement1);
            populateQueryContext(stateElement, ctx);
            return stateElement;
        }
    } else {
        throw newSiddhiParserException(ctx);
    }
}
Also used : StreamStateElement(io.siddhi.query.api.execution.query.input.state.StreamStateElement) AbsentStreamStateElement(io.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) BasicSingleInputStream(io.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream) AbsentStreamStateElement(io.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) EveryStateElement(io.siddhi.query.api.execution.query.input.state.EveryStateElement) StreamStateElement(io.siddhi.query.api.execution.query.input.state.StreamStateElement) NextStateElement(io.siddhi.query.api.execution.query.input.state.NextStateElement) AbsentStreamStateElement(io.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) StateElement(io.siddhi.query.api.execution.query.input.state.StateElement) CountStateElement(io.siddhi.query.api.execution.query.input.state.CountStateElement)

Example 9 with BasicSingleInputStream

use of io.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())), (TimeConstant) visit(ctx.for_time()));
    populateQueryContext(stateElement, ctx);
    return stateElement;
}
Also used : StreamStateElement(io.siddhi.query.api.execution.query.input.state.StreamStateElement) AbsentStreamStateElement(io.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) BasicSingleInputStream(io.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream) AbsentStreamStateElement(io.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)

Aggregations

BasicSingleInputStream (io.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream)9 AbsentStreamStateElement (io.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)4 StreamStateElement (io.siddhi.query.api.execution.query.input.state.StreamStateElement)4 StreamHandler (io.siddhi.query.api.execution.query.input.handler.StreamHandler)3 SingleInputStream (io.siddhi.query.api.execution.query.input.stream.SingleInputStream)3 OperationNotSupportedException (io.siddhi.core.exception.OperationNotSupportedException)2 CountStateElement (io.siddhi.query.api.execution.query.input.state.CountStateElement)2 EveryStateElement (io.siddhi.query.api.execution.query.input.state.EveryStateElement)2 NextStateElement (io.siddhi.query.api.execution.query.input.state.NextStateElement)2 StateElement (io.siddhi.query.api.execution.query.input.state.StateElement)2 ArrayList (java.util.ArrayList)2 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)1 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)1 ProcessStreamReceiver (io.siddhi.core.query.input.ProcessStreamReceiver)1 EntryValveProcessor (io.siddhi.core.query.input.stream.single.EntryValveProcessor)1 SingleStreamRuntime (io.siddhi.core.query.input.stream.single.SingleStreamRuntime)1 AbsentLogicalPostStateProcessor (io.siddhi.core.query.input.stream.state.AbsentLogicalPostStateProcessor)1 AbsentLogicalPreStateProcessor (io.siddhi.core.query.input.stream.state.AbsentLogicalPreStateProcessor)1 AbsentStreamPostStateProcessor (io.siddhi.core.query.input.stream.state.AbsentStreamPostStateProcessor)1 AbsentStreamPreStateProcessor (io.siddhi.core.query.input.stream.state.AbsentStreamPreStateProcessor)1