public VirtualContainsIndexQuery(byte[] indexId, IndexItem indexItem, string targetIndexName, string cacheTypeName)
     : base(indexId, indexItem, targetIndexName)
 {
     Init(cacheTypeName);
 }
 public VirtualContainsIndexQuery(byte[] indexId, IndexItem indexItem, string targetIndexName, List<string> tagsFromIndexes, bool excludeData, bool getMetadata, string cacheTypeName)
     : base(indexId, indexItem, targetIndexName, tagsFromIndexes, excludeData, getMetadata)
 {
     Init(cacheTypeName);
 }
		public void Deserialize(IPrimitiveReader reader, int version)
		{
            //IndexId
            ushort len = reader.ReadUInt16();
            if (len > 0)
            {
                indexId = reader.ReadBytes(len);
            }

            //IndexItemList
            ushort count = reader.ReadUInt16();
            if (count > 0)
            {
                IndexItem indexItem;
                indexItemList = new List<IndexItem>(count);
                for (ushort i = 0; i < count; i++)
                {
                    indexItem = new IndexItem();
                    indexItem.Deserialize(reader);
                    indexItemList.Add(indexItem);
                }
            }

            //TargetIndexName
            targetIndexName = reader.ReadString();

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

            //ExcludeData
            excludeData = reader.ReadBoolean();

            //GetMetadata
            getMetadata = reader.ReadBoolean();

            if(version >= 2)
            {
                //FullDataIdInfo
                fullDataIdInfo = new FullDataIdInfo();
                Serializer.Deserialize(reader.BaseStream, fullDataIdInfo);
            }
		}
        /// <summary>
        /// Gets the tags.
        /// </summary>
        /// <param name="cacheIndexInternal">The cache index internal.</param>
        /// <param name="searchItem">The search item.</param>
        /// <param name="resultItem">The result item.</param>
        internal static void GetTags(CacheIndexInternal cacheIndexInternal, IndexItem searchItem, IndexItem resultItem)
        {
            int searchIndex = cacheIndexInternal.Search(searchItem);
            if (searchIndex > -1)
            {
                IndexItem tempIndexItem = InternalItemAdapter.ConvertToIndexItem(cacheIndexInternal.GetItem(searchIndex), cacheIndexInternal.InDeserializationContext);

                foreach (KeyValuePair<string, byte[]> kvp in tempIndexItem.Tags)
                {
                    if (!resultItem.Tags.ContainsKey(kvp.Key))
                    {
                        resultItem.Tags.Add(kvp.Key, kvp.Value);
                    }
                }
            }
        }
 public ContainsIndexQuery(byte[] indexId, IndexItem indexItem, string targetIndexName)
 {
     Init(indexId, new List<IndexItem>(1) { indexItem }, targetIndexName, null, false, false, null);
 }
 public ContainsIndexQuery(byte[] indexId, IndexItem indexItem, string targetIndexName, List<string> tagsFromIndexes, bool excludeData, bool getMetadata)
 {
     Init(indexId, new List<IndexItem>(1) {indexItem}, targetIndexName, tagsFromIndexes, excludeData, getMetadata, null);
 }
 /// <summary>
 /// Gets the insert position.
 /// </summary>
 /// <param name="searchItem">The search item.</param>
 /// <param name="sortBy">The sort by.</param>
 /// <param name="comparer">The comparer.</param>
 /// <returns>InsertPosition</returns>
 internal int GetInsertPosition(IndexItem searchItem, SortBy sortBy, InternalItemComparer comparer)
 {
     return InternalItemList.GetInsertPosition(InternalItemAdapter.ConvertToInternalItem(searchItem), comparer, sortBy);
 }
 public IndexDataItem(IndexItem indexItem)
     : base(indexItem.ItemId, indexItem.Tags)
 {
     Init(null);
 }
Esempio n. 9
0
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //IndexId
            ushort len = reader.ReadUInt16();

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

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

            if (count > 0)
            {
                IndexItem indexItem;
                IndexItemList = new List <IndexItem>(count);
                for (ushort i = 0; i < count; i++)
                {
                    indexItem = new IndexItem();
                    indexItem.Deserialize(reader);
                    IndexItemList.Add(indexItem);
                }
            }

            //TargetIndexName
            TargetIndexName = reader.ReadString();

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

            //ExcludeData
            ExcludeData = reader.ReadBoolean();

            //GetMetadata
            GetMetadata = reader.ReadBoolean();

            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);
                }

                //DomainSpecificProcessingType
                DomainSpecificProcessingType = (DomainSpecificProcessingType)reader.ReadByte();
            }
        }
 /// <summary>
 /// Searches the specified search item.
 /// </summary>
 /// <param name="searchItem">The search item.</param>
 /// <returns></returns>
 internal int Search(IndexItem searchItem)
 {
     return InDeserializationContext.PrimarySortInfo.IsTag ?
         InternalItemList.LinearSearch(InternalItemAdapter.ConvertToInternalItem(searchItem), InDeserializationContext.LocalIdentityTagNames) :
         InternalItemList.BinarySearchItem(InternalItemAdapter.ConvertToInternalItem(searchItem),
             InDeserializationContext.PrimarySortInfo.IsTag,
             InDeserializationContext.PrimarySortInfo.FieldName,
             InDeserializationContext.PrimarySortInfo.SortOrderList, InDeserializationContext.LocalIdentityTagNames);
 }
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //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));
                    }
                }
            }

            //IndexItemList
            count = reader.ReadUInt16();
            if (count > 0)
            {
                IndexItem indexItem;
                IndexItemList = new List <IndexItem>(count);
                for (ushort i = 0; i < count; i++)
                {
                    indexItem = new IndexItem();
                    indexItem.Deserialize(reader);
                    IndexItemList.Add(indexItem);
                }
            }

            //TargetIndexName
            TargetIndexName = reader.ReadString();

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

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

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

                        multiIndexContainsQueryParams = null;
                        if (reader.ReadBoolean())
                        {
                            multiIndexContainsQueryParams = new MultiIndexContainsQueryParams();
                            Serializer.Deserialize(reader.BaseStream, multiIndexContainsQueryParams);
                        }

                        MultiIndexContainsQueryParamsMapping.Add(indexId, multiIndexContainsQueryParams);
                    }
                }
            }

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

            //Count
            Count = reader.ReadInt32();

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

            if (version >= 2)
            {
                //DomainSpecificProcessingType
                DomainSpecificProcessingType = (DomainSpecificProcessingType)reader.ReadByte();
            }
        }
Esempio n. 12
0
 public IndexDataItem(IndexItem indexItem)
     : base(indexItem.ItemId, indexItem.Tags)
 {
     Init(null);
 }
Esempio n. 13
0
		public void Deserialize(IPrimitiveReader reader, int version)
		{
			//IndexId
			ushort len = reader.ReadUInt16();
			if (len > 0)
			{
				indexId = reader.ReadBytes(len);
			}

			//TargetIndexName
			targetIndexName = reader.ReadString();

			//IndexTagMapping
			ushort count = reader.ReadUInt16();
			indexTagMapping = new Dictionary<string, List<string>>(count);
			if (count > 0)
			{
				string indexName;
				ushort tagNameListCount;
				List<string> tagNameList;

				for (ushort i = 0; i < count; i++)
				{
					indexName = reader.ReadString();
					tagNameListCount = reader.ReadUInt16();
					tagNameList = new List<string>();
					for (ushort j = 0; j < tagNameListCount; j++)
					{
						tagNameList.Add(reader.ReadString());
					}
					indexTagMapping.Add(indexName, tagNameList);
				}
			}

			//AddList
			int listCount = reader.ReadInt32();
			addList = new List<IndexDataItem>(listCount);
			IndexDataItem indexDataItem;
			for (int i = 0; i < listCount; i++)
			{
				indexDataItem = new IndexDataItem();
				indexDataItem.Deserialize(reader);
				addList.Add(indexDataItem);
			}

			//DeleteList
			listCount = reader.ReadInt32();
			deleteList = new List<IndexItem>(listCount);
			IndexItem indexItem;
			for (int i = 0; i < listCount; i++)
			{
				indexItem = new IndexItem();
				indexItem.Deserialize(reader);
				deleteList.Add(indexItem);
			}

			//Metadata
			len = reader.ReadUInt16();
			if (len > 0)
			{
				metadata = reader.ReadBytes(len);
			}

			//UpdateMetadata
			updateMetadata = reader.ReadBoolean();

			//ReplaceFullIndex
			replaceFullIndex = reader.ReadBoolean();

            if (version >= 2)
            {
                //PreserveData
                preserveData = reader.ReadBoolean();
            }

            if(version >= 3)
            {
                //IndexVirtualCountMapping
                count = reader.ReadUInt16();
                if (count > 0)
                {
                    indexVirtualCountMapping = new Dictionary<string, int>(count);
                    string indexName;
                    int virtualCount;

                    for (ushort i = 0; i < count; i++)
                    {
                        indexName = reader.ReadString();
                        virtualCount = reader.ReadInt32();
                        indexVirtualCountMapping.Add(indexName, virtualCount);
                    }
                }
            }

            if (version >= 4)
            {
                //PrimaryId
                primaryId = reader.ReadInt32();
            }
		}
Esempio n. 14
0
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            //IndexId
            ushort len = reader.ReadUInt16();

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

            //TargetIndexName
            targetIndexName = reader.ReadString();

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

            indexTagMapping = new Dictionary <string, List <string> >(count);
            if (count > 0)
            {
                string        indexName;
                ushort        tagNameListCount;
                List <string> tagNameList;

                for (ushort i = 0; i < count; i++)
                {
                    indexName        = reader.ReadString();
                    tagNameListCount = reader.ReadUInt16();
                    tagNameList      = new List <string>();
                    for (ushort j = 0; j < tagNameListCount; j++)
                    {
                        tagNameList.Add(reader.ReadString());
                    }
                    indexTagMapping.Add(indexName, tagNameList);
                }
            }

            //AddList
            int listCount = reader.ReadInt32();

            addList = new List <IndexDataItem>(listCount);
            IndexDataItem indexDataItem;

            for (int i = 0; i < listCount; i++)
            {
                indexDataItem = new IndexDataItem();
                indexDataItem.Deserialize(reader);
                addList.Add(indexDataItem);
            }

            //DeleteList
            listCount  = reader.ReadInt32();
            deleteList = new List <IndexItem>(listCount);
            IndexItem indexItem;

            for (int i = 0; i < listCount; i++)
            {
                indexItem = new IndexItem();
                indexItem.Deserialize(reader);
                deleteList.Add(indexItem);
            }

            //Metadata
            len = reader.ReadUInt16();
            if (len > 0)
            {
                metadata = reader.ReadBytes(len);
            }

            //UpdateMetadata
            updateMetadata = reader.ReadBoolean();

            //ReplaceFullIndex
            replaceFullIndex = reader.ReadBoolean();

            if (version >= 2)
            {
                //PreserveData
                preserveData = reader.ReadBoolean();
            }

            if (version >= 3)
            {
                //IndexVirtualCountMapping
                count = reader.ReadUInt16();
                if (count > 0)
                {
                    indexVirtualCountMapping = new Dictionary <string, int>(count);
                    string indexName;
                    int    virtualCount;

                    for (ushort i = 0; i < count; i++)
                    {
                        indexName    = reader.ReadString();
                        virtualCount = reader.ReadInt32();
                        indexVirtualCountMapping.Add(indexName, virtualCount);
                    }
                }
            }

            if (version >= 4)
            {
                //PrimaryId
                primaryId = reader.ReadInt32();
            }
        }
 /// <summary>
 /// Converts IndexItem to an InternalItem.
 /// </summary>
 /// <param name="indexItem">The index item.</param>
 /// <returns></returns>
 internal static InternalItem ConvertToInternalItem(IndexItem indexItem)
 {
     return new InternalItem {ItemId = indexItem.ItemId, TagList = ConvertToTagList(indexItem.Tags)};
 }