use of org.wso2.siddhi.query.api.definition.WindowDefinition in project siddhi by wso2.
the class DefinitionParserHelper method addWindow.
public static void addWindow(WindowDefinition windowDefinition, ConcurrentMap<String, Window> eventWindowMap, SiddhiAppContext siddhiAppContext) {
if (!eventWindowMap.containsKey(windowDefinition.getId())) {
Window table = new Window(windowDefinition, siddhiAppContext);
eventWindowMap.putIfAbsent(windowDefinition.getId(), table);
}
}
use of org.wso2.siddhi.query.api.definition.WindowDefinition in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitDefinition_window.
@Override
public Object visitDefinition_window(@NotNull SiddhiQLParser.Definition_windowContext ctx) {
Source source = (Source) visit(ctx.source());
if (source.isInnerStream) {
throw newSiddhiParserException(ctx, "'#' cannot be used, because Windows can't be defined as InnerStream!");
}
WindowDefinition windowDefinition = WindowDefinition.id(source.streamId);
List<SiddhiQLParser.Attribute_nameContext> attribute_names = ctx.attribute_name();
List<SiddhiQLParser.Attribute_typeContext> attribute_types = ctx.attribute_type();
for (int i = 0; i < attribute_names.size(); i++) {
SiddhiQLParser.Attribute_nameContext attributeNameContext = attribute_names.get(i);
SiddhiQLParser.Attribute_typeContext attributeTypeContext = attribute_types.get(i);
windowDefinition.attribute((String) visit(attributeNameContext), (Attribute.Type) visit(attributeTypeContext));
}
for (SiddhiQLParser.AnnotationContext annotationContext : ctx.annotation()) {
windowDefinition.annotation((Annotation) visit(annotationContext));
}
AttributeFunction attributeFunction = (AttributeFunction) visit(ctx.function_operation());
Window window = new Window(attributeFunction.getNamespace(), attributeFunction.getName(), attributeFunction.getParameters());
windowDefinition.window(window);
// Optional output event type
if (ctx.output_event_type() != null) {
windowDefinition.setOutputEventType((OutputStream.OutputEventType) visit(ctx.output_event_type()));
}
populateQueryContext(windowDefinition, ctx);
return windowDefinition;
}
use of org.wso2.siddhi.query.api.definition.WindowDefinition in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitSiddhi_app.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public SiddhiApp visitSiddhi_app(@NotNull SiddhiQLParser.Siddhi_appContext ctx) {
SiddhiApp siddhiApp = SiddhiApp.siddhiApp();
for (SiddhiQLParser.App_annotationContext annotationContext : ctx.app_annotation()) {
siddhiApp.annotation((Annotation) visit(annotationContext));
}
for (SiddhiQLParser.Definition_streamContext streamContext : ctx.definition_stream()) {
siddhiApp.defineStream((StreamDefinition) visit(streamContext));
}
for (SiddhiQLParser.Definition_tableContext tableContext : ctx.definition_table()) {
siddhiApp.defineTable((TableDefinition) visit(tableContext));
}
for (SiddhiQLParser.Definition_functionContext functionContext : ctx.definition_function()) {
siddhiApp.defineFunction((FunctionDefinition) visit(functionContext));
}
for (SiddhiQLParser.Definition_windowContext windowContext : ctx.definition_window()) {
siddhiApp.defineWindow((WindowDefinition) visit(windowContext));
}
for (SiddhiQLParser.Definition_aggregationContext aggregationContext : ctx.definition_aggregation()) {
siddhiApp.defineAggregation((AggregationDefinition) visit(aggregationContext));
}
for (SiddhiQLParser.Execution_elementContext executionElementContext : ctx.execution_element()) {
ExecutionElement executionElement = (ExecutionElement) visit(executionElementContext);
if (executionElement instanceof Partition) {
siddhiApp.addPartition((Partition) executionElement);
} else if (executionElement instanceof Query) {
siddhiApp.addQuery((Query) executionElement);
} else {
throw newSiddhiParserException(ctx);
}
}
for (SiddhiQLParser.Definition_triggerContext triggerContext : ctx.definition_trigger()) {
siddhiApp.defineTrigger((TriggerDefinition) visit(triggerContext));
}
populateQueryContext(siddhiApp, ctx);
return siddhiApp;
}
Aggregations