[
https://issues.apache.org/jira/browse/LUCENE-9440?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17163025#comment-17163025
]
Robert Muir commented on LUCENE-9440:
-------------------------------------
I don't think its a simple case of duplicate call.
The one in the constructor is only called with "assert", so only when
assertions are enabled. It happens for any fieldinfo creation. I don't remember
the reason why its only called under assert, presumably to avoid some
performance hit when fieldinfos are created by indexwriter.
On the other hand the second call (after deserializing bytes from the index) is
called even in "production". So if we remove it, we remove the sanity checks
alltogether for production code.
> FieldInfo#checkConsistency called twice from Lucene50FieldInfosFormat#read
> --------------------------------------------------------------------------
>
> Key: LUCENE-9440
> URL: https://issues.apache.org/jira/browse/LUCENE-9440
> Project: Lucene - Core
> Issue Type: Improvement
> Components: core/index
> Affects Versions: master (9.0)
> Reporter: Yauheni Putsykovich
> Priority: Trivial
> Attachments: LUCENE-9440
>
>
> Reviewing code I noticed that we do call _infos[i].checkConsistency();_
> method twice: first time inside the _FiledInfo_'s constructor and a second
> one just after we've created an object.
> org/apache/lucene/codecs/lucene50/Lucene50FieldInfosFormat.java:150
> {code:java}
> infos[i] = new FieldInfo(name, fieldNumber, storeTermVector, omitNorms,
> storePayloads, indexOptions, docValuesType, dvGen, attributes, 0, 0, 0,
> false);
> infos[i].checkConsistency();
> {code}
> _FileInfo_'s constructor(notice the last line)
> {code:java}
> public FieldInfo(String name, int number, boolean storeTermVector, boolean
> omitNorms, boolean storePayloads,
> IndexOptions indexOptions, DocValuesType docValues, long
> dvGen, Map<String,String> attributes,
> int pointDimensionCount, int pointIndexDimensionCount, int
> pointNumBytes, boolean softDeletesField) {
> this.name = Objects.requireNonNull(name);
> this.number = number;
> this.docValuesType = Objects.requireNonNull(docValues, "DocValuesType must
> not be null (field: \"" + name + "\")");
> this.indexOptions = Objects.requireNonNull(indexOptions, "IndexOptions must
> not be null (field: \"" + name + "\")");
> if (indexOptions != IndexOptions.NONE) {
> this.storeTermVector = storeTermVector;
> this.storePayloads = storePayloads;
> this.omitNorms = omitNorms;
> } else { // for non-indexed fields, leave defaults
> this.storeTermVector = false;
> this.storePayloads = false;
> this.omitNorms = false;
> }
> this.dvGen = dvGen;
> this.attributes = Objects.requireNonNull(attributes);
> this.pointDimensionCount = pointDimensionCount;
> this.pointIndexDimensionCount = pointIndexDimensionCount;
> this.pointNumBytes = pointNumBytes;
> this.softDeletesField = softDeletesField;
> assert checkConsistency();
> }
> {code}
>
> By this patch, I will remove the second call and leave only one in the
> constructor.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]