jpountz commented on a change in pull request #1394: LUCENE-9300: Fix field 
infos update on doc values update
URL: https://github.com/apache/lucene-solr/pull/1394#discussion_r402234114
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/index/ReadersAndUpdates.java
 ##########
 @@ -543,27 +543,39 @@ public synchronized boolean writeFieldUpdates(Directory 
dir, FieldInfos.FieldNum
       
       try {
         // clone FieldInfos so that we can update their dvGen separately from
-        // the reader's infos and write them to a new fieldInfos_gen file
-        FieldInfos.Builder builder = new FieldInfos.Builder(fieldNumbers);
-        // cannot use builder.add(reader.getFieldInfos()) because it does not
-        // clone FI.attributes as well FI.dvGen
+        // the reader's infos and write them to a new fieldInfos_gen file.
+        int maxFieldNumber = -1;
+        Map<String, FieldInfo> newFields = new HashMap<>();
         for (FieldInfo fi : reader.getFieldInfos()) {
-          FieldInfo clone = builder.add(fi);
-          // copy the stuff FieldInfos.Builder doesn't copy
-          for (Entry<String,String> e : fi.attributes().entrySet()) {
-            clone.putAttribute(e.getKey(), e.getValue());
-          }
-          clone.setDocValuesGen(fi.getDocValuesGen());
+          // cannot use builder.add(fi) because it does not preserve
+          // the local field number. Field numbers can be different from the 
global ones
+          // if the segment was created externally (with 
IndexWriter#addIndexes(Directory)).
 
 Review comment:
   ```suggestion
             // if the segment was created externally (and added to this index 
with IndexWriter#addIndexes(Directory)).
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to