public FieldsReader(PerFieldPostingsFormat outerInstance, SegmentReadState readState) { this.outerInstance = outerInstance; // Read _X.per and init each format: bool success = false; try { // Read field name -> format name foreach (FieldInfo fi in readState.FieldInfos) { if (fi.IsIndexed) { string fieldName = fi.Name; string formatName = fi.GetAttribute(PER_FIELD_FORMAT_KEY); if (formatName != null) { // null formatName means the field is in fieldInfos, but has no postings! string suffix = fi.GetAttribute(PER_FIELD_SUFFIX_KEY); if (Debugging.AssertsEnabled) { Debugging.Assert(suffix != null); } PostingsFormat format = PostingsFormat.ForName(formatName); string segmentSuffix = GetSuffix(formatName, suffix); // LUCENENET: Eliminated extra lookup by using TryGetValue instead of ContainsKey if (!formats.TryGetValue(segmentSuffix, out Codecs.FieldsProducer field)) { formats[segmentSuffix] = field = format.FieldsProducer(new SegmentReadState(readState, segmentSuffix)); } fields[fieldName] = field; } } } success = true; } finally { if (!success) { IOUtils.DisposeWhileHandlingException(formats.Values); } } }
public FieldsWriter(PerFieldPostingsFormat outerInstance, SegmentWriteState state) { this.outerInstance = outerInstance; segmentWriteState = state; }