Search in sources :

Example 1 with TimeConstant

use of org.wso2.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitEvery_sequence_source_chain.

@Override
public Object visitEvery_sequence_source_chain(SiddhiQLParser.Every_sequence_source_chainContext ctx) {
    // every_sequence_source_chain
    // : EVERY? sequence_source  within_time?  ',' sequence_source_chain
    // ;
    StateElement stateElement1;
    if (ctx.EVERY() != null) {
        stateElement1 = new EveryStateElement((StateElement) visit(ctx.sequence_source()));
    } else {
        stateElement1 = (StateElement) visit(ctx.sequence_source());
    }
    if (ctx.within_time() != null) {
        stateElement1.setWithin((TimeConstant) visit(ctx.within_time()));
    }
    populateQueryContext(stateElement1, ctx);
    NextStateElement nextStateElement = new NextStateElement(stateElement1, ((StateElement) visit(ctx.sequence_source_chain())));
    populateQueryContext(nextStateElement, ctx);
    StateInputStream stateInputStream = new StateInputStream(StateInputStream.Type.SEQUENCE, nextStateElement);
    populateQueryContext(stateInputStream, ctx);
    return stateInputStream;
}
Also used : NextStateElement(org.wso2.siddhi.query.api.execution.query.input.state.NextStateElement) EveryStateElement(org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement) StreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.StreamStateElement) NextStateElement(org.wso2.siddhi.query.api.execution.query.input.state.NextStateElement) StateElement(org.wso2.siddhi.query.api.execution.query.input.state.StateElement) CountStateElement(org.wso2.siddhi.query.api.execution.query.input.state.CountStateElement) AbsentStreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) StateInputStream(org.wso2.siddhi.query.api.execution.query.input.stream.StateInputStream) EveryStateElement(org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement)

Example 2 with TimeConstant

use of org.wso2.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.

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.wso2.siddhi.query.api.execution.query.input.state.NextStateElement) EveryStateElement(org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement) StreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.StreamStateElement) NextStateElement(org.wso2.siddhi.query.api.execution.query.input.state.NextStateElement) StateElement(org.wso2.siddhi.query.api.execution.query.input.state.StateElement) CountStateElement(org.wso2.siddhi.query.api.execution.query.input.state.CountStateElement) AbsentStreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)

Example 3 with TimeConstant

use of org.wso2.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitEvery_absent_sequence_source_chain.

@Override
public Object visitEvery_absent_sequence_source_chain(SiddhiQLParser.Every_absent_sequence_source_chainContext ctx) {
    // every_absent_sequence_source_chain
    // : EVERY? absent_sequence_source_chain  within_time? ',' sequence_source_chain
    // | EVERY? sequence_source  within_time? ',' absent_sequence_source_chain
    // ;
    StateElement stateElement1;
    StateElement stateElement2;
    if (ctx.EVERY() != null) {
        stateElement1 = new EveryStateElement((StateElement) visit(ctx.getChild(1)));
    } else {
        stateElement1 = (StateElement) visit(ctx.getChild(0));
    }
    if (ctx.within_time() != null) {
        stateElement1.setWithin((TimeConstant) visit(ctx.within_time()));
    }
    stateElement2 = (StateElement) visit(ctx.getChild(ctx.getChildCount() - 1));
    populateQueryContext(stateElement1, ctx);
    populateQueryContext(stateElement2, ctx);
    NextStateElement nextStateElement = new NextStateElement(stateElement1, stateElement2);
    populateQueryContext(nextStateElement, ctx);
    StateInputStream stateInputStream = new StateInputStream(StateInputStream.Type.SEQUENCE, nextStateElement);
    populateQueryContext(stateInputStream, ctx);
    return stateInputStream;
}
Also used : NextStateElement(org.wso2.siddhi.query.api.execution.query.input.state.NextStateElement) EveryStateElement(org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement) StreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.StreamStateElement) NextStateElement(org.wso2.siddhi.query.api.execution.query.input.state.NextStateElement) StateElement(org.wso2.siddhi.query.api.execution.query.input.state.StateElement) CountStateElement(org.wso2.siddhi.query.api.execution.query.input.state.CountStateElement) AbsentStreamStateElement(org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) StateInputStream(org.wso2.siddhi.query.api.execution.query.input.stream.StateInputStream) EveryStateElement(org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement)

Example 4 with TimeConstant

use of org.wso2.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.

the class SiddhiCompiler method parseTimeConstantDefinition.

public static TimeConstant parseTimeConstantDefinition(String source) throws SiddhiParserException {
    ANTLRInputStream input = new ANTLRInputStream(source);
    SiddhiQLLexer lexer = new SiddhiQLLexer(input);
    lexer.removeErrorListeners();
    lexer.addErrorListener(SiddhiErrorListener.INSTANCE);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    SiddhiQLParser parser = new SiddhiQLParser(tokens);
    parser.removeErrorListeners();
    parser.addErrorListener(SiddhiErrorListener.INSTANCE);
    ParseTree tree = parser.time_value();
    SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
    return (TimeConstant) eval.visit(tree);
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) SiddhiQLBaseVisitorImpl(org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree) TimeConstant(org.wso2.siddhi.query.api.expression.constant.TimeConstant)

Example 5 with TimeConstant

use of org.wso2.siddhi.query.api.expression.constant.TimeConstant in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitMinute_value.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public TimeConstant visitMinute_value(@NotNull SiddhiQLParser.Minute_valueContext ctx) {
    TimeConstant timeConstant = Expression.Time.minute(Long.parseLong(ctx.INT_LITERAL().getText().replaceFirst("[lL]", "")));
    populateQueryContext(timeConstant, ctx);
    return timeConstant;
}
Also used : TimeConstant(org.wso2.siddhi.query.api.expression.constant.TimeConstant)

Aggregations

TimeConstant (org.wso2.siddhi.query.api.expression.constant.TimeConstant)15 AbsentStreamStateElement (org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)12 StreamStateElement (org.wso2.siddhi.query.api.execution.query.input.state.StreamStateElement)12 CountStateElement (org.wso2.siddhi.query.api.execution.query.input.state.CountStateElement)11 EveryStateElement (org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement)11 NextStateElement (org.wso2.siddhi.query.api.execution.query.input.state.NextStateElement)11 StateElement (org.wso2.siddhi.query.api.execution.query.input.state.StateElement)11 Test (org.testng.annotations.Test)2 Query (org.wso2.siddhi.query.api.execution.query.Query)2 StateInputStream (org.wso2.siddhi.query.api.execution.query.input.stream.StateInputStream)2 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)1 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)1 ParseTree (org.antlr.v4.runtime.tree.ParseTree)1 PartitionType (org.wso2.siddhi.query.api.execution.partition.PartitionType)1 RangePartitionType (org.wso2.siddhi.query.api.execution.partition.RangePartitionType)1 ValuePartitionType (org.wso2.siddhi.query.api.execution.partition.ValuePartitionType)1 BasicSingleInputStream (org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream)1 EventOutputRate (org.wso2.siddhi.query.api.execution.query.output.ratelimit.EventOutputRate)1 OutputRate (org.wso2.siddhi.query.api.execution.query.output.ratelimit.OutputRate)1 SnapshotOutputRate (org.wso2.siddhi.query.api.execution.query.output.ratelimit.SnapshotOutputRate)1