public override TermsConsumer AddField(FieldInfo field) { PostingsFormat format = outerInstance.GetPostingsFormatForField(field.Name); if (format == null) { throw new InvalidOperationException("invalid null PostingsFormat for field=\"" + field.Name + "\""); } string formatName = format.Name; string previousValue = field.PutAttribute(PER_FIELD_FORMAT_KEY, formatName); Debug.Assert(previousValue == null); int?suffix; FieldsConsumerAndSuffix consumer; if (!formats.TryGetValue(format, out consumer) || consumer == null) { // First time we are seeing this format; create a new instance // bump the suffix if (!suffixes.TryGetValue(formatName, out suffix) || suffix == null) { suffix = 0; } else { suffix = suffix + 1; } suffixes[formatName] = suffix; string segmentSuffix = GetFullSegmentSuffix(field.Name, segmentWriteState.SegmentSuffix, GetSuffix(formatName, Convert.ToString(suffix, CultureInfo.InvariantCulture))); consumer = new FieldsConsumerAndSuffix(); consumer.Consumer = format.FieldsConsumer(new SegmentWriteState(segmentWriteState, segmentSuffix)); consumer.Suffix = suffix.Value; // LUCENENET NOTE: At this point suffix cannot be null formats[format] = consumer; } else { // we've already seen this format, so just grab its suffix Debug.Assert(suffixes.ContainsKey(formatName)); suffix = consumer.Suffix; } previousValue = field.PutAttribute(PER_FIELD_SUFFIX_KEY, Convert.ToString(suffix, CultureInfo.InvariantCulture)); Debug.Assert(previousValue == null); // TODO: we should only provide the "slice" of FIS // that this PF actually sees ... then stuff like // .hasProx could work correctly? // NOTE: .hasProx is already broken in the same way for the non-perfield case, // if there is a fieldinfo with prox that has no postings, you get a 0 byte file. return(consumer.Consumer.AddField(field)); }
public override TermsConsumer AddField(FieldInfo field) { PostingsFormat format = OuterInstance.GetPostingsFormatForField(field.Name); if (format == null) { throw new InvalidOperationException("invalid null PostingsFormat for field=\"" + field.Name + "\""); } string formatName = format.Name; string previousValue = field.PutAttribute(PER_FIELD_FORMAT_KEY, formatName); //Debug.Assert(previousValue == null); int suffix; FieldsConsumerAndSuffix consumer; Formats.TryGetValue(format, out consumer); if (consumer == null) { // First time we are seeing this format; create a new instance // bump the suffix if (!Suffixes.TryGetValue(formatName, out suffix)) { suffix = 0; } else { suffix = suffix + 1; } Suffixes[formatName] = suffix; string segmentSuffix = GetFullSegmentSuffix(field.Name, SegmentWriteState.SegmentSuffix, GetSuffix(formatName, Convert.ToString(suffix))); consumer = new FieldsConsumerAndSuffix(); consumer.Consumer = format.FieldsConsumer(new SegmentWriteState(SegmentWriteState, segmentSuffix)); consumer.Suffix = suffix; Formats[format] = consumer; } else { // we've already seen this format, so just grab its suffix Debug.Assert(Suffixes.ContainsKey(formatName)); suffix = consumer.Suffix; } previousValue = field.PutAttribute(PER_FIELD_SUFFIX_KEY, Convert.ToString(suffix)); //Debug.Assert(previousValue == null); // TODO: we should only provide the "slice" of FIS // that this PF actually sees ... then stuff like // .hasProx could work correctly? // NOTE: .hasProx is already broken in the same way for the non-perfield case, // if there is a fieldinfo with prox that has no postings, you get a 0 byte file. return consumer.Consumer.AddField(field); }