use of org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitBasic_source.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public BasicSingleInputStream visitBasic_source(@NotNull SiddhiQLParser.Basic_sourceContext ctx) {
// basic_source
// : io (basic_source_stream_handler)*
// ;
Source source = (Source) visit(ctx.source());
BasicSingleInputStream basicSingleInputStream = new BasicSingleInputStream(null, source.streamId, source.isInnerStream);
if (ctx.basic_source_stream_handlers() != null) {
basicSingleInputStream.addStreamHandlers((List<StreamHandler>) visit(ctx.basic_source_stream_handlers()));
}
populateQueryContext(basicSingleInputStream, ctx);
return basicSingleInputStream;
}
use of org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitDefinition_aggregation.
@Override
public AggregationDefinition visitDefinition_aggregation(@NotNull SiddhiQLParser.Definition_aggregationContext ctx) {
// Read the name of the aggregation
String aggregationName = (String) visitAggregation_name(ctx.aggregation_name());
// Create the aggregation using the extracted aggregation name
AggregationDefinition aggregationDefinition = AggregationDefinition.id(aggregationName);
// Get all annotation and populate the aggregation
for (SiddhiQLParser.AnnotationContext annotationContext : ctx.annotation()) {
aggregationDefinition.annotation((Annotation) visit(annotationContext));
}
// Attach the input stream
BasicSingleInputStream basicSingleInputStream = (BasicSingleInputStream) visit(ctx.standard_stream());
aggregationDefinition.from(basicSingleInputStream);
// Extract the selector and attach it to the new aggregation
BasicSelector selector = (BasicSelector) visit(ctx.group_by_query_selection());
aggregationDefinition.select(selector);
// Get the variable (if available) and aggregate on that variable
if (ctx.attribute_reference() != null) {
Variable aggregatedBy = (Variable) visit(ctx.attribute_reference());
aggregationDefinition.aggregateBy(aggregatedBy);
}
// Extract the specified time-durations and attache it to the aggregation definition
TimePeriod timePeriod = (TimePeriod) visit(ctx.aggregation_time());
aggregationDefinition.every(timePeriod);
populateQueryContext(aggregationDefinition, ctx);
return aggregationDefinition;
}
use of org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitStandard_stateful_source.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public StreamStateElement visitStandard_stateful_source(@NotNull SiddhiQLParser.Standard_stateful_sourceContext ctx) {
if (ctx.event() != null) {
activeStreams.add(visitEvent(ctx.event()));
}
BasicSingleInputStream basicSingleInputStream = (BasicSingleInputStream) visit(ctx.basic_source());
if (ctx.event() != null) {
if (basicSingleInputStream.isInnerStream()) {
activeStreams.remove("#" + basicSingleInputStream.getStreamId());
} else {
activeStreams.remove(basicSingleInputStream.getStreamId());
}
StreamStateElement streamStateElement = new StreamStateElement(basicSingleInputStream.as((String) visit(ctx.event())));
populateQueryContext(streamStateElement, ctx);
return streamStateElement;
} else {
StreamStateElement streamStateElement = new StreamStateElement(basicSingleInputStream);
populateQueryContext(streamStateElement, ctx);
return streamStateElement;
}
}
use of org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitBasic_absent_pattern_source.
@Override
public Object visitBasic_absent_pattern_source(SiddhiQLParser.Basic_absent_pattern_sourceContext ctx) {
// basic_absent_pattern_source
// :NOT basic_source for_time
// ;
AbsentStreamStateElement stateElement = State.logicalNot(new StreamStateElement((BasicSingleInputStream) visit(ctx.basic_source())));
stateElement.waitingTime((TimeConstant) visit(ctx.for_time()));
populateQueryContext(stateElement, ctx);
return stateElement;
}
Aggregations