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;
}
}
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();
}
}
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);
}
}
Aggregations