jpountz commented on code in PR #13208:
URL: https://github.com/apache/lucene/pull/13208#discussion_r1537183041


##########
lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldMergeState.java:
##########
@@ -31,40 +31,18 @@
 import org.apache.lucene.index.MergeState;
 import org.apache.lucene.index.Terms;
 
-/**
- * Utility class to update the {@link MergeState} instance to be restricted to 
a set of fields.
- *
- * <p>Warning: the input {@linkplain MergeState} instance will be updated when 
calling {@link
- * #apply(Collection)}.
- *
- * <p>It should be called within a {@code try {...} finally {...}} block to 
make sure that the
- * mergeState instance is restored to its original state:
- *
- * <pre>
- * PerFieldMergeState pfMergeState = new PerFieldMergeState(mergeState);
- * try {
- *   doSomething(pfMergeState.apply(fields));
- *   ...
- * } finally {
- *   pfMergeState.reset();
- * }
- * </pre>
- */
+/** Utility class to update the {@link MergeState} instance to be restricted 
to a set of fields. */
 final class PerFieldMergeState {
   private final MergeState in;
-  private final FieldInfos orgMergeFieldInfos;
-  private final FieldInfos[] orgFieldInfos;
-  private final FieldsProducer[] orgFieldsProducers;
+  private final MergeState copy;

Review Comment:
   Should we dynamically allocate this copy in `apply()` so that each caller 
gets an independent instance, and we're less subject to a similar kind of bug 
in the future due to multiple threads trying to modify this `copy` at the same 
time?



##########
lucene/core/src/java/org/apache/lucene/index/MergeState.java:
##########
@@ -23,13 +23,7 @@
 import java.util.Locale;
 import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
-import org.apache.lucene.codecs.DocValuesProducer;
-import org.apache.lucene.codecs.FieldsProducer;
-import org.apache.lucene.codecs.KnnVectorsReader;
-import org.apache.lucene.codecs.NormsProducer;
-import org.apache.lucene.codecs.PointsReader;
-import org.apache.lucene.codecs.StoredFieldsReader;
-import org.apache.lucene.codecs.TermVectorsReader;
+import org.apache.lucene.codecs.*;

Review Comment:
   We prefer to avoid star imports.



-- 
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-unsubscr...@lucene.apache.org

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


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

Reply via email to