internal void DecRef(SegmentInfos segmentInfos) { Debug.Assert(IsLocked); foreach (string file in segmentInfos.GetFiles(directory, false)) { DecRef(file); } }
internal ReaderCommit(SegmentInfos infos, Directory dir) { segmentsFileName = infos.GetSegmentsFileName(); this.dir = dir; userData = infos.UserData; files = infos.GetFiles(dir, true); generation = infos.Generation; segmentCount = infos.Count; }
public CommitPoint(ICollection <CommitPoint> commitsToDelete, Directory directory, SegmentInfos segmentInfos) { this.directory = directory; this.commitsToDelete = commitsToDelete; userData = segmentInfos.UserData; segmentsFileName = segmentInfos.GetSegmentsFileName(); generation = segmentInfos.Generation; files = segmentInfos.GetFiles(directory, true); segmentCount = segmentInfos.Count; }
internal void IncRef(SegmentInfos segmentInfos, bool isCommit) { Debug.Assert(IsLocked); // If this is a commit point, also incRef the // segments_N file: foreach (string fileName in segmentInfos.GetFiles(directory, isCommit)) { IncRef(fileName); } }
/// <summary> /// For definition of "check point" see <see cref="IndexWriter"/> comments: /// "Clarification: Check Points (and commits)". /// <para/> /// Writer calls this when it has made a "consistent /// change" to the index, meaning new files are written to /// the index and the in-memory <see cref="SegmentInfos"/> have been /// modified to point to those files. /// <para/> /// This may or may not be a commit (segments_N may or may /// not have been written). /// <para/> /// We simply incref the files referenced by the new /// <see cref="SegmentInfos"/> and decref the files we had previously /// seen (if any). /// <para/> /// If this is a commit, we also call the policy to give it /// a chance to remove other commits. If any commits are /// removed, we decref their files as well. /// </summary> public void Checkpoint(SegmentInfos segmentInfos, bool isCommit) { if (Debugging.AssertsEnabled) { Debugging.Assert(IsLocked); } if (Debugging.AssertsEnabled) { Debugging.Assert(Monitor.IsEntered(writer)); } long t0 = 0; if (infoStream.IsEnabled("IFD")) { t0 = Time.NanoTime(); infoStream.Message("IFD", "now checkpoint \"" + writer.SegString(writer.ToLiveInfos(segmentInfos).Segments) + "\" [" + segmentInfos.Count + " segments " + "; isCommit = " + isCommit + "]"); } // Try again now to delete any previously un-deletable // files (because they were in use, on Windows): DeletePendingFiles(); // Incref the files: IncRef(segmentInfos, isCommit); if (isCommit) { // Append to our commits list: commits.Add(new CommitPoint(commitsToDelete, directory, segmentInfos)); // Tell policy so it can remove commits: policy.OnCommit(commits); // Decref files for commits that were deleted by the policy: DeleteCommits(); } else { // DecRef old files from the last checkpoint, if any: DecRef(lastFiles); lastFiles.Clear(); // Save files so we can decr on next checkpoint/commit: lastFiles.AddRange(segmentInfos.GetFiles(directory, false)); } if (infoStream.IsEnabled("IFD")) { long t1 = Time.NanoTime(); infoStream.Message("IFD", ((t1 - t0) / 1000000) + " msec to checkpoint"); } }