public static void addTable(TableDefinition tableDefinition, ConcurrentMap<String, Table> tableMap,
                                SiddhiAppContext siddhiAppContext) {

        if (!tableMap.containsKey(tableDefinition.getId())) {

            MetaStreamEvent tableMetaStreamEvent = new MetaStreamEvent();
            tableMetaStreamEvent.addInputDefinition(tableDefinition);
            for (Attribute attribute : tableDefinition.getAttributeList()) {
                tableMetaStreamEvent.addOutputData(attribute);
            }

            StreamEventFactory tableStreamEventFactory = new StreamEventFactory(tableMetaStreamEvent);
            StreamEventCloner tableStreamEventCloner = new StreamEventCloner(tableMetaStreamEvent,
                    tableStreamEventFactory);

            Annotation annotation = AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_STORE,
                    tableDefinition.getAnnotations());

            Table table;
            ConfigReader configReader = null;
            RecordTableHandlerManager recordTableHandlerManager = null;
            RecordTableHandler recordTableHandler = null;
            if (annotation != null) {
                annotation = updateAnnotationRef(annotation, SiddhiConstants.NAMESPACE_STORE, siddhiAppContext);
                String tableType = annotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_TYPE);
                if (tableType == null) {
                    throw new SiddhiAppCreationException(
                            "Attribute 'type' does not exist for annotation '" + annotation + "'",
                            annotation, siddhiAppContext);
                }
                Extension extension = new Extension() {
                    @Override
                    public String getNamespace() {
                        return SiddhiConstants.NAMESPACE_STORE;
                    }

                    @Override
                    public String getName() {
                        return tableType;
                    }
                };
                recordTableHandlerManager = siddhiAppContext.getSiddhiContext().getRecordTableHandlerManager();
                if (recordTableHandlerManager != null) {
                    recordTableHandler = recordTableHandlerManager.generateRecordTableHandler();
                }
                table = (Table) SiddhiClassLoader.loadExtensionImplementation(extension,
                        TableExtensionHolder.getInstance(siddhiAppContext));
                configReader = siddhiAppContext.getSiddhiContext().getConfigManager()
                        .generateConfigReader(extension.getNamespace(), extension.getName());
            } else {
                table = new InMemoryTable();
            }
            table.initTable(tableDefinition, tableStreamEventFactory, tableStreamEventCloner, configReader,
                    siddhiAppContext, recordTableHandler);
            if (recordTableHandler != null) {
                recordTableHandlerManager.registerRecordTableHandler(recordTableHandler.getId(),
                        recordTableHandler);
            }
            tableMap.putIfAbsent(tableDefinition.getId(), table);
        }
    }
Utility class for queryParser to help with QueryRuntime
generation.
modules/siddhi-core/src/main/java/io/siddhi/core/util/parser/helper/DefinitionParserHelper.java