Example #1
0
        public virtual void Deserialize(IPrimitiveReader reader, int version)
        {
            //TargetIndexName
            TargetIndexName = reader.ReadString();

            //IndexIdList
            ushort 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));
                    }
                }
            }

            //ExcludeData
            ExcludeData = reader.ReadBoolean();

            //GetIndexHeader
            GetIndexHeader = 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)
            {
                intersectionQueryParamsMapping = new Dictionary <byte[], IntersectionQueryParams>(count, new ByteArrayEqualityComparer());
                byte[] indexId;
                IntersectionQueryParams intersectionQueryParam;
                ushort len;

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

                        intersectionQueryParam = new IntersectionQueryParams();
                        Serializer.Deserialize(reader.BaseStream, intersectionQueryParam);

                        intersectionQueryParamsMapping.Add(indexId, intersectionQueryParam);
                    }
                }
            }

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

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

                //Count
                Count = reader.ReadInt32();

                //MaxResultItems
                MaxResultItems = reader.ReadInt32();


                //CanApplyMaxResultItemsOnServer
                IsSingleClusterQuery = reader.ReadBoolean();

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

            if (version >= 4)
            {
                //DomainSpecificProcessingType
                DomainSpecificProcessingType = (DomainSpecificProcessingType)reader.ReadByte();
            }
        }
        /// <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;
        }
Example #3
0
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //IndexId
            ushort len = reader.ReadUInt16();

            if (len > 0)
            {
                IndexId = reader.ReadBytes(len);
            }

            //FirstPageSize
            FirstPageSize = reader.ReadInt32();

            //LastPageSize
            LastPageSize = reader.ReadInt32();

            //TargetIndexName
            TargetIndexName = reader.ReadString();

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

            //ExcludeData
            ExcludeData = reader.ReadBoolean();

            //GetMetadata
            GetMetadata = reader.ReadBoolean();

            if (version >= 2)
            {
                //Filter
                byte b = reader.ReadByte();
                if (b != 0)
                {
                    FilterType filterType = (FilterType)b;
                    Filter = FilterFactory.CreateFilter(reader, filterType);
                }
            }

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

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

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

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

            if (version >= 6)
            {
                //DomainSpecificProcessingType
                DomainSpecificProcessingType = (DomainSpecificProcessingType)reader.ReadByte();
            }
        }