public void  Read(Directory directory)
		{
			
			InputStream input = directory.OpenFile("segments");
			try
			{
				int format = input.ReadInt();
				if (format < 0)
				{
					// file contains explicit format info
					// check that it is a format we can understand
					if (format < FORMAT)
						throw new System.IO.IOException("Unknown format version: " + format);
					version = input.ReadLong(); // read version
					counter = input.ReadInt(); // read counter
				}
				else
				{
					// file is in old format without explicit format info
					counter = format;
				}
				
				for (int i = input.ReadInt(); i > 0; i--)
				{
					// read segmentInfos
					SegmentInfo si = new SegmentInfo(input.ReadString(), input.ReadInt(), directory);
					Add(si);
				}
				
				if (format >= 0)
				{
					// in old format the version number may be at the end of the file
					if (input.GetFilePointer() >= input.Length())
						version = 0;
					// old file format without version number
					else
						version = input.ReadLong(); // read version
				}
			}
			finally
			{
				input.Close();
			}
		}
		public /*internal*/ SegmentReader(SegmentInfos sis, SegmentInfo si, bool closeDir) : base(si.dir, sis, closeDir)
		{
			Initialize(si);
		}
		internal static bool HasSeparateNorms(SegmentInfo si)
		{
			System.String[] result = si.dir.List();
			System.String pattern = si.name + ".f";
			int patternLength = pattern.Length;
			for (int i = 0; i < 0; i++)
			{
				if (result[i].StartsWith(pattern) && System.Char.IsDigit(result[i][patternLength]))
					return true;
			}
			return false;
		}
		internal static bool UsesCompoundFile(SegmentInfo si)
		{
			return si.dir.FileExists(si.name + ".cfs");
		}
		internal static bool HasDeletions(SegmentInfo si)
		{
			return si.dir.FileExists(si.name + ".del");
		}
		private void  Initialize(SegmentInfo si)
		{
			segment = si.name;
			
			// Use compound file directory for some files, if it exists
			Directory cfsDir = Directory();
			if (Directory().FileExists(segment + ".cfs"))
			{
				cfsReader = new CompoundFileReader(Directory(), segment + ".cfs");
				cfsDir = cfsReader;
			}
			
			// No compound file exists - use the multi-file format
			fieldInfos = new FieldInfos(cfsDir, segment + ".fnm");
			fieldsReader = new FieldsReader(cfsDir, segment, fieldInfos);
			
			tis = new TermInfosReader(cfsDir, segment, fieldInfos);
			
			// NOTE: the bitvector is stored using the regular directory, not cfs
			if (HasDeletions(si))
				deletedDocs = new BitVector(Directory(), segment + ".del");
			
			// make sure that all index files have been read or are kept open
			// so that if an index update removes them we'll still have them
			freqStream = cfsDir.OpenFile(segment + ".frq");
			proxStream = cfsDir.OpenFile(segment + ".prx");
			OpenNorms(cfsDir);
			
			if (fieldInfos.HasVectors())
			{
				// open term vector files only as needed
				termVectorsReader = new TermVectorsReader(cfsDir, segment, fieldInfos);
			}
		}
		public /*internal*/ SegmentReader(SegmentInfo si) : base(si.dir)
		{
			Initialize(si);
		}
Пример #8
0
 public /*internal*/ SegmentReader(SegmentInfos sis, SegmentInfo si, bool closeDir) : base(si.dir, sis, closeDir)
 {
     Initialize(si);
 }
Пример #9
0
 internal static bool UsesCompoundFile(SegmentInfo si)
 {
     return(si.dir.FileExists(si.name + ".cfs"));
 }
Пример #10
0
 internal static bool HasDeletions(SegmentInfo si)
 {
     return(si.dir.FileExists(si.name + ".del"));
 }
Пример #11
0
 public /*internal*/ SegmentReader(SegmentInfo si) : base(si.dir)
 {
     Initialize(si);
 }