Search in sources :

Example 1 with OutputRate

use of org.wso2.siddhi.query.api.execution.query.output.ratelimit.OutputRate in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitAnonymous_stream.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public AnonymousInputStream visitAnonymous_stream(@NotNull SiddhiQLParser.Anonymous_streamContext ctx) {
    if (ctx.anonymous_stream() != null) {
        return (AnonymousInputStream) visit(ctx.anonymous_stream());
    }
    Set<String> activeStreamsBackup = activeStreams;
    try {
        activeStreams = new HashSet<String>();
        Query query = Query.query().from((InputStream) visit(ctx.query_input()));
        if (ctx.query_section() != null) {
            query.select((Selector) visit(ctx.query_section()));
        }
        if (ctx.output_rate() != null) {
            query.output((OutputRate) visit(ctx.output_rate()));
        }
        if (ctx.output_event_type() != null) {
            query.outStream(new ReturnStream((OutputStream.OutputEventType) visit(ctx.output_event_type())));
        } else {
            query.outStream(new ReturnStream());
        }
        AnonymousInputStream anonymousInputStream = new AnonymousInputStream(query);
        populateQueryContext(anonymousInputStream, ctx);
        return anonymousInputStream;
    } finally {
        activeStreams.clear();
        activeStreams = activeStreamsBackup;
    }
}
Also used : StoreQuery(org.wso2.siddhi.query.api.execution.query.StoreQuery) Query(org.wso2.siddhi.query.api.execution.query.Query) AnonymousInputStream(org.wso2.siddhi.query.api.execution.query.input.stream.AnonymousInputStream) ReturnStream(org.wso2.siddhi.query.api.execution.query.output.stream.ReturnStream)

Example 2 with OutputRate

use of org.wso2.siddhi.query.api.execution.query.output.ratelimit.OutputRate in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitQuery.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Query visitQuery(@NotNull SiddhiQLParser.QueryContext ctx) {
    try {
        Query query = Query.query().from((InputStream) visit(ctx.query_input()));
        if (ctx.query_section() != null) {
            query.select((Selector) visit(ctx.query_section()));
        }
        if (ctx.output_rate() != null) {
            query.output((OutputRate) visit(ctx.output_rate()));
        }
        for (SiddhiQLParser.AnnotationContext annotationContext : ctx.annotation()) {
            query.annotation((Annotation) visit(annotationContext));
        }
        if (ctx.query_output() != null) {
            query.outStream((OutputStream) visit(ctx.query_output()));
        }
        populateQueryContext(query, ctx);
        return query;
    } finally {
        activeStreams.clear();
    }
}
Also used : SiddhiQLParser(org.wso2.siddhi.query.compiler.SiddhiQLParser) StoreQuery(org.wso2.siddhi.query.api.execution.query.StoreQuery) Query(org.wso2.siddhi.query.api.execution.query.Query)

Example 3 with OutputRate

use of org.wso2.siddhi.query.api.execution.query.output.ratelimit.OutputRate 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)

Aggregations

Query (org.wso2.siddhi.query.api.execution.query.Query)2 StoreQuery (org.wso2.siddhi.query.api.execution.query.StoreQuery)2 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 AnonymousInputStream (org.wso2.siddhi.query.api.execution.query.input.stream.AnonymousInputStream)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 TimeOutputRate (org.wso2.siddhi.query.api.execution.query.output.ratelimit.TimeOutputRate)1 ReturnStream (org.wso2.siddhi.query.api.execution.query.output.stream.ReturnStream)1 TimeConstant (org.wso2.siddhi.query.api.expression.constant.TimeConstant)1 SiddhiQLParser (org.wso2.siddhi.query.compiler.SiddhiQLParser)1