/// <summary>
        /// The AddExplicitIndexOrReuse
        /// </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="agentInstanceContext">The <see cref="AgentInstanceContext"/></param>
        /// <param name="optionalSerde">The <see cref="object"/></param>
        /// <returns>The <see cref="Pair{IndexMultiKey, EventTableAndNamePair}"/></returns>
        public Pair <IndexMultiKey, EventTableAndNamePair> AddExplicitIndexOrReuse(
            bool unique,
            IList <IndexedPropDesc> hashProps,
            IList <IndexedPropDesc> btreeProps,
            EventAdvancedIndexProvisionDesc advancedIndexProvisionDesc,
            IEnumerable <EventBean> prefilledEvents,
            EventType indexedType,
            string indexName,
            AgentInstanceContext agentInstanceContext,
            object optionalSerde)
        {
            if (hashProps.IsEmpty() && btreeProps.IsEmpty() && advancedIndexProvisionDesc == null)
            {
                throw new ArgumentException("Invalid zero element list for hash and btree columns");
            }

            // Get an existing table, if any, matching the exact requirement
            var indexPropKeyMatch = EventTableIndexUtil.FindExactMatchNameAndType(_tableIndexesRefCount.Keys, unique, hashProps, btreeProps, advancedIndexProvisionDesc == null ? null : advancedIndexProvisionDesc.IndexDesc);

            if (indexPropKeyMatch != null)
            {
                EventTableIndexRepositoryEntry refTablePair = _tableIndexesRefCount.Get(indexPropKeyMatch);
                return(new Pair <IndexMultiKey, EventTableAndNamePair>(indexPropKeyMatch, new EventTableAndNamePair(refTablePair.Table, refTablePair.OptionalIndexName)));
            }

            return(AddIndex(unique, hashProps, btreeProps, advancedIndexProvisionDesc, prefilledEvents, indexedType, indexName, false, agentInstanceContext, optionalSerde));
        }
Exemplo n.º 2
0
        public static IndexMultiKey FindIndexConsiderTyping(IDictionary <IndexMultiKey, EventTableIndexMetadataEntry> tableIndexesRefCount,
                                                            IList <IndexedPropDesc> hashProps,
                                                            IList <IndexedPropDesc> btreeProps,
                                                            IList <IndexHintInstruction> optionalIndexHintInstructions)
        {
            if (hashProps.IsEmpty() && btreeProps.IsEmpty())
            {
                throw new ArgumentException("Invalid zero element list for hash and btree columns");
            }

            var indexCandidates = //(IDictionary<IndexMultiKey, EventTableIndexRepositoryEntry>)
                                  EventTableIndexUtil.FindCandidates(tableIndexesRefCount, hashProps, btreeProps);

            // if there are hints, follow these
            if (optionalIndexHintInstructions != null)
            {
                var found = EventTableIndexUtil.FindByIndexHint(indexCandidates, optionalIndexHintInstructions);
                if (found != null)
                {
                    return(found);
                }
            }

            // Get an existing table, if any, matching the exact requirement, prefer unique
            var indexPropKeyMatch = EventTableIndexUtil.FindExactMatchNameAndType(tableIndexesRefCount.Keys, true, hashProps, btreeProps);

            if (indexPropKeyMatch == null)
            {
                indexPropKeyMatch = EventTableIndexUtil.FindExactMatchNameAndType(tableIndexesRefCount.Keys, false, hashProps, btreeProps);
            }
            if (indexPropKeyMatch != null)
            {
                return(indexPropKeyMatch);
            }

            if (indexCandidates.IsEmpty())
            {
                return(null);
            }

            var transIndexCandidates = indexCandidates.Transform <IndexMultiKey, EventTableIndexEntryBase, IndexMultiKey, EventTableIndexMetadataEntry>(
                k => k, v => v,
                k => k, v => (EventTableIndexMetadataEntry)v);

            return(GetBestCandidate(transIndexCandidates).First);
        }
Exemplo n.º 3
0
        public Pair <IndexMultiKey, EventTableAndNamePair> AddExplicitIndexOrReuse(
            bool unique,
            IList <IndexedPropDesc> hashProps,
            IList <IndexedPropDesc> btreeProps,
            IEnumerable <EventBean> prefilledEvents,
            EventType indexedType,
            string indexName)
        {
            if (hashProps.IsEmpty() && btreeProps.IsEmpty())
            {
                throw new ArgumentException("Invalid zero element list for hash and btree columns");
            }

            // Get an existing table, if any, matching the exact requirement
            var indexPropKeyMatch = EventTableIndexUtil.FindExactMatchNameAndType(_tableIndexesRefCount.Keys, unique, hashProps, btreeProps);

            if (indexPropKeyMatch != null)
            {
                var refTablePair = _tableIndexesRefCount.Get(indexPropKeyMatch);
                return(new Pair <IndexMultiKey, EventTableAndNamePair>(indexPropKeyMatch, new EventTableAndNamePair(refTablePair.Table, refTablePair.OptionalIndexName)));
            }

            return(AddIndex(unique, hashProps, btreeProps, prefilledEvents, indexedType, indexName, false));
        }