Search in sources :

Example 6 with TimeConstant

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

the class SiddhiQLBaseVisitorImpl method visitPattern_stream.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Object visitPattern_stream(@NotNull SiddhiQLParser.Pattern_streamContext ctx) {
    // pattern_stream
    // : every_pattern_source_chain within_time?
    // | every_absent_pattern_source_chain within_time?
    // ;
    StateElement stateElement;
    if (ctx.every_pattern_source_chain() != null) {
        stateElement = ((StateElement) visit(ctx.every_pattern_source_chain()));
    } else {
        stateElement = ((StateElement) visit(ctx.absent_pattern_source_chain()));
    }
    TimeConstant within = null;
    if (ctx.within_time() != null) {
        within = (TimeConstant) visit(ctx.within_time());
    }
    StateInputStream stateInputStream = new StateInputStream(StateInputStream.Type.PATTERN, stateElement, within);
    populateQueryContext(stateInputStream, ctx);
    return stateInputStream;
}
Also used : 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) StateInputStream(io.siddhi.query.api.execution.query.input.stream.StateInputStream) TimeConstant(io.siddhi.query.api.expression.constant.TimeConstant)

Example 7 with TimeConstant

use of io.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(io.siddhi.query.api.expression.constant.TimeConstant)

Example 8 with TimeConstant

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

the class SiddhiQLBaseVisitorImpl method visitTime_value.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public TimeConstant visitTime_value(@NotNull SiddhiQLParser.Time_valueContext ctx) {
    TimeConstant timeValueInMillis = Expression.Time.milliSec(0);
    if (ctx.millisecond_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.millisecond_value())).value());
    }
    if (ctx.second_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.second_value())).value());
    }
    if (ctx.minute_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.minute_value())).value());
    }
    if (ctx.hour_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.hour_value())).value());
    }
    if (ctx.day_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.day_value())).value());
    }
    if (ctx.week_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.week_value())).value());
    }
    if (ctx.month_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.month_value())).value());
    }
    if (ctx.year_value() != null) {
        timeValueInMillis.milliSec(((TimeConstant) visit(ctx.year_value())).value());
    }
    populateQueryContext(timeValueInMillis, ctx);
    return timeValueInMillis;
}
Also used : TimeConstant(io.siddhi.query.api.expression.constant.TimeConstant)

Example 9 with TimeConstant

use of io.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(io.siddhi.query.api.execution.query.output.ratelimit.SnapshotOutputRate) ValuePartitionType(io.siddhi.query.api.execution.partition.ValuePartitionType) PartitionType(io.siddhi.query.api.execution.partition.PartitionType) RangePartitionType(io.siddhi.query.api.execution.partition.RangePartitionType) EventOutputRate(io.siddhi.query.api.execution.query.output.ratelimit.EventOutputRate) SnapshotOutputRate(io.siddhi.query.api.execution.query.output.ratelimit.SnapshotOutputRate) EventOutputRate(io.siddhi.query.api.execution.query.output.ratelimit.EventOutputRate) TimeOutputRate(io.siddhi.query.api.execution.query.output.ratelimit.TimeOutputRate) OutputRate(io.siddhi.query.api.execution.query.output.ratelimit.OutputRate) TimeOutputRate(io.siddhi.query.api.execution.query.output.ratelimit.TimeOutputRate) TimeConstant(io.siddhi.query.api.expression.constant.TimeConstant)

Example 10 with TimeConstant

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

the class SiddhiQLBaseVisitorImpl method visitWeek_value.

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

Aggregations

TimeConstant (io.siddhi.query.api.expression.constant.TimeConstant)18 Query (io.siddhi.query.api.execution.query.Query)4 Test (org.testng.annotations.Test)4 AbsentStreamStateElement (io.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)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 StreamStateElement (io.siddhi.query.api.execution.query.input.state.StreamStateElement)2 StateInputStream (io.siddhi.query.api.execution.query.input.stream.StateInputStream)2 PartitionType (io.siddhi.query.api.execution.partition.PartitionType)1 RangePartitionType (io.siddhi.query.api.execution.partition.RangePartitionType)1 ValuePartitionType (io.siddhi.query.api.execution.partition.ValuePartitionType)1 EventOutputRate (io.siddhi.query.api.execution.query.output.ratelimit.EventOutputRate)1 OutputRate (io.siddhi.query.api.execution.query.output.ratelimit.OutputRate)1 SnapshotOutputRate (io.siddhi.query.api.execution.query.output.ratelimit.SnapshotOutputRate)1 TimeOutputRate (io.siddhi.query.api.execution.query.output.ratelimit.TimeOutputRate)1 BoolConstant (io.siddhi.query.api.expression.constant.BoolConstant)1 Constant (io.siddhi.query.api.expression.constant.Constant)1 DoubleConstant (io.siddhi.query.api.expression.constant.DoubleConstant)1