public void Read(IndexInput input, FieldInfos fieldInfos) { this.term = null; // invalidate cache newSuffixStart = input.ReadVInt32(); int length = input.ReadVInt32(); int totalLength = newSuffixStart + length; if (Debugging.AssertsEnabled) { Debugging.Assert(totalLength <= ByteBlockPool.BYTE_BLOCK_SIZE - 2, () => "termLength=" + totalLength + ",resource=" + input); } if (bytes.Bytes.Length < totalLength) { bytes.Grow(totalLength); } bytes.Length = totalLength; input.ReadBytes(bytes.Bytes, newSuffixStart, length); int fieldNumber = input.ReadVInt32(); if (fieldNumber != currentFieldNumber) { currentFieldNumber = fieldNumber; // NOTE: too much sneakiness here, seriously this is a negative vint?! if (currentFieldNumber == -1) { field = ""; } else { if (Debugging.AssertsEnabled) { Debugging.Assert(fieldInfos.FieldInfo(currentFieldNumber) != null, currentFieldNumber.ToString); } field = fieldInfos.FieldInfo(currentFieldNumber).Name.Intern(); } } else { if (Debugging.AssertsEnabled) { Debugging.Assert(field.Equals(fieldInfos.FieldInfo(fieldNumber).Name, StringComparison.Ordinal), () => "currentFieldNumber=" + currentFieldNumber + " field=" + field + " vs " + fieldInfos.FieldInfo(fieldNumber) == null ? "null" : fieldInfos.FieldInfo(fieldNumber).Name); } } }
public SegmentTermEnum(IndexInput i, FieldInfos fis, bool isi) { input = i; fieldInfos = fis; isIndex = isi; maxSkipLevels = 1; // use single-level skip lists for formats > -3 int firstInt = input.ReadInt32(); if (firstInt >= 0) { // original-format file, without explicit format version number format = 0; size = firstInt; // back-compatible settings indexInterval = 128; skipInterval = int.MaxValue; // switch off skipTo optimization } else { // we have a format version number format = firstInt; // check that it is a format we can understand if (format > FORMAT_MINIMUM) { throw new IndexFormatTooOldException(input, format, FORMAT_MINIMUM, FORMAT_CURRENT); } if (format < FORMAT_CURRENT) { throw new IndexFormatTooNewException(input, format, FORMAT_MINIMUM, FORMAT_CURRENT); } size = input.ReadInt64(); // read the size indexInterval = input.ReadInt32(); skipInterval = input.ReadInt32(); maxSkipLevels = input.ReadInt32(); if (Debugging.AssertsEnabled) { Debugging.Assert(indexInterval > 0, "indexInterval={0} is negative; must be > 0", indexInterval); Debugging.Assert(skipInterval > 0, "skipInterval={0} is negative; must be > 0", skipInterval); } } }
/// <summary> /// Save a single segment's info. </summary> public override void Write(Directory dir, SegmentInfo si, FieldInfos fis, IOContext ioContext) { string fileName = IndexFileNames.SegmentFileName(si.Name, "", Lucene46SegmentInfoFormat.SI_EXTENSION); si.AddFile(fileName); IndexOutput output = dir.CreateOutput(fileName, ioContext); bool success = false; try { CodecUtil.WriteHeader(output, Lucene46SegmentInfoFormat.CODEC_NAME, Lucene46SegmentInfoFormat.VERSION_CURRENT); // Write the Lucene version that created this segment, since 3.1 output.WriteString(si.Version); output.WriteInt32(si.DocCount); output.WriteByte((byte)(sbyte)(si.UseCompoundFile ? SegmentInfo.YES : SegmentInfo.NO)); output.WriteStringStringMap(si.Diagnostics); output.WriteStringSet(si.GetFiles()); CodecUtil.WriteFooter(output); success = true; } finally { if (!success) { IOUtils.DisposeWhileHandlingException(output); si.Dir.DeleteFile(fileName); } else { output.Dispose(); } } }
public override StoredFieldsReader FieldsReader(Directory directory, SegmentInfo si, FieldInfos fn, IOContext context) { return(new Lucene40StoredFieldsReader(directory, si, fn, context)); }
/// <summary> /// Returns a <see cref="StoredFieldsReader"/> to load stored /// fields. /// </summary> public abstract StoredFieldsReader FieldsReader(Directory directory, SegmentInfo si, FieldInfos fn, IOContext context);
/// <summary> /// Writes the provided <see cref="FieldInfos"/> to the /// directory. /// </summary> public abstract void Write(Directory directory, string segmentName, string segmentSuffix, FieldInfos infos, IOContext context);
public override StoredFieldsReader FieldsReader(Directory directory, SegmentInfo si, FieldInfos fn, IOContext context) { return(new CompressingStoredFieldsReader(directory, si, segmentSuffix, fn, context, formatName, compressionMode)); }
/// <summary> /// Returns a <see cref="TermVectorsReader"/> to read term /// vectors. /// </summary> public abstract TermVectorsReader VectorsReader(Directory directory, SegmentInfo segmentInfo, FieldInfos fieldInfos, IOContext context);
/// <summary> /// Write <see cref="SegmentInfo"/> data. </summary> /// <exception cref="System.IO.IOException"> If an I/O error occurs. </exception> public abstract void Write(Directory dir, SegmentInfo info, FieldInfos fis, IOContext ioContext);
public override TermVectorsReader VectorsReader(Directory directory, SegmentInfo segmentInfo, FieldInfos fieldInfos, IOContext context) { return(new Lucene40TermVectorsReader(directory, segmentInfo, fieldInfos, context)); }