Exemplo n.º 1
0
        /// <summary>
        /// Determines whether repositioning of index item is required or not.
        /// </summary>
        /// <param name="indexInfo">The index info.</param>
        /// <param name="addItem">The add item.</param>
        /// <param name="internalItem">The internal item.</param>
        /// <returns>
        ///     <c>true</c> if repositioning of index item is required; otherwise, <c>false</c>.
        /// </returns>
        private static bool IsRepositioningOfIndexItemRequired(Index indexInfo, IndexDataItem addItem, InternalItem internalItem)
        {
            byte[] sortTagValueInAddItem;
            if (indexInfo.PrimarySortInfo.IsTag && addItem.Tags.TryGetValue(indexInfo.PrimarySortInfo.FieldName, out sortTagValueInAddItem))
            {
                // Index is sorted by tag and tag might have been updated
                byte[] sortTagValueInIndex;
                internalItem.TryGetTagValue(indexInfo.PrimarySortInfo.FieldName, out sortTagValueInIndex);

                if (!ByteArrayComparerUtil.CompareByteArrays(sortTagValueInAddItem, sortTagValueInIndex))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Linear searches the searchItem within the InternalItemList
 /// </summary>
 /// <param name="searchItem">The search item.</param>
 /// <param name="localIdentityTagNames">The local identity tag names.</param>
 /// <returns></returns>
 internal int LinearSearch(InternalItem searchItem, List <string> localIdentityTagNames)
 {
     try
     {
         for (int i = 0; i < Count; i++)
         {
             if (ByteArrayComparerUtil.CompareByteArrays(this[i].ItemId, searchItem.ItemId))
             {
                 if (EqualsLocalId(this[i], searchItem, localIdentityTagNames))
                 {
                     return(i);
                 }
             }
         }
         return(-1);
     }
     catch (Exception ex)
     {
         throw new Exception("Error in Linear Search.", ex);
     }
 }