Beispiel #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();
        }
Beispiel #2
0
            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));
            }
            internal ReaderCommit(SegmentInfos infos, Directory dir)
            {
                segmentsFileName = infos.GetCurrentSegmentFileName();
                this.dir         = dir;
                int size = infos.Count;

                files = new List <string>(size);
                files.Add(segmentsFileName);
                for (int i = 0; i < size; i++)
                {
                    SegmentInfo info = infos.Info(i);
                    if (info.dir == dir)
                    {
                        SupportClass.CollectionsSupport.AddAll(info.Files(), files);
                    }
                }
                version     = infos.GetVersion();
                generation  = infos.GetGeneration();
                isOptimized = infos.Count == 1 && !infos.Info(0).HasDeletions();
            }
            public CommitPoint(IndexFileDeleter enclosingInstance, ICollection <IndexCommitPoint> commitsToDelete, Directory directory, SegmentInfos segmentInfos)
            {
                InitBlock(enclosingInstance);
                this.directory       = directory;
                this.commitsToDelete = commitsToDelete;
                segmentsFileName     = segmentInfos.GetCurrentSegmentFileName();
                version    = segmentInfos.GetVersion();
                generation = segmentInfos.GetGeneration();
                int size = segmentInfos.Count;

                files = new List <string>(size);
                files.Add(segmentsFileName);
                gen = segmentInfos.GetGeneration();
                for (int i = 0; i < size; i++)
                {
                    SegmentInfo segmentInfo = segmentInfos.Info(i);
                    if (segmentInfo.dir == Enclosing_Instance.directory)
                    {
                        SupportClass.CollectionsSupport.AddAll(segmentInfo.Files(), files);
                    }
                }
                isOptimized = segmentInfos.Count == 1 && !segmentInfos.Info(0).HasDeletions();
            }
Beispiel #5
0
            public override System.Object DoBody(System.String segmentFileName)
            {
                IndexInput input = directory.OpenInput(segmentFileName);

                int  format  = 0;
                long version = 0;

                try
                {
                    format = input.ReadInt();
                    if (format < 0)
                    {
                        if (format < Lucene.Net.Index.SegmentInfos.FORMAT_SINGLE_NORM_FILE)
                        {
                            throw new System.IO.IOException("Unknown format version: " + format);
                        }
                        version = input.ReadLong();                         // read version
                    }
                }
                finally
                {
                    input.Close();
                }

                if (format < 0)
                {
                    return((long)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, segmentFileName);
                return((long)sis.GetVersion());
            }
Beispiel #6
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());
        }
            protected internal override object DoBody(System.String segmentFileName)
            {
                IndexInput input = directory.OpenInput(segmentFileName);

                int format = 0;
                long version = 0;
                try
                {
                    format = input.ReadInt();
                    if (format < 0)
                    {
                        if (format < Lucene.Net.Index.SegmentInfos.CURRENT_FORMAT)
                            throw new CorruptIndexException("Unknown format version: " + format);
                        version = input.ReadLong(); // read version
                    }
                }
                finally
                {
                    input.Close();
                }

                if (format < 0)
                    return (long) 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, segmentFileName);
                return (long) sis.GetVersion();
            }
Beispiel #8
0
            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));
            }
 internal ReaderCommit(SegmentInfos infos, Directory dir)
 {
     segmentsFileName = infos.GetCurrentSegmentFileName();
     this.dir = dir;
     int size = infos.Count;
     files = new List<string>(size);
     files.Add(segmentsFileName);
     for (int i = 0; i < size; i++)
     {
         SegmentInfo info = infos.Info(i);
         if (info.dir == dir)
             SupportClass.CollectionsSupport.AddAll(info.Files(), files);
     }
     version = infos.GetVersion();
     generation = infos.GetGeneration();
     isOptimized = infos.Count == 1 && !infos.Info(0).HasDeletions();
 }
Beispiel #10
0
 /// <summary> Version number when this IndexReader was opened.</summary>
 public virtual long GetVersion()
 {
     return(segmentInfos.GetVersion());
 }
		/// <summary> Version number when this IndexReader was opened.</summary>
		public override long GetVersion()
		{
			EnsureOpen();
			return segmentInfos.GetVersion();
		}
			internal ReaderCommit(SegmentInfos infos, Directory dir)
			{
				segmentsFileName = infos.GetCurrentSegmentFileName();
				this.dir = dir;
				userData = infos.GetUserData();
                files = infos.Files(dir, true);
				version = infos.GetVersion();
				generation = infos.GetGeneration();
				isOptimized = infos.Count == 1 && !infos.Info(0).HasDeletions();
			}
 public CommitPoint(IndexFileDeleter enclosingInstance, ICollection<IndexCommitPoint> commitsToDelete, Directory directory, SegmentInfos segmentInfos)
 {
     InitBlock(enclosingInstance);
     this.directory = directory;
     this.commitsToDelete = commitsToDelete;
     segmentsFileName = segmentInfos.GetCurrentSegmentFileName();
     version = segmentInfos.GetVersion();
     generation = segmentInfos.GetGeneration();
     int size = segmentInfos.Count;
     files = new List<string>(size);
     files.Add(segmentsFileName);
     gen = segmentInfos.GetGeneration();
     for (int i = 0; i < size; i++)
     {
         SegmentInfo segmentInfo = segmentInfos.Info(i);
         if (segmentInfo.dir == Enclosing_Instance.directory)
         {
             SupportClass.CollectionsSupport.AddAll(segmentInfo.Files(), files);
         }
     }
     isOptimized = segmentInfos.Count == 1 && !segmentInfos.Info(0).HasDeletions();
 }