Ejemplo n.º 1
0
        public TableMetadata(
            string tableName,
            string eplExpression,
            string statementName,
            Type[] keyTypes,
            IDictionary <string, TableMetadataColumn> tableColumns,
            TableStateRowFactory rowFactory,
            int numberMethodAggregations,
            StatementContext createTableStatementContext,
            ObjectArrayEventType internalEventType,
            ObjectArrayEventType publicEventType,
            TableMetadataInternalEventToPublic eventToPublic,
            bool queryPlanLogging)
        {
            _tableName                   = tableName;
            _eplExpression               = eplExpression;
            _statementName               = statementName;
            _keyTypes                    = keyTypes;
            _tableColumns                = tableColumns;
            _rowFactory                  = rowFactory;
            _numberMethodAggregations    = numberMethodAggregations;
            _statementContextCreateTable = createTableStatementContext;
            _internalEventType           = internalEventType;
            _publicEventType             = publicEventType;
            _eventToPublic               = eventToPublic;
            _queryPlanLogging            = queryPlanLogging;

            if (keyTypes.Length > 0)
            {
                var pair = TableServiceUtil.GetIndexMultikeyForKeys(tableColumns, internalEventType);
                _eventTableIndexMetadataRepo.AddIndex(true, pair.Second, tableName, createTableStatementContext.StatementName, true, null);
                _tableRowKeyFactory = new TableRowKeyFactory(pair.First);
            }
        }
Ejemplo n.º 2
0
 public TableMetadata GetTableMetadataFromEventType(EventType type)
 {
     var tableName = TableServiceUtil.GetTableNameFromEventType(type);
     if (tableName == null)
     {
         return null;
     }
     return _tables.Get(tableName);
 }
        public TableStateInstanceGroupedImpl(
            TableMetadata tableMetadata,
            AgentInstanceContext agentInstanceContext,
            IReaderWriterLockManager rwLockManager)
            : base(tableMetadata, agentInstanceContext, rwLockManager)
        {
            IList <EventPropertyGetter> indexGetters = new List <EventPropertyGetter>();
            IList <string> keyNames = new List <string>();

            foreach (var entry in tableMetadata.TableColumns)
            {
                if (entry.Value.IsKey)
                {
                    keyNames.Add(entry.Key);
                    indexGetters.Add(tableMetadata.InternalEventType.GetGetter(entry.Key));
                }
            }

            var tableName    = "primary-" + tableMetadata.TableName;
            var organization = new EventTableOrganization(tableName, true, false, 0, Collections.GetEmptyList <string>(), EventTableOrganizationType.HASH);

            EventTable table;

            if (indexGetters.Count == 1)
            {
                var tableMap = new TransformDictionary <object, EventBean, object, ObjectArrayBackedEventBean>(
                    _rows, k => k, v => v, k => k, v => v as ObjectArrayBackedEventBean);
                table = new PropertyIndexedEventTableSingleUnique(indexGetters[0], organization, tableMap);
            }
            else
            {
                var getters  = indexGetters.ToArrayOrNull();
                var tableMap = new TransformDictionary <MultiKeyUntyped, EventBean, object, ObjectArrayBackedEventBean>(
                    _rows, k => k as MultiKeyUntyped, v => v, k => k, v => v as ObjectArrayBackedEventBean);
                table = new PropertyIndexedEventTableUnique(getters, organization, tableMap);
            }

            var pair = TableServiceUtil.GetIndexMultikeyForKeys(tableMetadata.TableColumns, tableMetadata.InternalEventType);

            _primaryIndexKey = pair.Second;
            _indexRepository.AddIndex(_primaryIndexKey, new EventTableIndexRepositoryEntry(tableName, table));
        }