Lucene.Net.Index.SegmentInfos.Read C# (CSharp) Method

Read() public method

Find the latest commit ({@code segments_N file}) and load all SegmentCommitInfos.
public Read ( Directory directory ) : void
directory Directory
return void
        public void Read(Directory directory)
        {
            _generation = _lastGeneration = -1;

            new FindSegmentsFileAnonymousInnerClassHelper(this, directory).Run();
        }

Same methods

SegmentInfos::Read ( Directory directory, string segmentFileName ) : void

Usage Example

Ejemplo n.º 1
0
        /// <summary> Current version number from segments file.</summary>
        public static long ReadCurrentVersion(Directory directory)
        {
            IndexInput input = directory.OpenInput(IndexFileNames.SEGMENTS);
            int format = 0;
            long version = 0;
            try
            {
                format = input.ReadInt();
                if (format < 0)
                {
                    if (format < FORMAT)
                        throw new System.IO.IOException("Unknown format version: " + format);
                    version = input.ReadLong(); // read version
                }
            }
            finally
            {
                input.Close();
            }

            if (format < 0)
                return version;

            // We cannot be sure about the format of the file.
            // Therefore we have to read the whole file and cannot simply seek to the version entry.

            SegmentInfos sis = new SegmentInfos();
            sis.Read(directory);
            return sis.GetVersion();
        }
All Usage Examples Of Lucene.Net.Index.SegmentInfos::Read