You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "tflobbe (via GitHub)" <gi...@apache.org> on 2023/05/25 22:26:06 UTC

[GitHub] [lucene] tflobbe commented on a diff in pull request #12326: Lucene 9.x fails to merge 8.x segments with a field that changed IndexOptions NONE -> DOCS

tflobbe commented on code in PR #12326:
URL: https://github.com/apache/lucene/pull/12326#discussion_r1206055144


##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -628,6 +628,48 @@ FieldInfo constructFieldInfo(String fieldName, DocValuesType dvType, int newFiel
           isSoftDeletesField);
     }
 
+    synchronized void setDocValuesType(int number, String name, DocValuesType dvType) {
+      verifyConsistent(number, name, dvType);
+      docValuesType.put(name, dvType);
+    }
+
+    synchronized void verifyConsistent(Integer number, String name, DocValuesType dvType) {
+      if (name.equals(numberToName.get(number)) == false) {
+        throw new IllegalArgumentException(
+            "field number "
+                + number
+                + " is already mapped to field name \""
+                + numberToName.get(number)
+                + "\", not \""
+                + name
+                + "\"");
+      }
+      if (number.equals(nameToNumber.get(name)) == false) {
+        throw new IllegalArgumentException(
+            "field name \""
+                + name
+                + "\" is already mapped to field number \""
+                + nameToNumber.get(name)
+                + "\", not \""
+                + number
+                + "\"");
+      }
+      DocValuesType currentDVType = docValuesType.get(name);
+      if (dvType != DocValuesType.NONE
+          && currentDVType != null
+          && currentDVType != DocValuesType.NONE
+          && dvType != currentDVType) {
+        throw new IllegalArgumentException(
+            "cannot change DocValues type from "
+                + currentDVType
+                + " to "
+                + dvType
+                + " for field \""
+                + name
+                + "\"");
+      }
+    }
+

Review Comment:
   These I brought back from the 8.x code



##########
lucene/core/src/java/org/apache/lucene/index/FieldInfo.java:
##########
@@ -400,6 +400,150 @@ static void verifySameVectorOptions(
     }
   }
 
+  /*
+  This method will create a new instance of FieldInfo if any attribute changes (and it changes in a compatible way).
+  It is intended only to be used in indices where schema validation is not strict (legacy indices). It will return null
+  if no changes are done on this FieldInfo
+   */
+  FieldInfo handleLegacySupportedUpdates(FieldInfo otherFi) {

Review Comment:
   The base of this method is coming from 8.x's [FieldInfo#update](https://github.com/apache/lucene-solr/blob/branch_8_11/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java#L144)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org