Search in sources :

Example 11 with TimeConstant

use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.

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(org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant)

Example 12 with TimeConstant

use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitSecond_value.

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

Example 13 with TimeConstant

use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.

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.ballerinalang.siddhi.query.api.expression.constant.TimeConstant)

Example 14 with TimeConstant

use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitConstant_value.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Constant visitConstant_value(@NotNull SiddhiQLParser.Constant_valueContext ctx) {
    // constant_value
    // :bool_value
    // |signed_double_value
    // |signed_float_value
    // |signed_long_value
    // |signed_int_value
    // |time_value
    // |string_value
    // ;
    Constant constant;
    if (ctx.bool_value() != null) {
        constant = Expression.value(((BoolConstant) visit(ctx.bool_value())).getValue());
    } else if (ctx.signed_double_value() != null) {
        constant = Expression.value(((DoubleConstant) visit(ctx.signed_double_value())).getValue());
    } else if (ctx.signed_float_value() != null) {
        constant = Expression.value(((FloatConstant) visit(ctx.signed_float_value())).getValue());
    } else if (ctx.signed_long_value() != null) {
        constant = Expression.value(((LongConstant) visit(ctx.signed_long_value())).getValue());
    } else if (ctx.signed_int_value() != null) {
        constant = Expression.value(((IntConstant) visit(ctx.signed_int_value())).getValue());
    } else if (ctx.time_value() != null) {
        constant = (TimeConstant) visit(ctx.time_value());
    } else if (ctx.string_value() != null) {
        constant = Expression.value(((StringConstant) visit(ctx.string_value())).getValue());
    } else {
        throw newSiddhiParserException(ctx);
    }
    populateQueryContext(constant, ctx);
    return constant;
}
Also used : BoolConstant(org.ballerinalang.siddhi.query.api.expression.constant.BoolConstant) TimeConstant(org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant) LongConstant(org.ballerinalang.siddhi.query.api.expression.constant.LongConstant) DoubleConstant(org.ballerinalang.siddhi.query.api.expression.constant.DoubleConstant) BoolConstant(org.ballerinalang.siddhi.query.api.expression.constant.BoolConstant) FloatConstant(org.ballerinalang.siddhi.query.api.expression.constant.FloatConstant) StringConstant(org.ballerinalang.siddhi.query.api.expression.constant.StringConstant) IntConstant(org.ballerinalang.siddhi.query.api.expression.constant.IntConstant) Constant(org.ballerinalang.siddhi.query.api.expression.constant.Constant) FloatConstant(org.ballerinalang.siddhi.query.api.expression.constant.FloatConstant) IntConstant(org.ballerinalang.siddhi.query.api.expression.constant.IntConstant) StringConstant(org.ballerinalang.siddhi.query.api.expression.constant.StringConstant) TimeConstant(org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant)

Example 15 with TimeConstant

use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitMonth_value.

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

Aggregations

TimeConstant (org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant)15 Query (org.ballerinalang.siddhi.query.api.execution.query.Query)2 Test (org.testng.annotations.Test)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.ballerinalang.siddhi.query.api.execution.partition.PartitionType)1 RangePartitionType (org.ballerinalang.siddhi.query.api.execution.partition.RangePartitionType)1 ValuePartitionType (org.ballerinalang.siddhi.query.api.execution.partition.ValuePartitionType)1 AbsentStreamStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)1 CountStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement)1 EveryStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement)1 NextStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement)1 StateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement)1 StreamStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement)1 EventOutputRate (org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.EventOutputRate)1 OutputRate (org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.OutputRate)1 SnapshotOutputRate (org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.SnapshotOutputRate)1 TimeOutputRate (org.ballerinalang.siddhi.query.api.execution.query.output.ratelimit.TimeOutputRate)1 BoolConstant (org.ballerinalang.siddhi.query.api.expression.constant.BoolConstant)1