コード例 #1
0
        /// <summary>
        /// Gets the metadata when its stored seperately.
        /// </summary>
        /// <param name="indexTypeMapping">The index type mapping.</param>
        /// <param name="typeId">The type id.</param>
        /// <param name="primaryId">The primary id.</param>
        /// <param name="extendedId">The extended id.</param>
        /// <param name="storeContext">The store context.</param>
        /// <param name="metadata">The Metadata.</param>
        /// <param name="metadataPropertyCollection">The MetadataPropertyCollection.</param>
        internal static void GetMetadataStoredSeperately(IndexTypeMapping indexTypeMapping,
                                                         short typeId,
                                                         int primaryId,
                                                         byte[] extendedId,
                                                         IndexStoreContext storeContext,
                                                         out byte[] metadata,
                                                         out MetadataPropertyCollection metadataPropertyCollection)
        {
            metadata = null;
            metadataPropertyCollection = null;

            byte[] metadataBytes = BinaryStorageAdapter.Get(storeContext.IndexStorageComponent, typeId, primaryId, extendedId);

            if (metadataBytes != null)
            {
                if (indexTypeMapping.IsMetadataPropertyCollection)
                {
                    metadataPropertyCollection = GetMetadataPropertyCollection(metadataBytes);
                }
                else
                {
                    metadata = metadataBytes;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the MetadataPropertyCollection from raw byte array
        /// </summary>
        /// <param name="msg">The RelayMessage.</param>
        /// <returns></returns>
        internal static MetadataPropertyCollection GetMetadataPropertyCollection(RelayMessage msg)
        {
            MetadataPropertyCollection metadataPropertyCollection = null;

            if (msg.Payload != null)
            {
                metadataPropertyCollection = new MetadataPropertyCollection();
                msg.GetObject(metadataPropertyCollection);
            }
            return(metadataPropertyCollection);
        }
コード例 #3
0
        /// <summary>
        /// Gets the MetadataPropertyCollection from raw byte array
        /// </summary>
        /// <param name="payload">The RelayMessage.</param>
        /// <returns></returns>
        internal static MetadataPropertyCollection GetMetadataPropertyCollection(byte[] payload)
        {
            MetadataPropertyCollection metadataPropertyCollection = new MetadataPropertyCollection();

            if (payload != null)
            {
                MemoryStream stream = new MemoryStream(payload);
                Serializer.Deserialize(stream, metadataPropertyCollection);
            }

            return(metadataPropertyCollection);
        }
コード例 #4
0
 private void toolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (propertiesEditor != null)
     {
         if (saveMetadata.ShowDialog() == DialogResult.OK)
         {
             MetadataPropertyCollection changedProperties = propertiesEditor.GetProperties();
             FormatBase      format         = GroupDocs.Metadata.Tools.FormatFactory.RecognizeFormat(openFileDialog.FileName);
             IDocumentFormat documentFormat = format as IDocumentFormat;
             documentFormat.SetProperties(changedProperties);
             format.Save(saveMetadata.FileName);
         }
     }
 }
コード例 #5
0
ファイル: FilterUtil.cs プロジェクト: wilson0x4d/DataRelay
        /// <summary>
        /// Processes the filter.
        /// </summary>
        /// <param name="internalItem">The internal item.</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="tagHashCollection">The TagHashCollection.</param>
        /// <param name="metadataPropertyCollection">The MetadataPropertyCollection.</param>
        /// <returns><c>true</c> if item passes the filter; otherwise, <c>false</c></returns>
        internal static bool ProcessFilter(InternalItem internalItem,
                                           Filter filter,
                                           bool inclusiveFilter,
                                           TagHashCollection tagHashCollection,
                                           MetadataPropertyCollection metadataPropertyCollection)
        {
            bool retVal = DoProcessFilter(internalItem, filter, tagHashCollection, metadataPropertyCollection);

            if (inclusiveFilter)
            {
                return(retVal);
            }
            return(!retVal);
        }
コード例 #6
0
ファイル: FilterUtil.cs プロジェクト: wilson0x4d/DataRelay
        /// <summary>
        /// Processes the condition.
        /// </summary>
        /// <param name="internalItem">The internal item.</param>
        /// <param name="condition">The condition.</param>
        /// <param name="metadataPropertyCollection">The MetadataPropertyCollection.</param>
        /// <returns><c>true</c> if item passes the condition; otherwise, <c>false</c></returns>
        private static bool ProcessCondition(InternalItem internalItem,
                                             Condition condition,
                                             MetadataPropertyCollection metadataPropertyCollection)
        {
            IndexCacheUtils.ProcessMetadataPropertyCondition(condition, metadataPropertyCollection);

            if (condition.IsTag)
            {
                byte[] tagValue;
                internalItem.TryGetTagValue(condition.FieldName, out tagValue);
                return(condition.Process(tagValue));
            }
            return(condition.Process(internalItem.ItemId));
        }
コード例 #7
0
        internal InDeserializationContext(int maxItemsPerIndex,
                                          string indexName,
                                          byte[] indexId,
                                          short typeId,
                                          Filter filter,
                                          bool inclusiveFilter,
                                          TagHashCollection tagHashCollection,
                                          bool deserializeHeaderOnly,
                                          bool collectFilteredItems,
                                          PrimarySortInfo primarySortInfo,
                                          List <string> localIdentityTagNames,
                                          StringHashCollection stringHashCollection,
                                          Dictionary <int, bool> stringHashCodeDictionary,
                                          IndexCondition indexCondition,
                                          CapCondition capCondition,
                                          bool isMetadataPropertyCollection,
                                          MetadataPropertyCollection metadataPropertyCollection,
                                          DomainSpecificProcessingType domainSpecificProcessingType,
                                          DomainSpecificConfig domainSpecificConfig,
                                          string getDistinctValuesFieldName,
                                          GroupBy groupBy)
        {
            MaxItemsPerIndex             = maxItemsPerIndex;
            IndexName                    = indexName;
            IndexId                      = indexId;
            TypeId                       = typeId;
            Filter                       = filter;
            InclusiveFilter              = inclusiveFilter;
            TagHashCollection            = tagHashCollection;
            DeserializeHeaderOnly        = deserializeHeaderOnly;
            CollectFilteredItems         = collectFilteredItems;
            PrimarySortInfo              = primarySortInfo;
            LocalIdentityTagNames        = localIdentityTagNames;
            StringHashCollection         = stringHashCollection;
            StringHashCodeDictionary     = stringHashCodeDictionary;
            IndexCondition               = indexCondition;
            CapCondition                 = capCondition;
            IsMetadataPropertyCollection = isMetadataPropertyCollection;
            MetadataPropertyCollection   = metadataPropertyCollection;
            DomainSpecificProcessingType = domainSpecificProcessingType;
            DomainSpecificConfig         = domainSpecificConfig;
            GetDistinctValuesFieldName   = getDistinctValuesFieldName;
            GroupBy                      = groupBy;

            SetEnterExitCondition();
        }
        public void LoadControl(MetadataPropertyCollection metadataCollection)
        {
            List<PropertyItem> values = new List<PropertyItem>();
            foreach (MetadataProperty prop in metadataCollection)
            {
                if (prop.Value == null)
                {
                    continue;
                }

                if (prop.Value.Type != MetadataPropertyType.String)
                {
                    continue;
                }

                values.Add(new PropertyItem(prop.Name, prop.Value.ToString(), prop.IsBuiltInProperty));
            }
            gridDocumentProperties.DataSource = values;
        }
コード例 #9
0
ファイル: FilterUtil.cs プロジェクト: wilson0x4d/DataRelay
        /// <summary>
        /// Processes the aggregate filter.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="internalItem">The internal item.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="tagHashCollection">The TagHashCollection.</param>
        /// <param name="metadataPropertyCollection">The MetadataPropertyCollection.</param>
        /// <returns><c>true</c> if item passes the filter; otherwise, <c>false</c></returns>
        private static bool ProcessAggregateFilter <T>(InternalItem internalItem,
                                                       T filter,
                                                       TagHashCollection tagHashCollection,
                                                       MetadataPropertyCollection metadataPropertyCollection)
            where T : AggregateFilter
        {
            bool          retVal = !filter.ShortCircuitHint;
            List <Filter> later  = new List <Filter>();

            // evaluate root level items first
            for (ushort i = 0; i < filter.Count; i++)
            {
                if (filter[i] is Condition)
                {
                    // evaluate now
                    retVal = DoProcessFilter(internalItem, filter[i], tagHashCollection, metadataPropertyCollection);
                    if (retVal == filter.ShortCircuitHint)
                    {
                        break;
                    }
                }
                else
                {
                    // evaluate later
                    later.Add(filter[i]);
                }
            }

            // No need to evaluate aggreate filters if result already obtained.
            if (retVal != filter.ShortCircuitHint)
            {
                foreach (Filter f in later)
                {
                    retVal = DoProcessFilter(internalItem, f, tagHashCollection, metadataPropertyCollection);
                    if (retVal == filter.ShortCircuitHint)
                    {
                        break;
                    }
                }
            }
            return(retVal);
        }
コード例 #10
0
            /// <summary>
            /// Searches metadata in document
            /// </summary>
            public static void SearchMetadata(string filePath, string propertyName, SearchCondition searchCondition)
            {
                try
                {
                    //ExStart:DocumentSearchAPI
                    filePath = Common.MapSourceFilePath(filePath);

                    MetadataPropertyCollection properties = SearchFacade.ScanDocument(filePath, propertyName, searchCondition);

                    foreach (MetadataProperty property in properties)
                    {
                        Console.WriteLine("{0} : {1}", property.Name, property.Value);
                    }
                    //ExEnd:DocumentSearchAPI
                }
                catch (Exception exp)
                {
                    Console.WriteLine("Exception occurred: " + exp.Message);
                }
            }
コード例 #11
0
        public void LoadControl(MetadataPropertyCollection metadataCollection)
        {
            List <PropertyItem> values = new List <PropertyItem>();

            foreach (MetadataProperty prop in metadataCollection)
            {
                if (prop.Value == null)
                {
                    continue;
                }

                if (prop.Value.Type != MetadataPropertyType.String)
                {
                    continue;
                }

                values.Add(new PropertyItem(prop.Name, prop.Value.ToString(), prop.IsBuiltInProperty));
            }
            gridDocumentProperties.DataSource = values;
        }
コード例 #12
0
            /// <summary>
            /// Compares metadata of two documents and displays result
            /// </summary>
            public static void CompareDocument(string firstDocument, string secondDocument, ComparerSearchType type)
            {
                try
                {
                    //ExStart:ComparisonAPI
                    firstDocument  = Common.MapSourceFilePath(firstDocument);
                    secondDocument = Common.MapSourceFilePath(secondDocument);

                    MetadataPropertyCollection differences = ComparisonFacade.CompareDocuments(firstDocument, secondDocument, type);

                    foreach (MetadataProperty property in differences)
                    {
                        Console.WriteLine("{0} : {1}", property.Name, property.Value);
                    }
                    //ExEnd:ComparisonAPI
                }
                catch (Exception exp)
                {
                    Console.WriteLine("Exception occurred: " + exp.Message);
                }
            }
コード例 #13
0
 /// <summary>
 /// Gets the metadata when its stored along with the index.
 /// </summary>
 /// <param name="internalCacheIndexList">The internal cache index list.</param>
 /// <param name="indexTypeMapping">The index type mapping.</param>
 /// <param name="metadata">The Metadata.</param>
 /// <param name="metadataPropertyCollection">The MetadataPropertyCollection.</param>
 internal static void GetMetadataStoredWithIndex(IndexTypeMapping indexTypeMapping,
                                                 List <CacheIndexInternal> internalCacheIndexList,
                                                 out byte[] metadata,
                                                 out MetadataPropertyCollection metadataPropertyCollection)
 {
     metadata = null;
     metadataPropertyCollection = null;
     foreach (CacheIndexInternal cacheIndexInternal in internalCacheIndexList)
     {
         Index indexInfo = indexTypeMapping.IndexCollection[cacheIndexInternal.InDeserializationContext.IndexName];
         if (indexInfo.MetadataPresent)
         {
             if (indexInfo.IsMetadataPropertyCollection)
             {
                 metadataPropertyCollection = cacheIndexInternal.MetadataPropertyCollection;
             }
             else
             {
                 metadata = cacheIndexInternal.Metadata;
             }
         }
     }
 }
コード例 #14
0
        //ExEnd:FormatRecognizer

        //ExStart:MetadataComparer
        /// <summary>
        /// Compares and finds metadata difference of two files
        /// </summary>
        /// <param name="filePath1">First file path</param>
        /// <param name="filePath2">Second file path</param>
        public static void CompareFilesMetadata(string filePath1, string filePath2)
        {
            try
            {
                // path to the document
                filePath1 = Common.MapSourceFilePath(filePath1);

                // path to the compared document
                filePath2 = Common.MapSourceFilePath(filePath2);

                // get diffences between metadata
                MetadataPropertyCollection diffenceProperties = MetadataUtility.CompareDoc(filePath1, filePath2);

                // go through collection and show differences
                foreach (MetadataProperty property in diffenceProperties)
                {
                    Console.WriteLine("Property = {0}, value = {1}", property.Name, property.Value);
                }
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
コード例 #15
0
ファイル: FilterUtil.cs プロジェクト: wilson0x4d/DataRelay
        /// <summary>
        /// Does the process filter.
        /// </summary>
        /// <param name="internalItem">The internal item.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="tagHashCollection">The TagHashCollection.</param>
        /// <param name="metadataPropertyCollection">The MetadataPropertyCollection.</param>
        /// <returns><c>true</c> if item passes the filter; otherwise, <c>false</c></returns>
        private static bool DoProcessFilter(InternalItem internalItem,
                                            Filter filter,
                                            TagHashCollection tagHashCollection,
                                            MetadataPropertyCollection metadataPropertyCollection)
        {
            bool retVal = false;

            switch (filter.FilterType)
            {
            case FilterType.Condition:
                retVal = ProcessCondition(internalItem, filter as Condition, metadataPropertyCollection);
                break;

            case FilterType.And:
                retVal = ProcessAggregateFilter(internalItem, filter as AndFilter, tagHashCollection, metadataPropertyCollection);
                break;

            case FilterType.Or:
                retVal = ProcessAggregateFilter(internalItem, filter as OrFilter, tagHashCollection, metadataPropertyCollection);
                break;
            }

            return(retVal);
        }
コード例 #16
0
        /// <summary>
        /// Processes the specified filtered index delete command.
        /// </summary>
        /// <param name="filteredIndexDeleteCommand">The filtered index delete command.</param>
        /// <param name="messageContext">The message context.</param>
        /// <param name="storeContext">The store context.</param>
        internal static void Process(
            FilteredIndexDeleteCommand filteredIndexDeleteCommand,
            MessageContext messageContext,
            IndexStoreContext storeContext)
        {
            if (filteredIndexDeleteCommand != null)
            {
                IndexTypeMapping indexTypeMapping =
                    storeContext.StorageConfiguration.CacheIndexV3StorageConfig.IndexTypeMappingCollection[messageContext.TypeId];
                Index  indexInfo = indexTypeMapping.IndexCollection[filteredIndexDeleteCommand.TargetIndexName];
                byte[] metadata  = null;
                MetadataPropertyCollection metadataPropertyCollection = null;

                #region Get CacheIndexInternal for TargetIndexName

                if (indexTypeMapping.MetadataStoredSeperately)
                {
                    IndexServerUtils.GetMetadataStoredSeperately(indexTypeMapping,
                                                                 messageContext.TypeId,
                                                                 messageContext.PrimaryId,
                                                                 filteredIndexDeleteCommand.IndexId,
                                                                 storeContext,
                                                                 out metadata,
                                                                 out metadataPropertyCollection);
                }

                CacheIndexInternal cacheIndexInternal = IndexServerUtils.GetCacheIndexInternal(storeContext,
                                                                                               messageContext.TypeId,
                                                                                               filteredIndexDeleteCommand.PrimaryId,
                                                                                               filteredIndexDeleteCommand.IndexId,
                                                                                               indexInfo.ExtendedIdSuffix,
                                                                                               filteredIndexDeleteCommand.TargetIndexName,
                                                                                               0,
                                                                                               filteredIndexDeleteCommand.DeleteFilter,
                                                                                               false,
                                                                                               null,
                                                                                               false,
                                                                                               true,
                                                                                               indexInfo.PrimarySortInfo,
                                                                                               indexInfo.LocalIdentityTagList,
                                                                                               indexInfo.StringHashCodeDictionary,
                                                                                               null,
                                                                                               indexInfo.IsMetadataPropertyCollection,
                                                                                               metadataPropertyCollection,
                                                                                               DomainSpecificProcessingType.None,
                                                                                               null,
                                                                                               null,
                                                                                               null,
                                                                                               false);

                #endregion

                if (cacheIndexInternal != null)
                {
                    #region Increment perf counters' number

                    PerformanceCounters.Instance.SetCounterValue(
                        PerformanceCounterEnum.NumOfItemsInIndexPerFilterDeleteRequest,
                        messageContext.TypeId,
                        cacheIndexInternal.OutDeserializationContext.TotalCount);

                    PerformanceCounters.Instance.SetCounterValue(
                        PerformanceCounterEnum.NumOfItemsReadPerFilterDeleteRequest,
                        messageContext.TypeId,
                        cacheIndexInternal.OutDeserializationContext.ReadItemCount);

                    PerformanceCounters.Instance.SetCounterValue(
                        PerformanceCounterEnum.NumOfItemsFilteredPerFilterDeleteRequest,
                        messageContext.TypeId,
                        (cacheIndexInternal.OutDeserializationContext.TotalCount - cacheIndexInternal.OutDeserializationContext.FilteredInternalItemList.Count));

                    #endregion

                    #region Update VirtualCount

                    cacheIndexInternal.VirtualCount -= (cacheIndexInternal.OutDeserializationContext.TotalCount - cacheIndexInternal.Count);

                    #endregion

                    #region Save CacheIndexInternal to local storage since item which pass delete filter are pruned in it

                    byte[] extendedId = IndexServerUtils.FormExtendedId(filteredIndexDeleteCommand.IndexId,
                                                                        indexTypeMapping.IndexCollection[cacheIndexInternal.InDeserializationContext.IndexName].ExtendedIdSuffix);

                    // compose a bdb entry header
                    bool isCompress = storeContext.GetCompressOption(messageContext.TypeId);

                    PayloadStorage bdbEntryHeader = new PayloadStorage
                    {
                        Compressed       = isCompress,
                        TTL              = -1,
                        LastUpdatedTicks = DateTime.Now.Ticks,
                        ExpirationTicks  = -1,
                        Deactivated      = false
                    };

                    BinaryStorageAdapter.Save(
                        storeContext.MemoryPool,
                        storeContext.IndexStorageComponent,
                        messageContext.TypeId,
                        filteredIndexDeleteCommand.PrimaryId,
                        extendedId,
                        bdbEntryHeader,
                        Serializer.Serialize <CacheIndexInternal>(cacheIndexInternal, isCompress, RelayMessage.RelayCompressionImplementation));

                    #endregion

                    #region Data store deletes

                    if (DataTierUtil.ShouldForwardToDataTier(messageContext.RelayTTL,
                                                             messageContext.SourceZone,
                                                             storeContext.MyZone,
                                                             indexTypeMapping.IndexServerMode) &&
                        cacheIndexInternal.OutDeserializationContext.FilteredInternalItemList != null &&
                        cacheIndexInternal.OutDeserializationContext.FilteredInternalItemList.Count > 0)
                    {
                        List <RelayMessage> dataStorageMessageList = new List <RelayMessage>();

                        short relatedTypeId;
                        if (!storeContext.TryGetRelatedIndexTypeId(messageContext.TypeId, out relatedTypeId))
                        {
                            LoggingUtil.Log.ErrorFormat("Invalid RelatedTypeId for TypeId - {0}", messageContext.TypeId);
                            throw new Exception("Invalid RelatedTypeId for TypeId - " + messageContext.TypeId);
                        }
                        cacheIndexInternal.InternalItemList = cacheIndexInternal.OutDeserializationContext.FilteredInternalItemList;
                        List <byte[]> fullDataIdList = DataTierUtil.GetFullDataIds(cacheIndexInternal.InDeserializationContext.IndexId,
                                                                                   cacheIndexInternal.InternalItemList,
                                                                                   indexTypeMapping.FullDataIdFieldList);

                        foreach (byte[] fullDataId in fullDataIdList)
                        {
                            if (fullDataId != null)
                            {
                                dataStorageMessageList.Add(new RelayMessage(relatedTypeId,
                                                                            IndexCacheUtils.GeneratePrimaryId(fullDataId),
                                                                            fullDataId,
                                                                            MessageType.Delete));
                            }
                        }

                        if (dataStorageMessageList.Count > 0)
                        {
                            storeContext.ForwarderComponent.HandleMessages(dataStorageMessageList);
                        }
                    }

                    #endregion
                }
            }
        }
コード例 #17
0
        /// <summary>
        /// Deserialize the class data from a stream.
        /// </summary>
        /// <param name="reader">The <see cref="IPrimitiveReader"/> that extracts used to extra data from a stream.</param>
        /// <param name="version">The value of <see cref="CurrentVersion"/> that was written to the stream when it was originally serialized to a stream;
        /// the version of the <paramref name="reader"/> data.</param>
        public void Deserialize(IPrimitiveReader reader, int version)
        {
            ushort len;

            //Metadata or MetadataPropertyCollection
            if (InDeserializationContext.IsMetadataPropertyCollection)
            {
                //MetadataPropertyCollection
                len = reader.ReadUInt16();
                if (len > 0)
                {
                    MetadataPropertyCollection = new MetadataPropertyCollection();
                    string propertyName;
                    byte[] propertyValue;
                    ushort propertyValueLen;

                    for (ushort i = 0; i < len; i++)
                    {
                        propertyName     = reader.ReadString();
                        propertyValueLen = reader.ReadUInt16();
                        propertyValue    = null;
                        if (propertyValueLen > 0)
                        {
                            propertyValue = reader.ReadBytes(propertyValueLen);
                        }
                        MetadataPropertyCollection.Add(propertyName, propertyValue);
                    }
                }
            }
            else
            {
                //Metadata
                len = reader.ReadUInt16();
                if (len > 0)
                {
                    Metadata = reader.ReadBytes(len);
                }
            }

            //VirtualCount
            if (version >= 2)
            {
                virtualCount = reader.ReadInt32();
            }

            //Count
            outDeserializationContext = new OutDeserializationContext {
                TotalCount = reader.ReadInt32()
            };

            if (InDeserializationContext.DeserializeHeaderOnly)
            {
                //Note: If InDeserializationContext.DeserializeHeaderOnly property is set then InDeserializationContext.PartialByteArray shall hold all CacheIndexInternal
                //payload except metadata and header (just virtual count for now). This code path will only be used if just
                //header info like virtual count needs to be updated keeping rest of the index untouched.
                //InDeserializationContext.PartialByteArray shall be used in Serialize code
                outDeserializationContext.UnserializedCacheIndexInternal =
                    new byte[(int)reader.BaseStream.Length - (int)reader.BaseStream.Position];
                reader.BaseStream.Read(outDeserializationContext.UnserializedCacheIndexInternal, 0, outDeserializationContext.UnserializedCacheIndexInternal.Length);
            }
            else
            {
                int actualItemCount = outDeserializationContext.TotalCount;

                //this.InDeserializationContext.MaxItemsPerIndex = 0 indicates need to extract all items
                //this.InDeserializationContext.MaxItemsPerIndex > 0 indicates need to extract only number of items indicated by InDeserializationContext.MaxItemsPerIndex
                if (InDeserializationContext.MaxItemsPerIndex > 0)
                {
                    if (InDeserializationContext.MaxItemsPerIndex < outDeserializationContext.TotalCount)
                    {
                        actualItemCount = InDeserializationContext.MaxItemsPerIndex;
                    }
                }

                #region Populate InternalItemList

                InternalItem internalItem;
                bool         enterConditionPassed = false;

                InternalItemList = new InternalItemList();
                GroupByResult    = new GroupByResult(new BaseComparer(InDeserializationContext.PrimarySortInfo.IsTag, InDeserializationContext.PrimarySortInfo.FieldName, InDeserializationContext.PrimarySortInfo.SortOrderList));

                // Note: ---- Termination condition of the loop
                // For full index extraction loop shall terminate because of condition : internalItemList.Count + GroupByResult.Count < actualItemCount
                // For partial index extraction loop shall terminate because of following conditions
                //				a)  i < InDeserializationContext.TotalCount (when no sufficient items are found) OR
                //				b)  internalItemList.Count < actualItemCount (Item extraction cap is reached)
                int i = 0;
                while (GroupByResult.Count + InternalItemList.Count < actualItemCount && i < outDeserializationContext.TotalCount)
                {
                    i++;

                    #region Deserialize ItemId

                    len = reader.ReadUInt16();
                    if (len > 0)
                    {
                        internalItem = new InternalItem
                        {
                            ItemId = reader.ReadBytes(len)
                        };
                    }
                    else
                    {
                        throw new Exception("Invalid ItemId - is null or length is zero for IndexId : " +
                                            IndexCacheUtils.GetReadableByteArray(InDeserializationContext.IndexId));
                    }

                    #endregion

                    #region Process IndexCondition
                    if (InDeserializationContext.EnterCondition != null || InDeserializationContext.ExitCondition != null)
                    {
                        #region Have Enter/Exit Condition

                        if (InDeserializationContext.PrimarySortInfo.IsTag == false)
                        {
                            #region Sort by ItemId

                            if (InDeserializationContext.EnterCondition != null && enterConditionPassed == false)
                            {
                                #region enter condition processing

                                if (FilterPassed(internalItem, InDeserializationContext.EnterCondition))
                                {
                                    if (InDeserializationContext.ExitCondition != null && !FilterPassed(internalItem, InDeserializationContext.ExitCondition))
                                    {
                                        // no need to search beyond this point
                                        break;
                                    }

                                    enterConditionPassed = true;
                                    DeserializeTags(internalItem, InDeserializationContext, OutDeserializationContext, reader);
                                    ApplyFilterAndAddItem(internalItem);
                                }
                                else
                                {
                                    SkipDeserializeInternalItem(reader);
                                    // no filter processing required
                                }

                                #endregion
                            }
                            else if (InDeserializationContext.ExitCondition != null)
                            {
                                #region exit condition processing

                                if (FilterPassed(internalItem, InDeserializationContext.ExitCondition))
                                {
                                    // since item passed exit filter, we keep it.
                                    DeserializeTags(internalItem, InDeserializationContext, OutDeserializationContext, reader);
                                    ApplyFilterAndAddItem(internalItem);
                                }
                                else
                                {
                                    // no need to search beyond this point
                                    break;
                                }

                                #endregion
                            }
                            else if (InDeserializationContext.EnterCondition != null && enterConditionPassed && InDeserializationContext.ExitCondition == null)
                            {
                                #region enter condition processing when no exit condition exists

                                DeserializeTags(internalItem, InDeserializationContext, OutDeserializationContext, reader);
                                ApplyFilterAndAddItem(internalItem);

                                #endregion
                            }

                            #endregion
                        }
                        else
                        {
                            #region Sort by Tag

                            #region Deserialize InternalItem and fetch PrimarySortTag value

                            byte[] tagValue;
                            DeserializeTags(internalItem, InDeserializationContext, OutDeserializationContext, reader);
                            if (!internalItem.TryGetTagValue(InDeserializationContext.PrimarySortInfo.FieldName, out tagValue))
                            {
                                throw new Exception("PrimarySortTag Not found:  " + InDeserializationContext.PrimarySortInfo.FieldName);
                            }

                            #endregion

                            if (InDeserializationContext.EnterCondition != null && enterConditionPassed == false)
                            {
                                #region enter condition processing

                                if (FilterPassed(internalItem, InDeserializationContext.EnterCondition))
                                {
                                    if (InDeserializationContext.ExitCondition != null && !FilterPassed(internalItem, InDeserializationContext.ExitCondition))
                                    {
                                        // no need to search beyond this point
                                        break;
                                    }

                                    enterConditionPassed = true;
                                    ApplyFilterAndAddItem(internalItem);
                                }

                                #endregion
                            }
                            else if (InDeserializationContext.ExitCondition != null)
                            {
                                #region exit condition processing

                                if (FilterPassed(internalItem, InDeserializationContext.ExitCondition))
                                {
                                    // since item passed exit filter, we keep it.
                                    ApplyFilterAndAddItem(internalItem);
                                }
                                else
                                {
                                    // no need to search beyond this point
                                    break;
                                }

                                #endregion
                            }
                            else if (InDeserializationContext.EnterCondition != null && enterConditionPassed && InDeserializationContext.ExitCondition == null)
                            {
                                #region enter condition processing when no exit condition exists

                                ApplyFilterAndAddItem(internalItem);

                                #endregion
                            }

                            #endregion
                        }

                        #endregion
                    }
                    else
                    {
                        #region No Enter/Exit Condition

                        DeserializeTags(internalItem, InDeserializationContext, OutDeserializationContext, reader);
                        ApplyFilterAndAddItem(internalItem);

                        #endregion
                    }

                    #endregion
                }

                //Set ReadItemCount on OutDeserializationContext
                outDeserializationContext.ReadItemCount = i;

                #endregion
            }
        }
コード例 #18
0
        /// <summary>
        /// Processes the specified first last query.
        /// </summary>
        /// <param name="firstLastQuery">The first last query.</param>
        /// <param name="messageContext">The message context.</param>
        /// <param name="storeContext">The store context.</param>
        /// <returns>FirstLastQueryResult</returns>
        internal static FirstLastQueryResult Process(FirstLastQuery firstLastQuery, MessageContext messageContext, IndexStoreContext storeContext)
        {
            FirstLastQueryResult firstLastQueryResult;
            List <ResultItem>    firstPageResultItemList = null;
            List <ResultItem>    lastPageResultItemList  = null;
            bool indexExists  = false;
            int  indexSize    = -1;
            int  virtualCount = -1;

            byte[] metadata = null;
            MetadataPropertyCollection metadataPropertyCollection = null;

            try
            {
                IndexTypeMapping indexTypeMapping =
                    storeContext.StorageConfiguration.CacheIndexV3StorageConfig.IndexTypeMappingCollection[messageContext.TypeId];

                #region Validate Query

                ValidateQuery(indexTypeMapping, firstLastQuery);

                #endregion

                int maxItemsPerIndex = ((firstLastQuery.FirstPageSize > 0) && (firstLastQuery.LastPageSize < 1))
                                           ? firstLastQuery.FirstPageSize
                                           : int.MaxValue;

                Index targetIndexInfo = indexTypeMapping.IndexCollection[firstLastQuery.TargetIndexName];
                int   indexCap        = targetIndexInfo.MaxIndexSize;

                #region Prepare Result

                #region Extract index and apply criteria

                if (indexTypeMapping.MetadataStoredSeperately)
                {
                    IndexServerUtils.GetMetadataStoredSeperately(indexTypeMapping,
                                                                 messageContext.TypeId,
                                                                 messageContext.PrimaryId,
                                                                 firstLastQuery.IndexId,
                                                                 storeContext,
                                                                 out metadata,
                                                                 out metadataPropertyCollection);
                }

                CacheIndexInternal targetIndex = IndexServerUtils.GetCacheIndexInternal(storeContext,
                                                                                        messageContext.TypeId,
                                                                                        messageContext.PrimaryId,
                                                                                        firstLastQuery.IndexId,
                                                                                        targetIndexInfo.ExtendedIdSuffix,
                                                                                        firstLastQuery.TargetIndexName,
                                                                                        maxItemsPerIndex,
                                                                                        firstLastQuery.Filter,
                                                                                        true,
                                                                                        firstLastQuery.IndexCondition,
                                                                                        false,
                                                                                        false,
                                                                                        targetIndexInfo.PrimarySortInfo,
                                                                                        targetIndexInfo.LocalIdentityTagList,
                                                                                        targetIndexInfo.StringHashCodeDictionary,
                                                                                        null,
                                                                                        targetIndexInfo.IsMetadataPropertyCollection,
                                                                                        metadataPropertyCollection,
                                                                                        firstLastQuery.DomainSpecificProcessingType,
                                                                                        storeContext.DomainSpecificConfig,
                                                                                        null,
                                                                                        null,
                                                                                        false);

                #endregion

                if (targetIndex != null)
                {
                    indexSize    = targetIndex.OutDeserializationContext.TotalCount;
                    virtualCount = targetIndex.VirtualCount;
                    indexExists  = true;

                    #region Dynamic tag sort

                    if (firstLastQuery.TagSort != null)
                    {
                        targetIndex.Sort(firstLastQuery.TagSort);
                    }

                    #endregion

                    // update perf counters
                    PerformanceCounters.Instance.SetCounterValue(
                        PerformanceCounterEnum.NumOfItemsInIndexPerFirstLastQuery,
                        messageContext.TypeId,
                        indexSize);

                    PerformanceCounters.Instance.SetCounterValue(
                        PerformanceCounterEnum.NumOfItemsReadPerFirstLastQuery,
                        messageContext.TypeId,
                        targetIndex.OutDeserializationContext.ReadItemCount);

                    #region Populate resultLists

                    if (firstLastQuery.FirstPageSize + firstLastQuery.LastPageSize <= targetIndex.Count)
                    {
                        firstPageResultItemList = CacheIndexInternalAdapter.GetResultItemList(targetIndex, 1, firstLastQuery.FirstPageSize);
                        lastPageResultItemList  = CacheIndexInternalAdapter.GetResultItemList(targetIndex,
                                                                                              targetIndex.Count - firstLastQuery.LastPageSize + 1,
                                                                                              firstLastQuery.LastPageSize);
                    }
                    else
                    {
                        //Populate everything in firstPageResultItemList
                        firstPageResultItemList = CacheIndexInternalAdapter.GetResultItemList(targetIndex, 1, targetIndex.Count);
                    }

                    #endregion

                    #region Get data

                    if (!firstLastQuery.ExcludeData)
                    {
                        //First Page
                        if (firstPageResultItemList != null)
                        {
                            DataTierUtil.GetData(firstPageResultItemList,
                                                 null,
                                                 storeContext,
                                                 messageContext,
                                                 indexTypeMapping.FullDataIdFieldList,
                                                 firstLastQuery.FullDataIdInfo);
                        }

                        //Last Page
                        if (lastPageResultItemList != null)
                        {
                            DataTierUtil.GetData(lastPageResultItemList,
                                                 null,
                                                 storeContext,
                                                 messageContext,
                                                 indexTypeMapping.FullDataIdFieldList,
                                                 firstLastQuery.FullDataIdInfo);
                        }
                    }

                    #endregion

                    #region Get metadata

                    if (firstLastQuery.GetMetadata && !indexTypeMapping.MetadataStoredSeperately)
                    {
                        IndexServerUtils.GetMetadataStoredWithIndex(indexTypeMapping,
                                                                    new List <CacheIndexInternal>(1)
                        {
                            targetIndex
                        },
                                                                    out metadata,
                                                                    out metadataPropertyCollection);
                    }

                    #endregion
                }

                #endregion

                firstLastQueryResult = new FirstLastQueryResult(indexExists, indexSize, metadata, metadataPropertyCollection, firstPageResultItemList, lastPageResultItemList, virtualCount, indexCap, null);
            }
            catch (Exception ex)
            {
                firstLastQueryResult = new FirstLastQueryResult(false, -1, null, null, null, null, -1, 0, ex.Message);
                LoggingUtil.Log.ErrorFormat("TypeID {0} -- Error processing FirstLastQuery : {1}", messageContext.TypeId, ex);
            }
            return(firstLastQueryResult);
        }
コード例 #19
0
 internal MetadataPropertyCollection GetMetadataProperties()
 {
      if (null == _itemAttributes)
      {
          var itemAttributes = new MetadataPropertyCollection(this);
          if (IsReadOnly)
          {
              itemAttributes.SetReadOnly();
          }
          Interlocked.CompareExchange(
              ref _itemAttributes, itemAttributes, null);
      }
      return _itemAttributes;
 }
コード例 #20
0
        /// <summary>
        /// Processes the specified random query.
        /// </summary>
        /// <param name="randomQuery">The random query.</param>
        /// <param name="messageContext">The message context.</param>
        /// <param name="storeContext">The store context.</param>
        /// <returns>RandomQueryResult</returns>
        internal static RandomQueryResult Process(RandomQuery randomQuery, MessageContext messageContext, IndexStoreContext storeContext)
        {
            RandomQueryResult randomQueryResult;
            List <ResultItem> resultItemList = null;
            bool indexExists  = false;
            int  indexSize    = -1;
            int  virtualCount = -1;

            byte[] metadata = null;
            MetadataPropertyCollection metadataPropertyCollection = null;

            try
            {
                IndexTypeMapping indexTypeMapping =
                    storeContext.StorageConfiguration.CacheIndexV3StorageConfig.IndexTypeMappingCollection[messageContext.TypeId];

                #region Validate Query

                ValidateQuery(indexTypeMapping, randomQuery);

                #endregion

                Index targetIndexInfo = indexTypeMapping.IndexCollection[randomQuery.TargetIndexName];
                int   indexCap        = targetIndexInfo.MaxIndexSize;

                #region Prepare Result

                #region Extract index and apply criteria

                if (indexTypeMapping.MetadataStoredSeperately)
                {
                    IndexServerUtils.GetMetadataStoredSeperately(indexTypeMapping,
                                                                 messageContext.TypeId,
                                                                 messageContext.PrimaryId,
                                                                 randomQuery.IndexId,
                                                                 storeContext,
                                                                 out metadata,
                                                                 out metadataPropertyCollection);
                }

                CacheIndexInternal targetIndex = IndexServerUtils.GetCacheIndexInternal(storeContext,
                                                                                        messageContext.TypeId,
                                                                                        messageContext.PrimaryId,
                                                                                        randomQuery.IndexId,
                                                                                        targetIndexInfo.ExtendedIdSuffix,
                                                                                        randomQuery.TargetIndexName,
                                                                                        0,
                                                                                        randomQuery.Filter,
                                                                                        true,
                                                                                        randomQuery.IndexCondition,
                                                                                        false,
                                                                                        false,
                                                                                        targetIndexInfo.PrimarySortInfo,
                                                                                        targetIndexInfo.LocalIdentityTagList,
                                                                                        targetIndexInfo.StringHashCodeDictionary,
                                                                                        null,
                                                                                        targetIndexInfo.IsMetadataPropertyCollection,
                                                                                        metadataPropertyCollection,
                                                                                        randomQuery.DomainSpecificProcessingType,
                                                                                        storeContext.DomainSpecificConfig,
                                                                                        null,
                                                                                        null,
                                                                                        false);

                #endregion

                if (targetIndex != null)
                {
                    indexSize    = targetIndex.OutDeserializationContext.TotalCount;
                    virtualCount = targetIndex.VirtualCount;
                    indexExists  = true;

                    // update performance counters
                    PerformanceCounters.Instance.SetCounterValue(
                        PerformanceCounterEnum.NumOfItemsInIndexPerRandomQuery,
                        messageContext.TypeId,
                        indexSize);

                    PerformanceCounters.Instance.SetCounterValue(
                        PerformanceCounterEnum.NumOfItemsReadPerRandomQuery,
                        messageContext.TypeId,
                        targetIndex.OutDeserializationContext.ReadItemCount);

                    #region Populate resultLists

                    int indexItemCount  = targetIndex.Count;
                    int resultListCount = Math.Min(randomQuery.Count, indexItemCount);
                    IEnumerable <int> itemPositionList = Algorithm.RandomSubset(new Random(), 0, indexItemCount - 1, resultListCount);
                    resultItemList = CacheIndexInternalAdapter.GetResultItemList(targetIndex, itemPositionList);

                    #endregion

                    #region Get data

                    if (!randomQuery.ExcludeData)
                    {
                        DataTierUtil.GetData(resultItemList,
                                             null,
                                             storeContext,
                                             messageContext,
                                             indexTypeMapping.FullDataIdFieldList,
                                             randomQuery.FullDataIdInfo);
                    }

                    #endregion

                    #region Get metadata

                    if (randomQuery.GetMetadata && !indexTypeMapping.MetadataStoredSeperately)
                    {
                        IndexServerUtils.GetMetadataStoredWithIndex(indexTypeMapping,
                                                                    new List <CacheIndexInternal>(1)
                        {
                            targetIndex
                        },
                                                                    out metadata,
                                                                    out metadataPropertyCollection);
                    }

                    #endregion

                    #endregion
                }
                randomQueryResult = new RandomQueryResult(indexExists, indexSize, metadata, metadataPropertyCollection, resultItemList, virtualCount, indexCap, null);
            }
            catch (Exception ex)
            {
                randomQueryResult = new RandomQueryResult(false, -1, null, null, null, -1, 0, ex.Message);
                LoggingUtil.Log.ErrorFormat("TypeId {0} -- Error processing RandomQuery : {1}", messageContext.TypeId, ex);
            }
            return(randomQueryResult);
        }
コード例 #21
0
        /// <summary>
        /// Processes the specified MetadataPropertyQuery.
        /// </summary>
        /// <param name="metadataPropertyQuery">The MetadataPropertyQuery.</param>
        /// <param name="messageContext">The message context.</param>
        /// <param name="storeContext">The store context.</param>
        /// <returns></returns>
        internal static MetadataPropertyQueryResult Process(MetadataPropertyQuery metadataPropertyQuery, MessageContext messageContext, IndexStoreContext storeContext)
        {
            MetadataPropertyQueryResult metadataPropertyQueryResult;
            MetadataPropertyCollection  metadataPropertyCollection = null;

            try
            {
                IndexTypeMapping indexTypeMapping =
                    storeContext.StorageConfiguration.CacheIndexV3StorageConfig.IndexTypeMappingCollection[messageContext.TypeId];

                if (indexTypeMapping.IsMetadataPropertyCollection || indexTypeMapping.IndexCollection[metadataPropertyQuery.TargetIndexName].IsMetadataPropertyCollection)
                {
                    #region Fetch MetadataPropertyCollection

                    if (indexTypeMapping.MetadataStoredSeperately)
                    {
                        byte[] metadata;
                        IndexServerUtils.GetMetadataStoredSeperately(indexTypeMapping,
                                                                     messageContext.TypeId,
                                                                     metadataPropertyQuery.PrimaryId,
                                                                     metadataPropertyQuery.IndexId,
                                                                     storeContext,
                                                                     out metadata,
                                                                     out metadataPropertyCollection);
                    }
                    else
                    {
                        // Get CacheIndexInternal
                        Index indexInfo = indexTypeMapping.IndexCollection[metadataPropertyQuery.TargetIndexName];
                        CacheIndexInternal cacheIndexInternal = IndexServerUtils.GetCacheIndexInternal(storeContext,
                                                                                                       messageContext.
                                                                                                       TypeId,
                                                                                                       metadataPropertyQuery
                                                                                                       .PrimaryId,
                                                                                                       metadataPropertyQuery
                                                                                                       .IndexId,
                                                                                                       indexInfo.
                                                                                                       ExtendedIdSuffix,
                                                                                                       metadataPropertyQuery
                                                                                                       .
                                                                                                       TargetIndexName,
                                                                                                       0,
                                                                                                       null,
                                                                                                       false,
                                                                                                       null,
                                                                                                       true,
                                                                                                       false,
                                                                                                       null,
                                                                                                       null,
                                                                                                       null,
                                                                                                       null,
                                                                                                       true,
                                                                                                       null,
                                                                                                       DomainSpecificProcessingType
                                                                                                       .None,
                                                                                                       null,
                                                                                                       null,
                                                                                                       null,
                                                                                                       true);

                        if (cacheIndexInternal != null)
                        {
                            metadataPropertyCollection = cacheIndexInternal.MetadataPropertyCollection;
                        }
                    }

                    #endregion
                }

                metadataPropertyQueryResult = new MetadataPropertyQueryResult
                {
                    MetadataPropertyCollection = metadataPropertyCollection
                };
            }
            catch (Exception ex)
            {
                metadataPropertyQueryResult = new MetadataPropertyQueryResult
                {
                    MetadataPropertyCollection = metadataPropertyCollection,
                    ExceptionInfo = ex.Message
                };
                LoggingUtil.Log.ErrorFormat("TypeId {0} -- Error processing MetadataPropertyQuery : {1} for IndexId : {2} and TargetIndexname : {3}",
                                            messageContext.TypeId,
                                            ex,
                                            metadataPropertyQuery.IndexId != null ? IndexCacheUtils.GetReadableByteArray(metadataPropertyQuery.IndexId) : "Null",
                                            metadataPropertyQuery.TargetIndexName ?? "Null");
            }
            return(metadataPropertyQueryResult);
        }
コード例 #22
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                tabMetadataTypes.TabPages.Clear();

                DataSet ds;

                using (StreamReader streamReader = new StreamReader(openFileDialog.FileName))
                {
                    try
                    {
                        ds = ExportFacade.ExportToDataSet(streamReader.BaseStream);
                    }
                    catch (GroupDocs.Metadata.Exceptions.InvalidFormatException)
                    {
                        MessageBox.Show(@"This format is not supported");
                        return;
                    }
                    catch (GroupDocs.Metadata.Exceptions.GroupDocsException ex)
                    {
                        MessageBox.Show(string.Format("Error: {0}", ex.Message));
                        return;
                    }
                }

                propertiesEditor      = null;
                saveMetadata.FileName = openFileDialog.FileName;

                if (ds.Tables.Count == 0)
                {
                    MessageBox.Show(@"Metadata not found");
                }
                else
                {
                    for (int i = 0; i < ds.Tables.Count; i++)
                    {
                        DataTable table = ds.Tables[i];

                        Control child;
                        string  tabName;

                        switch (table.TableName.ToLower())
                        {
                        case "xmp":
                            tabName = "XMP metadata";
                            XmpPacketWrapper xmpPacket = MetadataUtility.ExtractXmpPackage(openFileDialog.FileName);
                            ucXmpTree        xmpTree   = new ucXmpTree();
                            xmpTree.LoadControl(xmpPacket);
                            ResizeControl(xmpTree);
                            child = xmpTree;
                            break;

                        case "pdf":
                        case "doc":
                        case "xls":
                        case "ppt":
                            tabName = "Document properties";
                            MetadataPropertyCollection properties = MetadataUtility.ExtractDocumentProperties(openFileDialog.FileName);
                            propertiesEditor = new ucPropertiesEditor();
                            ResizeControl(propertiesEditor);
                            propertiesEditor.LoadControl(properties);
                            child = propertiesEditor;
                            break;

                        default:
                            tabName = string.Format("{0} metadata", table.TableName);
                            DataGridView gridView = new DataGridView();
                            ResizeControl(gridView);
                            gridView.DataSource = table;
                            child = gridView;
                            break;
                        }

                        tabMetadataTypes.TabPages.Add(tabName);
                        TabPage addedTab = tabMetadataTypes.TabPages[i];

                        //addedTab.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top;
                        addedTab.Controls.Add(child);
                    }

                    tabMetadataTypes.Visible = true;
                }
            }
        }
コード例 #23
0
        /// <summary>
        /// Processes the specified contains index query.
        /// </summary>
        /// <param name="containsIndexQuery">The contains index query.</param>
        /// <param name="messageContext">The message context.</param>
        /// <param name="storeContext">The store context.</param>
        /// <returns>ContainsIndexQueryResult</returns>
        internal static ContainsIndexQueryResult Process(ContainsIndexQuery containsIndexQuery, MessageContext messageContext, IndexStoreContext storeContext)
        {
            ContainsIndexQueryResult containsIndexQueryResult;
            MultiItemResult          multiItemResult = null;

            byte[] metadata = null;
            MetadataPropertyCollection metadataPropertyCollection = null;
            bool indexExists  = false;
            int  indexSize    = -1;
            int  virtualCount = -1;

            try
            {
                IndexTypeMapping indexTypeMapping =
                    storeContext.StorageConfiguration.CacheIndexV3StorageConfig.IndexTypeMappingCollection[messageContext.TypeId];

                #region Check TargetIndexName

                if (string.IsNullOrEmpty(containsIndexQuery.TargetIndexName))
                {
                    containsIndexQuery.TargetIndexName = IndexServerUtils.CheckQueryTargetIndexName(indexTypeMapping);
                }

                if (!indexTypeMapping.IndexCollection.Contains(containsIndexQuery.TargetIndexName))
                {
                    throw new Exception("Invalid TargetIndexName - " + containsIndexQuery.TargetIndexName);
                }

                #endregion

                Index targetIndexInfo = indexTypeMapping.IndexCollection[containsIndexQuery.TargetIndexName];
                int   indexCap        = targetIndexInfo.MaxIndexSize;
                List <CacheIndexInternal> internalCacheIndexList = new List <CacheIndexInternal>();

                #region Get TargetIndex

                CacheIndexInternal cacheIndexInternal = IndexServerUtils.GetCacheIndexInternal(storeContext,
                                                                                               messageContext.TypeId,
                                                                                               messageContext.PrimaryId,
                                                                                               containsIndexQuery.IndexId,
                                                                                               targetIndexInfo.ExtendedIdSuffix,
                                                                                               containsIndexQuery.TargetIndexName,
                                                                                               0,
                                                                                               null,
                                                                                               true,
                                                                                               null,
                                                                                               false,
                                                                                               false,
                                                                                               targetIndexInfo.PrimarySortInfo,
                                                                                               targetIndexInfo.LocalIdentityTagList,
                                                                                               targetIndexInfo.StringHashCodeDictionary,
                                                                                               null,
                                                                                               targetIndexInfo.IsMetadataPropertyCollection,
                                                                                               null,
                                                                                               containsIndexQuery.DomainSpecificProcessingType,
                                                                                               storeContext.DomainSpecificConfig,
                                                                                               null,
                                                                                               null,
                                                                                               false);

                #endregion

                if (cacheIndexInternal != null)
                {
                    internalCacheIndexList.Add(cacheIndexInternal);
                    indexExists  = true;
                    indexSize    = cacheIndexInternal.OutDeserializationContext.TotalCount;
                    virtualCount = cacheIndexInternal.VirtualCount;

                    // update the performance counter
                    PerformanceCounters.Instance.SetCounterValue(
                        PerformanceCounterEnum.NumOfItemsInIndexPerContainsIndexQuery,
                        messageContext.TypeId,
                        indexSize);

                    PerformanceCounters.Instance.SetCounterValue(
                        PerformanceCounterEnum.NumOfItemsReadPerContainsIndexQuery,
                        messageContext.TypeId,
                        cacheIndexInternal.OutDeserializationContext.ReadItemCount);

                    int           searchIndex;
                    IndexDataItem indexDataItem;

                    foreach (IndexItem queryIndexItem in containsIndexQuery.IndexItemList)
                    {
                        #region Search item in index

                        searchIndex = internalCacheIndexList[0].Search(queryIndexItem);

                        #endregion

                        if (searchIndex > -1)
                        {
                            if (multiItemResult == null)
                            {
                                multiItemResult = new MultiItemResult(containsIndexQuery.IndexId);
                            }
                            indexDataItem = new IndexDataItem(InternalItemAdapter.ConvertToIndexItem(internalCacheIndexList[0].GetItem(searchIndex),
                                                                                                     internalCacheIndexList[0].InDeserializationContext));

                            #region Get extra tags

                            if (containsIndexQuery.TagsFromIndexes != null && containsIndexQuery.TagsFromIndexes.Count != 0)
                            {
                                foreach (string indexName in containsIndexQuery.TagsFromIndexes)
                                {
                                    Index indexInfo = indexTypeMapping.IndexCollection[indexName];

                                    CacheIndexInternal indexInternal =
                                        IndexServerUtils.GetCacheIndexInternal(storeContext,
                                                                               messageContext.TypeId,
                                                                               messageContext.PrimaryId,
                                                                               containsIndexQuery.IndexId,
                                                                               indexInfo.ExtendedIdSuffix,
                                                                               indexName,
                                                                               0,
                                                                               null,
                                                                               true,
                                                                               null,
                                                                               false,
                                                                               false,
                                                                               indexInfo.PrimarySortInfo,
                                                                               indexInfo.LocalIdentityTagList,
                                                                               indexInfo.StringHashCodeDictionary,
                                                                               null,
                                                                               indexInfo.IsMetadataPropertyCollection,
                                                                               null,
                                                                               containsIndexQuery.DomainSpecificProcessingType,
                                                                               storeContext.DomainSpecificConfig,
                                                                               null,
                                                                               null,
                                                                               false);

                                    if (indexInternal != null)
                                    {
                                        // update the performance counter
                                        PerformanceCounters.Instance.SetCounterValue(
                                            PerformanceCounterEnum.NumOfItemsInIndexPerContainsIndexQuery,
                                            messageContext.TypeId,
                                            indexInternal.OutDeserializationContext.TotalCount);

                                        PerformanceCounters.Instance.SetCounterValue(
                                            PerformanceCounterEnum.NumOfItemsReadPerContainsIndexQuery,
                                            messageContext.TypeId,
                                            indexInternal.OutDeserializationContext.ReadItemCount);

                                        internalCacheIndexList.Add(indexInternal);

                                        IndexServerUtils.GetTags(indexInternal, queryIndexItem, indexDataItem);
                                    }
                                }
                            }

                            #endregion

                            multiItemResult.Add(indexDataItem);
                        }
                    }

                    #region Get data

                    if (!containsIndexQuery.ExcludeData && multiItemResult != null)
                    {
                        byte[] extendedId;
                        List <RelayMessage> dataStoreMessages = new List <RelayMessage>(multiItemResult.Count);
                        short relatedTypeId;
                        if (containsIndexQuery.FullDataIdInfo != null && containsIndexQuery.FullDataIdInfo.RelatedTypeName != null)
                        {
                            if (!storeContext.TryGetTypeId(containsIndexQuery.FullDataIdInfo.RelatedTypeName, out relatedTypeId))
                            {
                                LoggingUtil.Log.ErrorFormat("Invalid RelatedCacheTypeName - {0}", containsIndexQuery.FullDataIdInfo.RelatedTypeName);
                                throw new Exception("Invalid RelatedTypeId for TypeId - " + containsIndexQuery.FullDataIdInfo.RelatedTypeName);
                            }
                        }
                        else if (!storeContext.TryGetRelatedIndexTypeId(messageContext.TypeId, out relatedTypeId))
                        {
                            LoggingUtil.Log.ErrorFormat("Invalid RelatedTypeId for TypeId - {0}", messageContext.TypeId);
                            throw new Exception("Invalid RelatedTypeId for TypeId - " + messageContext.TypeId);
                        }

                        foreach (IndexDataItem resultItem in multiItemResult)
                        {
                            extendedId = DataTierUtil.GetFullDataId(containsIndexQuery.IndexId,
                                                                    resultItem,
                                                                    containsIndexQuery.FullDataIdInfo != null && containsIndexQuery.FullDataIdInfo.RelatedTypeName != null ?
                                                                    containsIndexQuery.FullDataIdInfo.FullDataIdFieldList :
                                                                    indexTypeMapping.FullDataIdFieldList);
                            dataStoreMessages.Add(new RelayMessage(relatedTypeId, IndexCacheUtils.GeneratePrimaryId(extendedId), extendedId, MessageType.Get));
                        }

                        storeContext.ForwarderComponent.HandleMessages(dataStoreMessages);

                        int i = 0;
                        foreach (IndexDataItem resultItem in multiItemResult)
                        {
                            if (dataStoreMessages[i].Payload != null)
                            {
                                resultItem.Data = dataStoreMessages[i].Payload.ByteArray;
                            }
                            i++;
                        }
                    }

                    #endregion

                    #region Get metadata

                    if (containsIndexQuery.GetMetadata)
                    {
                        if (indexTypeMapping.MetadataStoredSeperately)
                        {
                            IndexServerUtils.GetMetadataStoredSeperately(indexTypeMapping,
                                                                         messageContext.TypeId,
                                                                         messageContext.PrimaryId,
                                                                         containsIndexQuery.IndexId,
                                                                         storeContext,
                                                                         out metadata,
                                                                         out metadataPropertyCollection);
                        }
                        else
                        {
                            IndexServerUtils.GetMetadataStoredWithIndex(indexTypeMapping,
                                                                        internalCacheIndexList,
                                                                        out metadata,
                                                                        out metadataPropertyCollection);
                        }
                    }

                    #endregion
                }
                containsIndexQueryResult = new ContainsIndexQueryResult(multiItemResult,
                                                                        metadata,
                                                                        metadataPropertyCollection,
                                                                        indexSize,
                                                                        indexExists,
                                                                        virtualCount,
                                                                        indexCap,
                                                                        null);
            }
            catch (Exception ex)
            {
                containsIndexQueryResult = new ContainsIndexQueryResult(null, null, null, -1, false, -1, 0, ex.Message);
                LoggingUtil.Log.ErrorFormat("TypeId {0} -- Error processing ContainsIndexQuery : {1}", messageContext.TypeId, ex);
            }
            return(containsIndexQueryResult);
        }
コード例 #24
0
        /// <summary>
        /// Processes the specified MetadataPropertyCommand.
        /// </summary>
        /// <param name="metadataPropertyCommand">The MetadataPropertyCommand.</param>
        /// <param name="messageContext">The message context.</param>
        /// <param name="storeContext">The store context.</param>
        internal static void Process(MetadataPropertyCommand metadataPropertyCommand, MessageContext messageContext, IndexStoreContext storeContext)
        {
            if (metadataPropertyCommand != null)
            {
                MetadataPropertyCollection metadataPropertyCollection = null;
                byte[]             metadata;
                IndexTypeMapping   indexTypeMapping   = storeContext.StorageConfiguration.CacheIndexV3StorageConfig.IndexTypeMappingCollection[messageContext.TypeId];
                CacheIndexInternal cacheIndexInternal = null;

                #region Fetch MetadataPropertyCollection

                if (indexTypeMapping.MetadataStoredSeperately)
                {
                    IndexServerUtils.GetMetadataStoredSeperately(indexTypeMapping,
                                                                 messageContext.TypeId,
                                                                 metadataPropertyCommand.PrimaryId,
                                                                 metadataPropertyCommand.IndexId,
                                                                 storeContext,
                                                                 out metadata,
                                                                 out metadataPropertyCollection);
                }
                else
                {
                    Index indexInfo = indexTypeMapping.IndexCollection[metadataPropertyCommand.TargetIndexName];

                    // Get CacheIndexInternal
                    cacheIndexInternal = IndexServerUtils.GetCacheIndexInternal(storeContext,
                                                                                messageContext.TypeId,
                                                                                metadataPropertyCommand.PrimaryId,
                                                                                metadataPropertyCommand.IndexId,
                                                                                indexInfo.ExtendedIdSuffix,
                                                                                metadataPropertyCommand.TargetIndexName,
                                                                                0,
                                                                                null,
                                                                                false,
                                                                                null,
                                                                                true,
                                                                                false,
                                                                                null,
                                                                                null,
                                                                                null,
                                                                                null,
                                                                                true,
                                                                                null,
                                                                                DomainSpecificProcessingType.None,
                                                                                null,
                                                                                null,
                                                                                null,
                                                                                true);

                    if (cacheIndexInternal != null && cacheIndexInternal.MetadataPropertyCollection != null)
                    {
                        metadataPropertyCollection = cacheIndexInternal.MetadataPropertyCollection;
                    }
                }

                #endregion

                #region Process MetadataPropertyCollection add/deletes

                if (metadataPropertyCollection == null)
                {
                    metadataPropertyCollection = new MetadataPropertyCollection();
                }
                metadataPropertyCollection.Process(metadataPropertyCommand.MetadataPropertyCollectionUpdate);

                #endregion

                #region Restore MetadataPropertyCollection back to storage

                bool   isCompress = storeContext.GetCompressOption(messageContext.TypeId);
                byte[] extId      = null;
                byte[] byteArray  = null;

                if (indexTypeMapping.MetadataStoredSeperately)
                {
                    extId     = metadataPropertyCommand.ExtendedId;
                    byteArray = Serializer.Serialize(metadataPropertyCollection, isCompress);
                }
                else
                {
                    if (cacheIndexInternal == null)
                    {
                        cacheIndexInternal = new CacheIndexInternal
                        {
                            InDeserializationContext = new InDeserializationContext(0,
                                                                                    metadataPropertyCommand.TargetIndexName,
                                                                                    metadataPropertyCommand.IndexId,
                                                                                    messageContext.TypeId,
                                                                                    null,
                                                                                    false,
                                                                                    null,
                                                                                    true,
                                                                                    false,
                                                                                    null,
                                                                                    null,
                                                                                    null,
                                                                                    null,
                                                                                    null,
                                                                                    null,
                                                                                    true,
                                                                                    null,
                                                                                    DomainSpecificProcessingType.None,
                                                                                    null,
                                                                                    null,
                                                                                    null)
                        };
                    }

                    //Restore CacheIndexInternal
                    cacheIndexInternal.MetadataPropertyCollection = metadataPropertyCollection;

                    extId = IndexServerUtils.FormExtendedId(metadataPropertyCommand.IndexId,
                                                            indexTypeMapping.IndexCollection[
                                                                cacheIndexInternal.InDeserializationContext.IndexName].
                                                            ExtendedIdSuffix);

                    byteArray = Serializer.Serialize(cacheIndexInternal, isCompress);
                }

                PayloadStorage bdbEntryHeader = new PayloadStorage
                {
                    Compressed       = isCompress,
                    TTL              = -1,
                    LastUpdatedTicks = DateTime.Now.Ticks,
                    ExpirationTicks  = -1,
                    Deactivated      = false
                };

                BinaryStorageAdapter.Save(
                    storeContext.MemoryPool,
                    storeContext.IndexStorageComponent,
                    messageContext.TypeId,
                    metadataPropertyCommand.PrimaryId,
                    extId,
                    bdbEntryHeader,
                    byteArray);

                #endregion
            }
        }
コード例 #25
0
        /// <summary>
        /// Gets the index header.
        /// </summary>
        /// <param name="internalIndexDictionary">The internal index dictionary.</param>
        /// <param name="targetIndexCacheIndexInternal">The targetindex CacheIndexInternal.</param>
        /// <param name="indexId">The index id.</param>
        /// <param name="query">The query.</param>
        /// <param name="indexTypeMapping">The index type mapping.</param>
        /// <param name="typeId">The type id.</param>
        /// <param name="storeContext">The store context.</param>
        /// <param name="indexInIndexIdList">The indexInIndexIdList.</param>
        /// <returns>IndexHeader</returns>
        private static IndexHeader GetIndexHeader(Dictionary <KeyValuePair <byte[], string>,
                                                              CacheIndexInternal> internalIndexDictionary,
                                                  CacheIndexInternal targetIndexCacheIndexInternal,
                                                  byte[] indexId,
                                                  BaseMultiIndexIdQuery <TQueryResult> query,
                                                  IndexTypeMapping indexTypeMapping,
                                                  short typeId,
                                                  IndexStoreContext storeContext,
                                                  int indexInIndexIdList)
        {
            byte[] metadata = null;
            MetadataPropertyCollection metadataPropertyCollection = null;

            if (CheckMetaData(internalIndexDictionary, indexTypeMapping))
            {
                if (indexTypeMapping.MetadataStoredSeperately)
                {
                    #region Check if MetadataPropertyCollection is stored seperately

                    IndexServerUtils.GetMetadataStoredSeperately(indexTypeMapping,
                                                                 typeId,
                                                                 (query.PrimaryIdList != null && indexInIndexIdList < query.PrimaryIdList.Count) ?
                                                                 query.PrimaryIdList[indexInIndexIdList]:
                                                                 IndexCacheUtils.GeneratePrimaryId(indexId),
                                                                 indexId,
                                                                 storeContext,
                                                                 out metadata,
                                                                 out metadataPropertyCollection);

                    #endregion
                }
                else
                {
                    #region Check metadata on targetIndex

                    if (indexTypeMapping.IndexCollection[query.TargetIndexName].MetadataPresent)
                    {
                        if (indexTypeMapping.IndexCollection[query.TargetIndexName].IsMetadataPropertyCollection)
                        {
                            metadataPropertyCollection = targetIndexCacheIndexInternal.MetadataPropertyCollection;
                        }
                        else
                        {
                            metadata = targetIndexCacheIndexInternal.Metadata;
                        }
                    }

                    #endregion

                    #region Check metadata on other extracted indexes

                    if (query.TagsFromIndexes != null)
                    {
                        foreach (string indexName in query.TagsFromIndexes)
                        {
                            if (indexTypeMapping.IndexCollection[indexName].MetadataPresent)
                            {
                                if (indexTypeMapping.IndexCollection[indexName].IsMetadataPropertyCollection)
                                {
                                    metadataPropertyCollection =
                                        internalIndexDictionary[new KeyValuePair <byte[], string>(indexId, indexName)].
                                        MetadataPropertyCollection;
                                }
                                else
                                {
                                    metadata =
                                        internalIndexDictionary[new KeyValuePair <byte[], string>(indexId, indexName)].
                                        Metadata;
                                }
                            }
                        }
                    }

                    #endregion
                }
            }

            return(new IndexHeader
            {
                Metadata = metadata,
                MetadataPropertyCollection = metadataPropertyCollection,
                VirtualCount = targetIndexCacheIndexInternal.VirtualCount
            });
        }
コード例 #26
0
        /// <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="maxItemsPerIndex">The maxItemsPerIndex.</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>
        /// <param name="isMetadataPropertyCollection">if set to <c>true</c> metadata represents a property collection; otherwise , <c>false</c>.</param>
        /// <param name="metadataPropertyCollection">The MetadataPropertyCollection.</param>
        /// <param name="domainSpecificProcessingType">The DomainSpecificProcessingType.</param>
        /// <param name="domainSpecificConfig">The DomainSpecificConfig.</param>
        /// <param name="getDistinctValuesFieldName">The distinct value field name.</param>
        /// <param name="groupBy">The GroupBy clause.</param>
        /// <param name="forceFullGet">indicate whether or not use full get.</param>
        /// <returns>CacheIndexInternal</returns>
        internal static CacheIndexInternal GetCacheIndexInternal(IndexStoreContext storeContext,
                                                                 short typeId,
                                                                 int primaryId,
                                                                 byte[] indexId,
                                                                 short extendedIdSuffix,
                                                                 string indexName,
                                                                 int maxItemsPerIndex,
                                                                 Filter filter,
                                                                 bool inclusiveFilter,
                                                                 IndexCondition indexCondition,
                                                                 bool deserializeHeaderOnly,
                                                                 bool getFilteredItems,
                                                                 PrimarySortInfo primarySortInfo,
                                                                 List <string> localIdentityTagNames,
                                                                 Dictionary <int, bool> stringHashCodeDictionary,
                                                                 CapCondition capCondition,
                                                                 bool isMetadataPropertyCollection,
                                                                 MetadataPropertyCollection metadataPropertyCollection,
                                                                 DomainSpecificProcessingType domainSpecificProcessingType,
                                                                 DomainSpecificConfig domainSpecificConfig,
                                                                 string getDistinctValuesFieldName,
                                                                 GroupBy groupBy,
                                                                 bool forceFullGet)
        {
            CacheIndexInternal cacheIndexInternal = null;

            byte[] extendedId = FormExtendedId(indexId, extendedIdSuffix);
            //RelayMessage getMsg = new RelayMessage(typeId, primaryId, extendedId, MessageType.Get);
            //storeContext.IndexStorageComponent.HandleMessage(getMsg);

            Stream myStream;

            ResourcePoolItem <MemoryStream> pooledStreamItem = null;
            MemoryStream pooledStream;

            try
            {
                int indexLevelGetSize =
                    storeContext.StorageConfiguration.CacheIndexV3StorageConfig.IndexTypeMappingCollection[typeId].
                    IndexCollection[indexName].PartialGetSizeInBytes;

                bool isFullGet = forceFullGet ? true : (indexLevelGetSize <= 0 && storeContext.PartialGetLength <= 0);

                if (isFullGet)
                {
                    byte[] cacheBytes = BinaryStorageAdapter.Get(
                        storeContext.IndexStorageComponent,
                        typeId,
                        primaryId,
                        extendedId);

                    if (cacheBytes != null)
                    {
                        myStream = new MemoryStream(cacheBytes);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    int partialGetSize = indexLevelGetSize == 0 ? storeContext.PartialGetLength : indexLevelGetSize;

                    // get a memory stream from the memory pool
                    pooledStreamItem = storeContext.MemoryPool.GetItem();
                    pooledStream     = pooledStreamItem.Item;

                    myStream = new SmartStream(
                        storeContext.IndexStorageComponent,
                        typeId,
                        primaryId,
                        extendedId,
                        partialGetSize,
                        pooledStream);

                    BerkeleyBinaryStorePerformanceCounters.Instance.IncrementCounter(
                        BerkeleyBinaryStorePerformanceCounterEnum.PartialGetPerSec,
                        1);
                }

                if (myStream.Length > 0) //CacheIndex exists, this check is just for SmartStream
                {
                    cacheIndexInternal = new CacheIndexInternal
                    {
                        InDeserializationContext =
                            new InDeserializationContext(maxItemsPerIndex,
                                                         indexName,
                                                         indexId,
                                                         typeId,
                                                         filter,
                                                         inclusiveFilter,
                                                         storeContext.TagHashCollection,
                                                         deserializeHeaderOnly,
                                                         getFilteredItems,
                                                         primarySortInfo,
                                                         localIdentityTagNames,
                                                         storeContext.StringHashCollection,
                                                         stringHashCodeDictionary,
                                                         indexCondition,
                                                         capCondition,
                                                         isMetadataPropertyCollection,
                                                         metadataPropertyCollection,
                                                         domainSpecificProcessingType,
                                                         domainSpecificConfig,
                                                         getDistinctValuesFieldName,
                                                         groupBy)
                    };

                    if (!isFullGet)
                    {
                        // skip the bdb entry header
                        myStream.Read(new byte[BdbHeaderSize], 0, BdbHeaderSize);
                    }

                    // This mess is required until Moods 2.0 migrated to have IVersionSerializable version of CacheIndexInternal
                    // ** TBD - Should be removed later
                    if (LegacySerializationUtil.Instance.IsSupported(typeId))
                    {
                        cacheIndexInternal.Deserialize(new CompactBinaryReader(myStream));
                    }
                    else
                    {
                        int version = myStream.ReadByte();

                        try
                        {
                            cacheIndexInternal.Deserialize(new CompactBinaryReader(myStream), version);
                        }
                        catch (Exception ex)
                        {
                            LoggingUtil.Log.ErrorFormat(
                                "The deserialization has an exception: primary id : {0}, index id : {1}, extendedid : {2}, extendedIdSuffix : {3}, version : {4} info : {5}",
                                primaryId,
                                ByteArrayToString(indexId, 0),
                                ByteArrayToString(extendedId, 0),
                                extendedIdSuffix,
                                version,
                                ex.ToString());

                            if (myStream.Length > 0)
                            {
                                myStream.Seek(0, SeekOrigin.Begin);
                                byte[] ba = new byte[10];
                                myStream.Read(ba, 0, 10);

                                LoggingUtil.Log.ErrorFormat("The first 10 bytes of the stream are {0}",
                                                            ByteArrayToString(ba, 0));
                            }

                            throw;
                        }
                    }

                    // update SmartStream perf counters
                    if (!isFullGet)
                    {
                        SmartStream mySmartStream = (SmartStream)myStream;

                        BerkeleyBinaryStorePerformanceCounters.Instance.IncrementCounter(
                            BerkeleyBinaryStorePerformanceCounterEnum.AvgDbGetPerPartialGet,
                            mySmartStream.DatabaseAccessTime);

                        BerkeleyBinaryStorePerformanceCounters.Instance.IncrementCounter(
                            BerkeleyBinaryStorePerformanceCounterEnum.AvgDbGetPerPartialGetBase,
                            1);

                        BerkeleyBinaryStorePerformanceCounters.Instance.IncrementCounter(
                            BerkeleyBinaryStorePerformanceCounterEnum.AvgBytesPerPartialGet,
                            mySmartStream.Position);

                        BerkeleyBinaryStorePerformanceCounters.Instance.IncrementCounter(
                            BerkeleyBinaryStorePerformanceCounterEnum.AvgBytesPerPartialGetBase,
                            1);
                    }
                }
            }
            finally
            {
                // release the pooled stream
                if (storeContext.MemoryPool != null && pooledStreamItem != null)
                {
                    storeContext.MemoryPool.ReleaseItem(pooledStreamItem);
                }
            }

            return(cacheIndexInternal);
        }