Java Code Examples for io.siddhi.query.api.execution.query.Query#outStream()

The following examples show how to use io.siddhi.query.api.execution.query.Query#outStream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SiddhiQLBaseVisitorImpl.java    From siddhi with Apache License 2.0 5 votes vote down vote up
/**
     * {@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) {

//        query
//        : annotation* query_input query_section? output_rate? (query_output | query_publish)
//        ;

        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();
        }
    }
 
Example 2
Source File: SiddhiQLBaseVisitorImpl.java    From siddhi with Apache License 2.0 5 votes vote down vote up
/**
 * {@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;
    }
}