Example #1
0
        protected override void HandleCommitPoints(IndexedItemsInfo itemsInfo, IndexSegmentsInfo segmentsInfo)
        {
            if (ShouldStoreCommitPoint(itemsInfo) && itemsInfo.HighestETag != null)
            {
                context.IndexStorage.StoreCommitPoint(indexId.ToString(), new IndexCommitPoint
                {
                    HighestCommitedETag = itemsInfo.HighestETag,
                    TimeStamp           = LastIndexTime,
                    SegmentsInfo        = segmentsInfo ?? IndexStorage.GetCurrentSegmentsInfo(indexDefinition.Name, directory)
                });

                LastCommitPointStoreTime = SystemTime.UtcNow;
            }
            else if (itemsInfo.DeletedKeys != null && directory is RAMDirectory == false)
            {
                context.IndexStorage.AddDeletedKeysToCommitPoints(indexDefinition, itemsInfo.DeletedKeys);
            }
        }
Example #2
0
		protected bool Equals(IndexSegmentsInfo other)
		{
			var theSameNumberOfItems = ReferencedFiles.Count == other.ReferencedFiles.Count;
			var theSameReferencedFiles = true;

			if (theSameNumberOfItems)
			{
				if (ReferencedFiles.Any(file => other.ReferencedFiles.Contains(file) == false))
					theSameReferencedFiles = false;
			}
			else
				theSameReferencedFiles = false;

			return theSameReferencedFiles &&
				Generation == other.Generation &&
				string.Equals(SegmentsFileName, other.SegmentsFileName) &&
				IsIndexCorrupted.Equals(other.IsIndexCorrupted);
		}
Example #3
0
        protected bool Equals(IndexSegmentsInfo other)
        {
            var theSameNumberOfItems   = ReferencedFiles.Count == other.ReferencedFiles.Count;
            var theSameReferencedFiles = true;

            if (theSameNumberOfItems)
            {
                if (ReferencedFiles.Any(file => other.ReferencedFiles.Contains(file) == false))
                {
                    theSameReferencedFiles = false;
                }
            }
            else
            {
                theSameReferencedFiles = false;
            }

            return(theSameReferencedFiles &&
                   Generation == other.Generation &&
                   string.Equals(SegmentsFileName, other.SegmentsFileName) &&
                   IsIndexCorrupted.Equals(other.IsIndexCorrupted));
        }
Example #4
0
        private IndexSegmentsInfo GetCurrentSegmentsInfo()
        {
            var segmentInfos = new SegmentInfos();
            var result       = new IndexSegmentsInfo();

            try
            {
                segmentInfos.Read(directory);

                result.Generation       = segmentInfos.Generation;
                result.SegmentsFileName = segmentInfos.GetCurrentSegmentFileName();
                result.ReferencedFiles  = segmentInfos.Files(directory, false);
            }
            catch (CorruptIndexException ex)
            {
                logIndexing.WarnException(string.Format("Could not read segment information for an index '{0}'", indexId), ex);

                result.IsIndexCorrupted = true;
            }

            return(result);
        }
Example #5
0
		protected override void HandleCommitPoints(IndexedItemsInfo itemsInfo, IndexSegmentsInfo segmentsInfo)
		{
			if (ShouldStoreCommitPoint(itemsInfo) && itemsInfo.HighestETag != null)
			{
				context.IndexStorage.StoreCommitPoint(indexId.ToString(), new IndexCommitPoint
				{
					HighestCommitedETag = itemsInfo.HighestETag,
					TimeStamp = LastIndexTime,
					SegmentsInfo = segmentsInfo ?? IndexStorage.GetCurrentSegmentsInfo(indexDefinition.Name, directory)
				});

				LastCommitPointStoreTime = SystemTime.UtcNow;
			}
			else if (itemsInfo.DeletedKeys != null && directory is RAMDirectory == false)
			{
				context.IndexStorage.AddDeletedKeysToCommitPoints(indexDefinition, itemsInfo.DeletedKeys);
			}
		}
Example #6
0
        public static IndexSegmentsInfo GetCurrentSegmentsInfo(string indexName, Lucene.Net.Store.Directory directory)
        {
            var segmentInfos = new SegmentInfos();
            var result = new IndexSegmentsInfo();

            try
            {
                segmentInfos.Read(directory);

                result.Generation = segmentInfos.Generation;
                result.SegmentsFileName = segmentInfos.GetCurrentSegmentFileName();
                result.ReferencedFiles = segmentInfos.Files(directory, false);
            }
            catch (CorruptIndexException ex)
            {
                log.WarnException(string.Format("Could not read segment information for an index '{0}'", indexName), ex);

                result.IsIndexCorrupted = true;
            }

            return result;
        }
Example #7
0
		protected abstract void HandleCommitPoints(IndexedItemsInfo itemsInfo, IndexSegmentsInfo segmentsInfo);
		protected override void HandleCommitPoints(IndexedItemsInfo itemsInfo, IndexSegmentsInfo segmentsInfo)
		{
			// MapReduce index does not store and use any commit points
		}
Example #9
0
 protected override void HandleCommitPoints(IndexedItemsInfo itemsInfo, IndexSegmentsInfo segmentsInfo)
 {
     // MapReduce index does not store and use any commit points
 }