Search in sources :

Example 11 with TimeConstant

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

the class SiddhiQLBaseVisitorImpl method visitMillisecond_value.

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

Example 12 with TimeConstant

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

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.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 13 with TimeConstant

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

the class SiddhiQLBaseVisitorImpl method visitOutput_rate.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public OutputRate visitOutput_rate(@NotNull SiddhiQLParser.Output_rateContext ctx) {
    if (ctx.SNAPSHOT() != null) {
        SnapshotOutputRate snapshotOutputRate = new SnapshotOutputRate(((TimeConstant) visit(ctx.time_value())).value());
        populateQueryContext(snapshotOutputRate, ctx);
        return snapshotOutputRate;
    } else if (ctx.time_value() != null) {
        TimeOutputRate timeOutputRate = new TimeOutputRate(((TimeConstant) visit(ctx.time_value())).value());
        if (ctx.output_rate_type() != null) {
            timeOutputRate.output((OutputRate.Type) visit(ctx.output_rate_type()));
        }
        populateQueryContext(timeOutputRate, ctx);
        return timeOutputRate;
    } else if (ctx.EVENTS() != null) {
        EventOutputRate eventOutputRate = new EventOutputRate(Integer.parseInt(ctx.INT_LITERAL().getText()));
        if (ctx.output_rate_type() != null) {
            eventOutputRate.output((OutputRate.Type) visit(ctx.output_rate_type()));
        }
        populateQueryContext(eventOutputRate, ctx);
        return eventOutputRate;
    } else {
        throw newSiddhiParserException(ctx);
    }
}
Also used : SnapshotOutputRate(org.wso2.siddhi.query.api.execution.query.output.ratelimit.SnapshotOutputRate) PartitionType(org.wso2.siddhi.query.api.execution.partition.PartitionType) RangePartitionType(org.wso2.siddhi.query.api.execution.partition.RangePartitionType) ValuePartitionType(org.wso2.siddhi.query.api.execution.partition.ValuePartitionType) EventOutputRate(org.wso2.siddhi.query.api.execution.query.output.ratelimit.EventOutputRate) TimeOutputRate(org.wso2.siddhi.query.api.execution.query.output.ratelimit.TimeOutputRate) EventOutputRate(org.wso2.siddhi.query.api.execution.query.output.ratelimit.EventOutputRate) OutputRate(org.wso2.siddhi.query.api.execution.query.output.ratelimit.OutputRate) SnapshotOutputRate(org.wso2.siddhi.query.api.execution.query.output.ratelimit.SnapshotOutputRate) TimeOutputRate(org.wso2.siddhi.query.api.execution.query.output.ratelimit.TimeOutputRate) TimeConstant(org.wso2.siddhi.query.api.expression.constant.TimeConstant)

Example 14 with TimeConstant

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

the class SiddhiQLBaseVisitorImpl method visitYear_value.

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

Example 15 with TimeConstant

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

the class SiddhiQLBaseVisitorImpl method visitHour_value.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public TimeConstant visitHour_value(@NotNull SiddhiQLParser.Hour_valueContext ctx) {
    TimeConstant timeConstant = Expression.Time.hour(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