public Files ( Directory dir, bool includeSegmentsFile ) : ICollection |
||
dir | Directory | |
includeSegmentsFile | bool | |
return | ICollection |
internal void DecRef(SegmentInfos segmentInfos) { foreach (string file in segmentInfos.Files(directory, false)) { DecRef(file); } }
internal void DecRef(SegmentInfos segmentInfos) { Debug.Assert(IsLocked); foreach (string file in segmentInfos.Files(directory, false)) { DecRef(file); } }
internal void DecRef(SegmentInfos segmentInfos) { System.Collections.Generic.IEnumerator <string> it = segmentInfos.Files(directory, false).GetEnumerator(); while (it.MoveNext()) { DecRef(it.Current); } }
internal ReaderCommit(SegmentInfos infos, Directory dir) { segmentsFileName = infos.GetSegmentsFileName(); this.dir = dir; userData = infos.UserData; files = infos.Files(dir, true); generation = infos.Generation; segmentCount = infos.Count; }
internal ReaderCommit(SegmentInfos infos, Directory dir) { SegmentsFileName_Renamed = infos.SegmentsFileName; this.Dir = dir; UserData_Renamed = infos.UserData; Files = infos.Files(dir, true); Generation_Renamed = infos.Generation; SegmentCount_Renamed = infos.Size(); }
internal void IncRef(SegmentInfos segmentInfos, bool isCommit) { // If this is a commit point, also incRef the // segments_N file: foreach (string fileName in segmentInfos.Files(directory, isCommit)) { IncRef(fileName); } }
internal void IncRef(SegmentInfos segmentInfos, bool isCommit) { // If this is a commit point, also incRef the // segments_N file: System.Collections.Generic.IEnumerator <string> it = segmentInfos.Files(directory, isCommit).GetEnumerator(); while (it.MoveNext()) { IncRef(it.Current); } }
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.Files(directory, true); segmentCount = segmentInfos.Count; }
public CommitPoint(ICollection <CommitPoint> commitsToDelete, Directory directory, SegmentInfos segmentInfos) { this.Directory_Renamed = directory; this.CommitsToDelete = commitsToDelete; UserData_Renamed = segmentInfos.UserData; SegmentsFileName_Renamed = segmentInfos.SegmentsFileName; Generation_Renamed = segmentInfos.Generation; Files = segmentInfos.Files(directory, true); SegmentCount_Renamed = segmentInfos.Size(); }
internal void IncRef(SegmentInfos segmentInfos, bool isCommit) { Debug.Assert(Locked()); // If this is a commit point, also incRef the // segments_N file: foreach (String fileName in segmentInfos.Files(Directory, isCommit)) { IncRef(fileName); } }
/// <summary>Construct reading the named set of readers. </summary> internal DirectoryReader(Directory directory, SegmentInfos sis, IndexDeletionPolicy deletionPolicy, bool readOnly, int termInfosIndexDivisor) { this.directory = directory; this.readOnly = readOnly; this.segmentInfos = sis; this.deletionPolicy = deletionPolicy; this.termInfosIndexDivisor = termInfosIndexDivisor; if (!readOnly) { // We assume that this segments_N was previously // properly sync'd: SupportClass.CollectionsHelper.AddAllIfNotContains(synced, sis.Files(directory, true)); } // To reduce the chance of hitting FileNotFound // (and having to retry), we open segments in // reverse because IndexWriter merges & deletes // the newest segments first. SegmentReader[] readers = new SegmentReader[sis.Count]; for (int i = sis.Count - 1; i >= 0; i--) { bool success = false; try { readers[i] = SegmentReader.Get(readOnly, sis.Info(i), termInfosIndexDivisor); success = true; } finally { if (!success) { // Close all readers we had opened: for (i++; i < sis.Count; i++) { try { readers[i].Close(); } catch (System.Exception ignore) { // keep going - we want to clean up as much as possible } } } } } Initialize(readers); }
public CommitPoint(IndexFileDeleter enclosingInstance, System.Collections.ICollection commitsToDelete, Directory directory, SegmentInfos segmentInfos) { InitBlock(enclosingInstance); this.directory = directory; this.commitsToDelete = commitsToDelete; userData = segmentInfos.GetUserData(); segmentsFileName = segmentInfos.GetCurrentSegmentFileName(); version = segmentInfos.GetVersion(); generation = segmentInfos.GetGeneration(); files = segmentInfos.Files(directory, true); gen = segmentInfos.GetGeneration(); isOptimized = segmentInfos.Count == 1 && !segmentInfos.Info(0).HasDeletions(); System.Diagnostics.Debug.Assert(!segmentInfos.HasExternalSegments(directory)); }
/// <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) { Debug.Assert(IsLocked); //Debug.Assert(Thread.holdsLock(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.Files(directory, false)); } if (infoStream.IsEnabled("IFD")) { long t1 = Time.NanoTime(); infoStream.Message("IFD", ((t1 - t0) / 1000000) + " msec to checkpoint"); } }
internal ReaderCommit(SegmentInfos infos, Directory dir) { segmentsFileName = infos.GetCurrentSegmentFileName(); this.dir = dir; userData = infos.GetUserData(); files = System.Collections.ArrayList.ReadOnly(new System.Collections.ArrayList(infos.Files(dir, true))); version = infos.GetVersion(); generation = infos.GetGeneration(); isOptimized = infos.Count == 1 && !infos.Info(0).HasDeletions(); }
/// <summary> For definition of "check point" see IndexWriter comments: /// "Clarification: Check Points (and commits)". /// /// 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 SegmentInfos have been /// modified to point to those files. /// /// This may or may not be a commit (segments_N may or may /// not have been written). /// /// We simply incref the files referenced by the new /// SegmentInfos and decref the files we had previously /// seen (if any). /// /// 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 (infoStream != null) { Message("now checkpoint \"" + segmentInfos.GetCurrentSegmentFileName() + "\" [" + 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(this, 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 { System.Collections.Generic.IList<string> docWriterFiles; if (docWriter != null) { docWriterFiles = docWriter.OpenFiles(); if (docWriterFiles != null) // We must incRef these files before decRef'ing // last files to make sure we don't accidentally // delete them: IncRef(docWriterFiles); } else docWriterFiles = null; // DecRef old files from the last checkpoint, if any: int size = lastFiles.Count; if (size > 0) { for (int i = 0; i < size; i++) DecRef(lastFiles[i]); lastFiles.Clear(); } // Save files so we can decr on next checkpoint/commit: foreach (string fname in segmentInfos.Files(directory, false)) { lastFiles.Add(fname); } if (docWriterFiles != null) { foreach (string fname in docWriterFiles) { lastFiles.Add(fname); } } } }
// called only from assert private bool FilesExist(SegmentInfos toSync) { ICollection<string> files = toSync.Files(directory, false); foreach (String fileName in files) { Debug.Assert(SlowFileExists(directory, fileName), "file " + fileName + " does not exist; files=" + Arrays.ToString(directory.ListAll())); // If this trips it means we are missing a call to // .checkpoint somewhere, because by the time we // are called, deleter should know about every // file referenced by the current head // segmentInfos: Debug.Assert(Deleter.Exists(fileName), "IndexFileDeleter doesn't know about file " + fileName); } return true; }
/// <summary> /// Walk through all files referenced by the current /// segmentInfos and ask the Directory to sync each file, /// if it wasn't already. If that succeeds, then we /// prepare a new segments_N file but do not fully commit /// it. /// </summary> private void StartCommit(SegmentInfos toSync) { Debug.Assert(TestPoint("startStartCommit")); Debug.Assert(PendingCommit == null); if (HitOOM) { throw new InvalidOperationException("this writer hit an OutOfMemoryError; cannot commit"); } try { if (infoStream.IsEnabled("IW")) { infoStream.Message("IW", "startCommit(): start"); } lock (this) { Debug.Assert(LastCommitChangeCount <= ChangeCount, "lastCommitChangeCount=" + LastCommitChangeCount + " changeCount=" + ChangeCount); if (PendingCommitChangeCount == LastCommitChangeCount) { if (infoStream.IsEnabled("IW")) { infoStream.Message("IW", " skip startCommit(): no changes pending"); } Deleter.DecRef(FilesToCommit); FilesToCommit = null; return; } if (infoStream.IsEnabled("IW")) { infoStream.Message("IW", "startCommit index=" + SegString(ToLiveInfos(toSync).Segments) + " changeCount=" + ChangeCount); } Debug.Assert(FilesExist(toSync)); } Debug.Assert(TestPoint("midStartCommit")); bool pendingCommitSet = false; try { Debug.Assert(TestPoint("midStartCommit2")); lock (this) { Debug.Assert(PendingCommit == null); Debug.Assert(segmentInfos.Generation == toSync.Generation); // Exception here means nothing is prepared // (this method unwinds everything it did on // an exception) toSync.PrepareCommit(directory); //System.out.println("DONE prepareCommit"); pendingCommitSet = true; PendingCommit = toSync; } // this call can take a long time -- 10s of seconds // or more. We do it without syncing on this: bool success = false; ICollection<string> filesToSync; try { filesToSync = toSync.Files(directory, false); directory.Sync(filesToSync); success = true; } finally { if (!success) { pendingCommitSet = false; PendingCommit = null; toSync.RollbackCommit(directory); } } if (infoStream.IsEnabled("IW")) { infoStream.Message("IW", "done all syncs: " + filesToSync); } Debug.Assert(TestPoint("midStartCommitSuccess")); } finally { lock (this) { // Have our master segmentInfos record the // generations we just prepared. We do this // on error or success so we don't // double-write a segments_N file. segmentInfos.UpdateGeneration(toSync); if (!pendingCommitSet) { if (infoStream.IsEnabled("IW")) { infoStream.Message("IW", "hit exception committing segments file"); } // Hit exception Deleter.DecRef(FilesToCommit); FilesToCommit = null; } } } } catch (System.OutOfMemoryException oom) { HandleOOM(oom, "startCommit"); } Debug.Assert(TestPoint("finishStartCommit")); }
// Used by near real-time search internal DirectoryReader(IndexWriter writer, SegmentInfos infos, int termInfosIndexDivisor) { this.internalDirectory = writer.Directory; this.readOnly = true; segmentInfos = infos; segmentInfosStart = (SegmentInfos) infos.Clone(); this.termInfosIndexDivisor = termInfosIndexDivisor; if (!readOnly) { // We assume that this segments_N was previously // properly sync'd: synced.UnionWith(infos.Files(internalDirectory, true)); } // IndexWriter synchronizes externally before calling // us, which ensures infos will not change; so there's // no need to process segments in reverse order int numSegments = infos.Count; var readers = new SegmentReader[numSegments]; Directory dir = writer.Directory; int upto = 0; for (int i = 0; i < numSegments; i++) { bool success = false; try { SegmentInfo info = infos.Info(i); if (info.dir == dir) { readers[upto++] = writer.readerPool.GetReadOnlyClone(info, true, termInfosIndexDivisor); } success = true; } finally { if (!success) { // Close all readers we had opened: for (upto--; upto >= 0; upto--) { try { readers[upto].Close(); } catch (System.Exception) { // keep going - we want to clean up as much as possible } } } } } this.writer = writer; if (upto < readers.Length) { // This means some segments were in a foreign Directory var newReaders = new SegmentReader[upto]; Array.Copy(readers, 0, newReaders, 0, upto); readers = newReaders; } Initialize(readers); }
/// <summary>This constructor is only used for <see cref="Reopen()" /> </summary> internal DirectoryReader(Directory directory, SegmentInfos infos, SegmentReader[] oldReaders, int[] oldStarts, IEnumerable<KeyValuePair<string, byte[]>> oldNormsCache, bool readOnly, bool doClone, int termInfosIndexDivisor) { this.internalDirectory = directory; this.readOnly = readOnly; this.segmentInfos = infos; this.termInfosIndexDivisor = termInfosIndexDivisor; if (!readOnly) { // We assume that this segments_N was previously // properly sync'd: synced.UnionWith(infos.Files(directory, true)); } // we put the old SegmentReaders in a map, that allows us // to lookup a reader using its segment name IDictionary<string, int> segmentReaders = new HashMap<string, int>(); if (oldReaders != null) { // create a Map SegmentName->SegmentReader for (int i = 0; i < oldReaders.Length; i++) { segmentReaders[oldReaders[i].SegmentName] = i; } } var newReaders = new SegmentReader[infos.Count]; // remember which readers are shared between the old and the re-opened // DirectoryReader - we have to incRef those readers var readerShared = new bool[infos.Count]; for (int i = infos.Count - 1; i >= 0; i--) { // find SegmentReader for this segment if (!segmentReaders.ContainsKey(infos.Info(i).name)) { // this is a new segment, no old SegmentReader can be reused newReaders[i] = null; } else { // there is an old reader for this segment - we'll try to reopen it newReaders[i] = oldReaders[segmentReaders[infos.Info(i).name]]; } bool success = false; try { SegmentReader newReader; if (newReaders[i] == null || infos.Info(i).GetUseCompoundFile() != newReaders[i].SegmentInfo.GetUseCompoundFile()) { // We should never see a totally new segment during cloning System.Diagnostics.Debug.Assert(!doClone); // this is a new reader; in case we hit an exception we can close it safely newReader = SegmentReader.Get(readOnly, infos.Info(i), termInfosIndexDivisor); } else { newReader = newReaders[i].ReopenSegment(infos.Info(i), doClone, readOnly); } if (newReader == newReaders[i]) { // this reader will be shared between the old and the new one, // so we must incRef it readerShared[i] = true; newReader.IncRef(); } else { readerShared[i] = false; newReaders[i] = newReader; } success = true; } finally { if (!success) { for (i++; i < infos.Count; i++) { if (newReaders[i] != null) { try { if (!readerShared[i]) { // this is a new subReader that is not used by the old one, // we can close it newReaders[i].Close(); } else { // this subReader is also used by the old reader, so instead // closing we must decRef it newReaders[i].DecRef(); } } catch (System.IO.IOException) { // keep going - we want to clean up as much as possible } } } } } } // initialize the readers to calculate maxDoc before we try to reuse the old normsCache Initialize(newReaders); // try to copy unchanged norms from the old normsCache to the new one if (oldNormsCache != null) { foreach(var entry in oldNormsCache) { String field = entry.Key; if (!HasNorms(field)) { continue; } byte[] oldBytes = entry.Value; var bytes = new byte[MaxDoc]; for (int i = 0; i < subReaders.Length; i++) { int oldReaderIndex = segmentReaders[subReaders[i].SegmentName]; // this SegmentReader was not re-opened, we can copy all of its norms if (segmentReaders.ContainsKey(subReaders[i].SegmentName) && (oldReaders[oldReaderIndex] == subReaders[i] || oldReaders[oldReaderIndex].norms[field] == subReaders[i].norms[field])) { // we don't have to synchronize here: either this constructor is called from a SegmentReader, // in which case no old norms cache is present, or it is called from MultiReader.reopen(), // which is synchronized Array.Copy(oldBytes, oldStarts[oldReaderIndex], bytes, starts[i], starts[i + 1] - starts[i]); } else { subReaders[i].Norms(field, bytes, starts[i]); } } normsCache[field] = bytes; // update cache } } }
internal void IncRef(SegmentInfos segmentInfos, bool isCommit) { Debug.Assert(Locked()); // If this is a commit point, also incRef the // segments_N file: foreach (String fileName in segmentInfos.Files(Directory, isCommit)) { IncRef(fileName); } }
internal ReaderCommit(SegmentInfos infos, Directory dir) { segmentsFileName = infos.GetCurrentSegmentFileName(); this.dir = dir; userData = infos.UserData; files = infos.Files(dir, true); version = infos.Version; generation = infos.Generation; isOptimized = infos.Count == 1 && !infos.Info(0).HasDeletions(); }
public CommitPoint(ICollection<CommitPoint> commitsToDelete, Directory directory, SegmentInfos segmentInfos) { this.Directory_Renamed = directory; this.CommitsToDelete = commitsToDelete; UserData_Renamed = segmentInfos.UserData; SegmentsFileName_Renamed = segmentInfos.SegmentsFileName; Generation_Renamed = segmentInfos.Generation; Files = segmentInfos.Files(directory, true); SegmentCount_Renamed = segmentInfos.Size(); }
/// <summary> /// For definition of "check point" see IndexWriter comments: /// "Clarification: Check Points (and commits)". /// /// 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 SegmentInfos have been /// modified to point to those files. /// /// this may or may not be a commit (segments_N may or may /// not have been written). /// /// We simply incref the files referenced by the new /// SegmentInfos and decref the files we had previously /// seen (if any). /// /// 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) { Debug.Assert(Locked()); //Debug.Assert(Thread.holdsLock(Writer)); long t0 = 0; if (InfoStream.IsEnabled("IFD")) { t0 = DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond; InfoStream.Message("IFD", "now checkpoint \"" + Writer.SegString(Writer.ToLiveInfos(segmentInfos).Segments) + "\" [" + segmentInfos.Size() + " 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.Files(Directory, false)); } if (InfoStream.IsEnabled("IFD")) { long t1 = DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond; InfoStream.Message("IFD", ((t1 - t0) / 1000000) + " msec to checkpoint"); } }
internal void DecRef(SegmentInfos segmentInfos) { System.Collections.Generic.IEnumerator<string> it = segmentInfos.Files(directory, false).GetEnumerator(); while (it.MoveNext()) { DecRef(it.Current); } }
internal void IncRef(SegmentInfos segmentInfos, bool isCommit) { // If this is a commit point, also incRef the // segments_N file: System.Collections.IEnumerator it = segmentInfos.Files(directory, isCommit).GetEnumerator(); while (it.MoveNext()) { IncRef((System.String) ((System.Collections.DictionaryEntry) it.Current).Key); } }
public CommitPoint(IndexFileDeleter enclosingInstance, System.Collections.ICollection commitsToDelete, Directory directory, SegmentInfos segmentInfos) { InitBlock(enclosingInstance); this.directory = directory; this.commitsToDelete = commitsToDelete; userData = segmentInfos.GetUserData(); segmentsFileName = segmentInfos.GetCurrentSegmentFileName(); version = segmentInfos.GetVersion(); generation = segmentInfos.GetGeneration(); files = segmentInfos.Files(directory, true); gen = segmentInfos.GetGeneration(); isOptimized = segmentInfos.Count == 1 && !segmentInfos.Info(0).HasDeletions(); System.Diagnostics.Debug.Assert(!segmentInfos.HasExternalSegments(directory)); }
/// <summary> For definition of "check point" see IndexWriter comments: /// "Clarification: Check Points (and commits)". /// /// 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 SegmentInfos have been /// modified to point to those files. /// /// This may or may not be a commit (segments_N may or may /// not have been written). /// /// We simply incref the files referenced by the new /// SegmentInfos and decref the files we had previously /// seen (if any). /// /// 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 (infoStream != null) { Message("now checkpoint \"" + segmentInfos.GetCurrentSegmentFileName() + "\" [" + 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(this, 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 { System.Collections.Generic.IList <string> docWriterFiles; if (docWriter != null) { docWriterFiles = docWriter.OpenFiles(); if (docWriterFiles != null) { // We must incRef these files before decRef'ing // last files to make sure we don't accidentally // delete them: IncRef(docWriterFiles); } } else { docWriterFiles = null; } // DecRef old files from the last checkpoint, if any: int size = lastFiles.Count; if (size > 0) { for (int i = 0; i < size; i++) { DecRef(lastFiles[i]); } lastFiles.Clear(); } // Save files so we can decr on next checkpoint/commit: foreach (string fname in segmentInfos.Files(directory, false)) { lastFiles.Add(fname); } if (docWriterFiles != null) { foreach (string fname in docWriterFiles) { lastFiles.Add(fname); } } } }
internal ReaderCommit(SegmentInfos infos, Directory dir) { SegmentsFileName_Renamed = infos.SegmentsFileName; this.Dir = dir; UserData_Renamed = infos.UserData; Files = infos.Files(dir, true); Generation_Renamed = infos.Generation; SegmentCount_Renamed = infos.Size(); }
internal void IncRef(SegmentInfos segmentInfos, bool isCommit) { // If this is a commit point, also incRef the // segments_N file: System.Collections.Generic.IEnumerator<string> it = segmentInfos.Files(directory, isCommit).GetEnumerator(); while (it.MoveNext()) { IncRef(it.Current); } }
internal void DecRef(SegmentInfos segmentInfos) { Debug.Assert(Locked()); foreach (String file in segmentInfos.Files(Directory, false)) { DecRef(file); } }
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; }
internal void DecRef(SegmentInfos segmentInfos) { System.Collections.IEnumerator it = segmentInfos.Files(directory, false).GetEnumerator(); while (it.MoveNext()) { DecRef((System.String)((System.Collections.DictionaryEntry) it.Current).Key); } }