public String getTableId() { return tableDefinition.getId(); } }
@Override public Finder constructFinder(Expression expression, MatchingMetaStateHolder matchingMetaStateHolder, ExecutionPlanContext executionPlanContext, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, EventTable> eventTableMap) { return new AnalyticsTableOperator(this.tenantId, this.tableName, this.tableDefinition.getAttributeList(), expression, matchingMetaStateHolder, executionPlanContext, variableExpressionExecutors, eventTableMap, this.tableDefinition, tableDefinition.getId()); }
public SiddhiApp defineTable(TableDefinition tableDefinition) { if (tableDefinition == null) { throw new SiddhiAppValidationException("Table Definition should not be null"); } else if (tableDefinition.getId() == null) { throw new SiddhiAppValidationException("Table Id should not be null for Table Definition", tableDefinition.getQueryContextStartIndex(), tableDefinition.getQueryContextEndIndex()); } checkDuplicateDefinition(tableDefinition); this.tableDefinitionMap.put(tableDefinition.getId(), tableDefinition); return this; }
@Override protected void init(TableDefinition tableDefinition, ConfigReader configReader) { this.attributeNames = tableDefinition.getAttributeList().stream().map(Attribute::getName).collect(Collectors.toList()); Annotation storeAnnotation = AnnotationHelper .getAnnotation(ANNOTATION_STORE, tableDefinition.getAnnotations()); Annotation primaryKeys = AnnotationHelper .getAnnotation(ANNOTATION_PRIMARY_KEY, tableDefinition.getAnnotations()); Annotation indices = AnnotationHelper .getAnnotation(ANNOTATION_INDEX_BY, tableDefinition.getAnnotations()); this.initializeConnectionParameters(storeAnnotation, configReader); this.expectedIndexModels = new ArrayList<>(); IndexModel primaryKey = MongoTableUtils.extractPrimaryKey(primaryKeys, this.attributeNames); if (primaryKey != null) { this.expectedIndexModels.add(primaryKey); } this.expectedIndexModels.addAll(MongoTableUtils.extractIndexModels(indices, this.attributeNames)); String customCollectionName = storeAnnotation.getElement( MongoTableConstants.ANNOTATION_ELEMENT_COLLECTION_NAME); this.collectionName = MongoTableUtils.isEmpty(customCollectionName) ? tableDefinition.getId() : customCollectionName; this.initialCollectionTest = false; }
SiddhiConstants.ANNOTATION_FROM, tableDefinition.getAnnotations()); String clusterName = fromAnnotation.getElement( HazelcastEventTableConstants.ANNOTATION_ELEMENT_HAZELCAST_CLUSTER_NAME); HazelcastEventTableConstants.ANNOTATION_ELEMENT_HAZELCAST_CLUSTER_COLLECTION); Annotation annotation = AnnotationHelper.getAnnotation( SiddhiConstants.ANNOTATION_INDEX_BY, tableDefinition.getAnnotations()); boolean serverMode = (hosts == null || hosts.isEmpty()); if (serverMode) { executionPlanContext.getName() + '.' + tableDefinition.getId(); for (Attribute attribute : tableDefinition.getAttributeList()) { metaStreamEvent.addOutputData(attribute); if (annotation.getElements().size() != 1) { throw new OperationNotSupportedException(SiddhiConstants.ANNOTATION_INDEX_BY + " annotation of table " + tableDefinition.getId() + " contains " + annotation.getElements().size() + " elements, Siddhi Hazelcast event table only supports indexing based on a single attribute"); int indexPosition = tableDefinition.getAttributePosition(indexAttribute); eventHolder = new HazelcastPrimaryKeyEventHolder(hzInstance.getMap(collectionName), tableStreamEventPool, eventConverter, indexPosition, indexAttribute); } else {
tableDefinition.getAnnotations()); String dataSourceName = fromAnnotation.getElement(RDBMSEventTableConstants.ANNOTATION_ELEMENT_DATASOURCE_NAME); String tableName = fromAnnotation.getElement(RDBMSEventTableConstants.ANNOTATION_ELEMENT_TABLE_NAME); DataSource dataSource = executionPlanContext.getSiddhiContext().getSiddhiDataSource(dataSourceName); List<Attribute> attributeList = tableDefinition.getAttributeList(); List<Element> connectionPropertyElements = null; Annotation connectionAnnotation = AnnotationHelper.getAnnotation(RDBMSEventTableConstants.ANNOTATION_CONNECTION, tableDefinition.getAnnotations()); if (connectionAnnotation != null) { connectionPropertyElements = connectionAnnotation.getElements();
int columnCount = tableDefinition.getAttributeList().size(); try { while (results.next()) { Object[] eventArray = new Object[columnCount]; for (int i = 0; i < columnCount; i++) { switch (tableDefinition.getAttributeList().get(i).getType()) { case INT: eventArray[i] = results.getInt(i + 1);
ExecutionPlanContext executionPlanContext) { Annotation fromAnnotation = AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_FROM, tableDefinition.getAnnotations()); this.tableDefinition = tableDefinition; this.tableName = fromAnnotation.getElement(AnalyticsEventTableConstants.ANNOTATION_TABLE_NAME);
"InnerStream!"); TableDefinition tableDefinition = TableDefinition.id(source.streamId); List<SiddhiQLParser.Attribute_nameContext> attribute_names = ctx.attribute_name(); List<SiddhiQLParser.Attribute_typeContext> attribute_types = ctx.attribute_type(); SiddhiQLParser.Attribute_nameContext attributeNameContext = attribute_names.get(i); SiddhiQLParser.Attribute_typeContext attributeTypeContext = attribute_types.get(i); tableDefinition.attribute((String) visit(attributeNameContext), (Attribute.Type) visit (attributeTypeContext)); tableDefinition.annotation((Annotation) visit(annotationContext));
queryContextStartIndex = siddhiApp.getTableDefinitionMap().get(streamId).getQueryContextStartIndex(); queryContextEndIndex = siddhiApp.getTableDefinitionMap().get(streamId).getQueryContextEndIndex(); streamDataHolder.setStreamDefinition(ExceptionUtil.getContext(queryContextStartIndex, queryContextEndIndex, siddhiTopologyDataHolder.getUserDefinedSiddhiApp()));
if (state.failed) return tableDefinition; if ( state.backtracking==0 ) {tableDefinition.name(id17);} if (state.failed) return tableDefinition; if ( state.backtracking==0 ) {tableDefinition.attribute(attributeName18, type19);} if (state.failed) return tableDefinition; if ( state.backtracking==0 ) {tableDefinition.from(tableParamName20, tableParamValue21);}
List<Annotation> annotationListObjects = new ArrayList<>(); List<String> annotationList = new ArrayList<>(); for (Annotation annotation : tableDefinition.getAnnotations()) { if (annotation.getName().equalsIgnoreCase("STORE")) { storeConfig = storeConfigGenerator.generateStoreConfig(annotation); TableConfig tableConfig = new TableConfig(tableDefinition.getId(), tableDefinition.getId(), attributeConfigListGenerator.generateAttributeConfigList(tableDefinition.getAttributeList()), storeConfig, annotationList, annotationListObjects); preserveCodeSegmentsOf(storeConfigGenerator, annotationConfigGenerator, attributeConfigListGenerator);
@SuppressWarnings({"rawtypes", "unchecked"}) @Override public void add(ComplexEventChunk addingEventChunk) { this.checkAndProcessPostInit(); addingEventChunk.reset(); int count = AnalyticsEventTableUtils.putEvents(this.tenantId, this.tableName, this.tableDefinition.getAttributeList(), addingEventChunk); if (log.isDebugEnabled()) { log.debug("Records added: " + count + " -> " + this.tenantId + ":" + this.tableName); } this.checkAndWaitForIndexing(); }
@Override protected void init(TableDefinition tableDefinition, ConfigReader configReader) { attributes = tableDefinition.getAttributeList(); storeAnnotation = AnnotationHelper.getAnnotation(ANNOTATION_STORE, tableDefinition.getAnnotations()); primaryKeys = AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_PRIMARY_KEY, tableDefinition.getAnnotations()); primaryKeyAttributePositionsList = new ArrayList<>(); if (primaryKeys != null) { tableDefinition.getAnnotations()); RDBMSTableUtils.validateAnnotation(primaryKeys); RDBMSTableUtils.validateAnnotation(indices); this.tableName = RDBMSTableUtils.isEmpty(tableName) ? tableDefinition.getId() : tableName;
/** * Called to construct a operator to perform delete and update operations */ @Override public Operator constructOperator(Expression expression, MatchingMetaStateHolder matchingMetaStateHolder, ExecutionPlanContext executionPlanContext, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, EventTable> eventTableMap) { return RDBMSOperatorParser.parse(dbHandler, expression, matchingMetaStateHolder, executionPlanContext, variableExpressionExecutors, eventTableMap, tableDefinition, cachedTable, tableDefinition.getId()); }
@Override public Operator constructOperator(Expression expression, MatchingMetaStateHolder matchingMetaStateHolder, ExecutionPlanContext executionPlanContext, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, EventTable> eventTableMap) { return new AnalyticsTableOperator(this.tenantId, this.tableName, this.tableDefinition.getAttributeList(), expression, matchingMetaStateHolder, executionPlanContext, variableExpressionExecutors, eventTableMap, this.tableDefinition, this.tableDefinition.getId()); }
public SiddhiApp defineTable(TableDefinition tableDefinition) { if (tableDefinition == null) { throw new SiddhiAppValidationException("Table Definition should not be null"); } else if (tableDefinition.getId() == null) { throw new SiddhiAppValidationException("Table Id should not be null for Table Definition", tableDefinition.getQueryContextStartIndex(), tableDefinition.getQueryContextEndIndex()); } checkDuplicateDefinition(tableDefinition); this.tableDefinitionMap.put(tableDefinition.getId(), tableDefinition); return this; }
public CachingTable(String cachingAlgorithm, String cacheSize, ExecutionPlanContext executionPlanContext, TableDefinition tableDefinition) { this.elementId = executionPlanContext.getElementIdGenerator().createNewId(); this.list = new LinkedList<StreamEvent>(); long cacheLimit = DEFAULT_CACHE_SIZE; if (cacheSize != null) { try { cacheLimit = Integer.parseInt(cacheSize); } catch (Exception ex) { log.error("Can't parse the cache size. Creating cache with the default size."); } } if (CACHING_ALGO_LFU.equalsIgnoreCase(cachingAlgorithm)) { this.cacheManager = new LFUCacheManager(list, cacheLimit); } else if (CACHING_ALGO_LRU.equalsIgnoreCase(cachingAlgorithm)) { this.cacheManager = new LRUCacheManager(list, cacheLimit); } else { this.cacheManager = new BasicCacheManager(list, cacheLimit); } MetaStreamEvent metaStreamEvent = new MetaStreamEvent(); metaStreamEvent.addInputDefinition(tableDefinition); for (Attribute attribute : tableDefinition.getAttributeList()) { metaStreamEvent.addOutputData(attribute); } streamEventPool = new StreamEventPool(metaStreamEvent, 10); eventConverter = new ZeroStreamEventConverter(); }
/** * Called to construct a operator to perform search operations */ @Override public Finder constructFinder(Expression expression, MatchingMetaStateHolder matchingMetaStateHolder, ExecutionPlanContext executionPlanContext, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, EventTable> eventTableMap) { return RDBMSOperatorParser.parse(dbHandler, expression, matchingMetaStateHolder, executionPlanContext, variableExpressionExecutors, eventTableMap, tableDefinition, cachedTable, tableDefinition.getId()); }
if (eventsToBeAdded.hasNext()) { int count = AnalyticsEventTableUtils.putEvents(this.tenantId, this.tableName, this.tableDefinition.getAttributeList(), eventsToBeAdded); if (log.isDebugEnabled()) { log.debug("Records added: " + count + " -> " + this.tenantId + ":" + this.tableName);