Search in sources :

Example 1 with StateElement

use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement in project ballerina by ballerina-lang.

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())));
            }
            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 : AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement) BasicSingleInputStream(org.ballerinalang.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) StateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) CountStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement)

Example 2 with StateElement

use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitRight_absent_sequence_source.

@Override
public Object visitRight_absent_sequence_source(SiddhiQLParser.Right_absent_sequence_sourceContext ctx) {
    if (ctx.right_absent_sequence_source().size() == 1 && ctx.basic_absent_pattern_source() == null && ctx.sequence_source_chain() == null) {
        // '('right_absent_pattern_source')' within_time?
        StateElement stateElement = (StateElement) visit(ctx.right_absent_sequence_source(0));
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
        populateQueryContext(stateElement, ctx);
        return stateElement;
    } else {
        NextStateElement nextStateElement = new NextStateElement((StateElement) visit(ctx.getChild(0)), (StateElement) visit(ctx.getChild(2)));
        populateQueryContext(nextStateElement, ctx);
        return nextStateElement;
    }
}
Also used : NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) StateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) CountStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement)

Example 3 with StateElement

use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitAbsent_pattern_source_chain.

@Override
public Object visitAbsent_pattern_source_chain(SiddhiQLParser.Absent_pattern_source_chainContext ctx) {
    if (ctx.absent_pattern_source_chain() != null) {
        StateElement stateElement = (StateElement) visit(ctx.absent_pattern_source_chain());
        if (ctx.EVERY() != null) {
            stateElement = new EveryStateElement(stateElement);
        }
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
        populateQueryContext(stateElement, ctx);
        return stateElement;
    } else {
        return visit(ctx.getChild(0));
    }
}
Also used : EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) StateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) CountStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement)

Example 4 with StateElement

use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitPattern_source_chain.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Object visitPattern_source_chain(@NotNull SiddhiQLParser.Pattern_source_chainContext ctx) {
    if (ctx.pattern_source_chain().size() == 1) {
        StateElement stateElement = ((StateElement) visit(ctx.pattern_source_chain(0)));
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
        populateQueryContext(stateElement, ctx);
        return stateElement;
    } else if (ctx.pattern_source_chain().size() == 2) {
        NextStateElement nextStateElement = new NextStateElement(((StateElement) visit(ctx.pattern_source_chain(0))), ((StateElement) visit(ctx.pattern_source_chain(1))));
        populateQueryContext(nextStateElement, ctx);
        return nextStateElement;
    } else if (ctx.pattern_source() != null) {
        StateElement stateElement = ((StateElement) visit(ctx.pattern_source()));
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
        populateQueryContext(stateElement, ctx);
        return stateElement;
    } else {
        throw newSiddhiParserException(ctx);
    }
}
Also used : NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) StateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) CountStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement)

Example 5 with StateElement

use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitLeft_absent_sequence_source.

@Override
public Object visitLeft_absent_sequence_source(SiddhiQLParser.Left_absent_sequence_sourceContext ctx) {
    if (ctx.left_absent_sequence_source().size() == 1 && ctx.basic_absent_pattern_source() == null && ctx.sequence_source_chain() == null) {
        // '('left_absent_pattern_source')' within_time?
        StateElement stateElement = (StateElement) visit(ctx.left_absent_sequence_source(0));
        if (ctx.within_time() != null) {
            stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
        }
        populateQueryContext(stateElement, ctx);
        return stateElement;
    } else {
        NextStateElement nextStateElement = new NextStateElement((StateElement) visit(ctx.getChild(0)), (StateElement) visit(ctx.getChild(2)));
        populateQueryContext(nextStateElement, ctx);
        return nextStateElement;
    }
}
Also used : NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) StateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) CountStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement)

Aggregations

CountStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement)18 EveryStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement)18 NextStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement)18 StateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement)18 StreamStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement)18 AbsentStreamStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)17 StateInputStream (org.ballerinalang.siddhi.query.api.execution.query.input.stream.StateInputStream)4 LogicalStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.LogicalStateElement)3 SingleStreamRuntime (org.ballerinalang.siddhi.core.query.input.stream.single.SingleStreamRuntime)2 AbsentStreamPreStateProcessor (org.ballerinalang.siddhi.core.query.input.stream.state.AbsentStreamPreStateProcessor)2 StateStreamRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.StateStreamRuntime)2 StreamPreStateProcessor (org.ballerinalang.siddhi.core.query.input.stream.state.StreamPreStateProcessor)2 CountInnerStateRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.runtime.CountInnerStateRuntime)2 EveryInnerStateRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.runtime.EveryInnerStateRuntime)2 InnerStateRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.runtime.InnerStateRuntime)2 LogicalInnerStateRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.runtime.LogicalInnerStateRuntime)2 NextInnerStateRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.runtime.NextInnerStateRuntime)2 StreamInnerStateRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.runtime.StreamInnerStateRuntime)2 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1