Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-9440

FieldInfo#checkConsistency called twice from Lucene50(60)FieldInfosFormat#read

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 9.0
    • 9.0, 8.7
    • core/index
    • None
    • New, Patch Available
    • Yes

    Description

      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

      infos[i] = new FieldInfo(name, fieldNumber, storeTermVector, omitNorms, storePayloads, indexOptions, docValuesType, dvGen, attributes, 0, 0, 0, false); 
      infos[i].checkConsistency();
      

      FileInfo's constructor(notice the last line)

      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();
      }
      

       

      By this patch, I will remove the second call and leave only one in the constructor.

       

      Attachments

        1. LUCENE-9440.patch
          2 kB
          Yauheni Putsykovich
        2. LUCENE-9440.patch
          5 kB
          Yauheni Putsykovich

        Activity

          People

            Unassigned Unassigned
            sleshJdev Yauheni Putsykovich
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: