Beispiel #1
0
        public static EventTable[] RealizeTables(
            SubordinateQueryIndexDesc[] indexDescriptors,
            EventType eventType,
            EventTableIndexRepository indexRepository,
            IEnumerable <EventBean> contents,
            AgentInstanceContext agentInstanceContext,
            bool isRecoveringResilient)
        {
            var tables = new EventTable[indexDescriptors.Length];

            for (var i = 0; i < tables.Length; i++)
            {
                var desc  = indexDescriptors[i];
                var table = indexRepository.GetIndexByDesc(desc.IndexMultiKey);
                if (table == null)
                {
                    table = EventTableUtil.BuildIndex(agentInstanceContext, 0, desc.QueryPlanIndexItem, eventType, true, desc.IndexMultiKey.IsUnique, null, null, false);

                    // fill table since its new
                    if (!isRecoveringResilient)
                    {
                        var events = new EventBean[1];
                        foreach (var prefilledEvent in contents)
                        {
                            events[0] = prefilledEvent;
                            table.Add(events);
                        }
                    }

                    indexRepository.AddIndex(desc.IndexMultiKey, new EventTableIndexRepositoryEntry(null, table));
                }
                tables[i] = table;
            }
            return(tables);
        }
Beispiel #2
0
        public NamedWindowRootViewInstance(
            NamedWindowRootView rootView,
            AgentInstanceContext agentInstanceContext,
            EventTableIndexMetadata eventTableIndexMetadata)
        {
            this.rootView = rootView;
            AgentInstanceContext = agentInstanceContext;

            IndexRepository = new EventTableIndexRepository(eventTableIndexMetadata);
            foreach (var entry in eventTableIndexMetadata.Indexes
            ) {
                if (entry.Value.OptionalQueryPlanIndexItem != null) {
                    var index = EventTableUtil.BuildIndex(
                        agentInstanceContext,
                        0,
                        entry.Value.OptionalQueryPlanIndexItem,
                        rootView.EventType,
                        true,
                        entry.Key.IsUnique,
                        entry.Value.OptionalIndexName,
                        null,
                        false);
                    IndexRepository.AddIndex(
                        entry.Key,
                        new EventTableIndexRepositoryEntry(
                            entry.Value.OptionalIndexName,
                            entry.Value.OptionalIndexModuleName,
                            index));
                }
            }
        }
        /// <summary>
        /// The AddIndex
        /// </summary>
        /// <param name="unique">The <see cref="bool"/></param>
        /// <param name="hashProps">The <see cref="IList{IndexedPropDesc}"/></param>
        /// <param name="btreeProps">The <see cref="IList{IndexedPropDesc}"/></param>
        /// <param name="advancedIndexProvisionDesc">The <see cref="EventAdvancedIndexProvisionDesc"/></param>
        /// <param name="prefilledEvents">The <see cref="IEnumerable{EventBean}"/></param>
        /// <param name="indexedType">The <see cref="EventType"/></param>
        /// <param name="indexName">The <see cref="string"/></param>
        /// <param name="mustCoerce">The <see cref="bool"/></param>
        /// <param name="agentInstanceContext">The <see cref="AgentInstanceContext"/></param>
        /// <param name="optionalSerde">The <see cref="object"/></param>
        /// <returns>The <see cref="Pair{IndexMultiKey, EventTableAndNamePair}"/></returns>
        private Pair <IndexMultiKey, EventTableAndNamePair> AddIndex(
            bool unique,
            IList <IndexedPropDesc> hashProps,
            IList <IndexedPropDesc> btreeProps,
            EventAdvancedIndexProvisionDesc advancedIndexProvisionDesc,
            IEnumerable <EventBean> prefilledEvents,
            EventType indexedType,
            string indexName,
            bool mustCoerce,
            AgentInstanceContext agentInstanceContext,
            object optionalSerde)
        {
            // not resolved as full match and not resolved as unique index match, allocate
            var indexPropKey = new IndexMultiKey(unique, hashProps, btreeProps, advancedIndexProvisionDesc == null ? null : advancedIndexProvisionDesc.IndexDesc);

            var indexedPropDescs   = hashProps.ToArray();
            var indexProps         = IndexedPropDesc.GetIndexProperties(indexedPropDescs);
            var indexCoercionTypes = IndexedPropDesc.GetCoercionTypes(indexedPropDescs);

            if (!mustCoerce)
            {
                indexCoercionTypes = null;
            }

            var rangePropDescs     = btreeProps.ToArray();
            var rangeProps         = IndexedPropDesc.GetIndexProperties(rangePropDescs);
            var rangeCoercionTypes = IndexedPropDesc.GetCoercionTypes(rangePropDescs);

            var indexItem = new QueryPlanIndexItem(indexProps, indexCoercionTypes, rangeProps, rangeCoercionTypes, unique, advancedIndexProvisionDesc);
            var table     = EventTableUtil.BuildIndex(agentInstanceContext, 0, indexItem, indexedType, true, unique, indexName, optionalSerde, false);

            // fill table since its new
            var events = new EventBean[1];

            foreach (EventBean prefilledEvent in prefilledEvents)
            {
                events[0] = prefilledEvent;
                table.Add(events, agentInstanceContext);
            }

            // add table
            _tables.Add(table);

            // add index, reference counted
            _tableIndexesRefCount.Put(indexPropKey, new EventTableIndexRepositoryEntry(indexName, table));

            return(new Pair <IndexMultiKey, EventTableAndNamePair>(indexPropKey, new EventTableAndNamePair(table, indexName)));
        }