private void Init(List <byte[]> indexIdList,
                   List <int> primaryIdList,
                   string targetIndexName,
                   List <string> tagsFromIndexes,
                   TagSort tagSort,
                   int maxItems,
                   bool excludeData,
                   bool getIndexHeader,
                   Dictionary <byte[], IndexIdParams> indexIdParamsMapping,
                   bool getAdditionalAvailableItemCount,
                   Filter filter,
                   FullDataIdInfo fullDataIdInfo,
                   IndexCondition indexCondition,
                   bool clientSideSubsetProcessingRequired,
                   CapCondition capCondition,
                   GetIndexHeaderType getIndexHeaderType)
 {
     IndexIdList                     = indexIdList;
     PrimaryIdList                   = primaryIdList;
     TargetIndexName                 = targetIndexName;
     TagsFromIndexes                 = tagsFromIndexes;
     TagSort                         = tagSort;
     MaxItems                        = maxItems;
     ExcludeData                     = excludeData;
     GetIndexHeader                  = getIndexHeader;
     IndexIdParamsMapping            = indexIdParamsMapping;
     GetAdditionalAvailableItemCount = getAdditionalAvailableItemCount;
     Filter         = filter;
     FullDataIdInfo = fullDataIdInfo;
     IndexCondition = indexCondition;
     ClientSideSubsetProcessingRequired = clientSideSubsetProcessingRequired;
     CapCondition       = capCondition;
     GetIndexHeaderType = getIndexHeaderType;
 }
        public override void Deserialize(IPrimitiveReader reader, int version)
        {
            //Offset
            Offset = reader.ReadInt32();

            //Span
            Span = reader.ReadInt32();

            //TargetIndexName
            TargetIndexName = reader.ReadString();

            //TagsFromIndexes
            ushort count = reader.ReadUInt16();

            if (count > 0)
            {
                TagsFromIndexes = new List <string>(count);
                for (ushort i = 0; i < count; i++)
                {
                    TagsFromIndexes.Add(reader.ReadString());
                }
            }

            //TagSort
            if (reader.ReadByte() != 0)
            {
                TagSort = new TagSort();
                Serializer.Deserialize(reader.BaseStream, TagSort);
            }

            //IndexIdList
            count = reader.ReadUInt16();
            if (count > 0)
            {
                IndexIdList = new List <byte[]>(count);
                ushort len;
                for (ushort i = 0; i < count; i++)
                {
                    len = reader.ReadUInt16();
                    if (len > 0)
                    {
                        IndexIdList.Add(reader.ReadBytes(len));
                    }
                }
            }

            //Read a byte to account for deprecated CriterionList
            reader.ReadByte();

            //MaxItemsPerIndex
            MaxItems = reader.ReadInt32();

            //ExcludeData
            ExcludeData = reader.ReadBoolean();

            //GetIndexHeader
            GetIndexHeader = reader.ReadBoolean();

            //GetPageableItemCount
            GetAdditionalAvailableItemCount = reader.ReadBoolean();

            //PrimaryIdList
            count = reader.ReadUInt16();
            if (count > 0)
            {
                PrimaryIdList = new List <int>(count);
                for (ushort i = 0; i < count; i++)
                {
                    PrimaryIdList.Add(reader.ReadInt32());
                }
            }

            //Filter
            byte b = reader.ReadByte();

            if (b != 0)
            {
                FilterType filterType = (FilterType)b;
                Filter = FilterFactory.CreateFilter(reader, filterType);
            }

            //IndexIdParamsMapping
            count = reader.ReadUInt16();
            if (count > 0)
            {
                IndexIdParamsMapping = new Dictionary <byte[], IndexIdParams>(count, new ByteArrayEqualityComparer());
                byte[]        indexId;
                IndexIdParams indexIdParam;
                ushort        len;

                for (ushort i = 0; i < count; i++)
                {
                    len     = reader.ReadUInt16();
                    indexId = null;
                    if (len > 0)
                    {
                        indexId = reader.ReadBytes(len);

                        indexIdParam = new IndexIdParams();
                        Serializer.Deserialize(reader.BaseStream, indexIdParam);

                        IndexIdParamsMapping.Add(indexId, indexIdParam);
                    }
                }
            }

            //FullDataIdInfo
            if (reader.ReadBoolean())
            {
                FullDataIdInfo = new FullDataIdInfo();
                Serializer.Deserialize(reader.BaseStream, FullDataIdInfo);
            }

            //ClientSideSubsetProcessingRequired
            ClientSideSubsetProcessingRequired = reader.ReadBoolean();

            if (version >= 2)
            {
                //CapCondition
                if (reader.ReadBoolean())
                {
                    CapCondition = new CapCondition();
                    Serializer.Deserialize(reader.BaseStream, CapCondition);
                }
            }

            if (version >= 3)
            {
                //GetIndexHeaderType
                GetIndexHeaderType = (GetIndexHeaderType)reader.ReadByte();
            }
        }
Beispiel #3
0
        public override string ToString()
        {
            var stb = new StringBuilder();

            stb.Append("(").Append("TargetIndexName: ").Append(TargetIndexName).Append("),");

            stb.Append("(").Append("TagsFromIndexes Count: ").Append(TagsFromIndexes == null ? "Null" : TagsFromIndexes.Count.ToString());
            if (TagsFromIndexes != null && TagsFromIndexes.Count > 0)
            {
                foreach (var indexName in TagsFromIndexes)
                {
                    stb.Append("(").Append(" IndexName: ").Append(indexName).Append("),");
                }
            }
            stb.Append("),");

            stb.Append("(").Append("TagSort: ").Append(TagSort == null ? "Null" : TagSort.ToString()).Append("),");

            stb.Append("(").Append("IndexIdList Count: ").Append(IndexIdList == null ? "Null" : IndexIdList.Count.ToString());
            if (IndexIdList != null && IndexIdList.Count > 0)
            {
                foreach (var indexId in IndexIdList)
                {
                    stb.Append("(").Append(" IndexId: ").Append(IndexCacheUtils.GetReadableByteArray(indexId)).Append("),");
                }
            }
            stb.Append("),");

            stb.Append("(").Append("MaxItems: ").Append(MaxItems).Append("),");

            stb.Append("(").Append("ExcludeData: ").Append(ExcludeData).Append("),");

            stb.Append("(").Append("GetIndexHeader: ").Append(GetIndexHeader).Append("),");

            stb.Append("(").Append("GetAdditionalAvailableItemCount: ").Append(GetAdditionalAvailableItemCount).Append("),");

            stb.Append("(").Append("PrimaryIdList").Append(PrimaryIdList == null ? "Null" : PrimaryIdList.Count.ToString());
            if (PrimaryIdList != null && PrimaryIdList.Count > 0)
            {
                foreach (var primaryId in PrimaryIdList)
                {
                    stb.Append("(").Append("PrimaryId: ").Append(primaryId).Append("),");
                }
            }
            stb.Append("),");

            if (Filter == null)
            {
                stb.Append("(").Append("Total Filter Count: ").Append(0);
            }
            else
            {
                stb.Append("(").Append("Total Filter Count: ").Append(Filter.FilterCount).Append(" ").Append("Filter Info - ").Append(Filter.ToString());
            }
            stb.Append("),");
            stb.Append("(").Append("IndexCondition: ").Append(IndexCondition == null ? "Null" : IndexCondition.ToString()).Append("),");
            stb.Append("(").Append("IndexIdParamsMapping Count: ").Append(IndexIdParamsMapping == null ? "Null" : IndexIdParamsMapping.Count.ToString());
            if (IndexIdParamsMapping != null && IndexIdParamsMapping.Count > 0)
            {
                foreach (var indexIdParam in IndexIdParamsMapping)
                {
                    stb.Append("(");
                    stb.Append("(").Append(" IndexId: ").Append(IndexCacheUtils.GetReadableByteArray(indexIdParam.Key)).Append("),");
                    stb.Append("(").Append("IndexIdParams: ").Append(indexIdParam.Value).Append("),");
                    stb.Append("),");
                }
            }
            stb.Append("),");
            stb.Append("(").Append("CapCondition: ").Append(CapCondition == null ? "Null" : CapCondition.ToString()).Append("),");
            stb.Append("(").Append("GetIndexHeaderType: ").Append(GetIndexHeaderType.ToString()).Append("),");
            stb.Append("(").Append("ClientSideSubsetProcessingRequired: ").Append(ClientSideSubsetProcessingRequired).Append("),");
            stb.Append("(").Append("MaxMergeCount: ").Append(MaxMergeCount).Append("),");
            stb.Append("(").Append("DomainSpecificProcessingType: ").Append(DomainSpecificProcessingType).Append("),");
            stb.Append("(").Append("GroupBy: ").Append(GroupBy == null ? "Null" : GroupBy.ToString()).Append("),");

            return(stb.ToString());
        }
        /// <summary>
        /// Gets the CacheIndexInternal.
        /// </summary>
        /// <param name="storeContext">The store context.</param>
        /// <param name="typeId">The type id.</param>
        /// <param name="primaryId">The primary id.</param>
        /// <param name="indexId">The index id.</param>
        /// <param name="extendedIdSuffix">The extended id suffix.</param>
        /// <param name="indexName">Name of the index.</param>
        /// <param name="count">The count.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="inclusiveFilter">if set to <c>true</c> includes the items that pass the filter; otherwise , <c>false</c>.</param>
        /// <param name="indexCondition">The index condition.</param>
        /// <param name="deserializeHeaderOnly">if set to <c>true</c> if just CacheIndexInternal header is to be deserialized; otherwise, <c>false</c>.</param>
        /// <param name="getFilteredItems">if set to <c>true</c> get filtered items; otherwise, <c>false</c>.</param>
        /// <param name="primarySortInfo">The primary sort info.</param>
        /// <param name="localIdentityTagNames">The local identity tag names.</param>
        /// <param name="stringHashCodeDictionary">The string hash code dictionary.</param>
        /// <param name="capCondition">The cap condition.</param>
        /// <returns>CacheIndexInternal</returns>
        internal static CacheIndexInternal GetCacheIndexInternal(IndexStoreContext storeContext,
            short typeId,
            int primaryId,
            byte[] indexId,
            short extendedIdSuffix,
            string indexName,
            int count,
            Filter filter,
            bool inclusiveFilter,
            IndexCondition indexCondition,
            bool deserializeHeaderOnly,
            bool getFilteredItems,
            PrimarySortInfo primarySortInfo,
            List<string> localIdentityTagNames,
            Dictionary<int, bool> stringHashCodeDictionary,
            CapCondition capCondition)
        {
            CacheIndexInternal cacheIndexInternal = null;
            byte[] extendedId = FormExtendedId(indexId, extendedIdSuffix);
            RelayMessage getMsg = new RelayMessage(typeId, primaryId, extendedId, MessageType.Get);
            storeContext.IndexStorageComponent.HandleMessage(getMsg);

            if (getMsg.Payload != null) //CacheIndex exists
            {
                cacheIndexInternal = new CacheIndexInternal
                                         {
                                             InDeserializationContext = new InDeserializationContext
                                                                            {
                                                                                TypeId = getMsg.TypeId,
                                                                                TagHashCollection = storeContext.TagHashCollection,
                                                                                IndexId = indexId,
                                                                                IndexName = indexName,
                                                                                MaxItemsPerIndex = count,
                                                                                Filter = filter,
                                                                                InclusiveFilter = inclusiveFilter,
                                                                                IndexCondition = indexCondition,
                                                                                DeserializeHeaderOnly = deserializeHeaderOnly,
                                                                                CollectFilteredItems = getFilteredItems,
                                                                                PrimarySortInfo = primarySortInfo,
                                                                                LocalIdentityTagNames = localIdentityTagNames,
                                                                                StringHashCollection = storeContext.StringHashCollection,
                                                                                StringHashCodeDictionary = stringHashCodeDictionary,
                                                                                CapCondition = capCondition
                                                                            }
                                         };

                // This mess is required until Moods 2.0 migrated to have IVersionSerializable version of CacheIndexInternal
                // ** TBD - Should be removed later
                if (LegacySerializationUtil.Instance.IsSupported(getMsg.TypeId))
                {
                    MemoryStream stream = new MemoryStream(getMsg.Payload.ByteArray);
                    cacheIndexInternal.Deserialize(new CompactBinaryReader(stream));
                }
                else
                {
                    getMsg.GetObject(cacheIndexInternal);
                }
            }

            return cacheIndexInternal;
        }