jimczi commented on code in PR #16883:
URL: https://github.com/apache/lucene/pull/16883#discussion_r4350723929


##########
lucene/core/src/java/org/apache/lucene/store/IndexInput.java:
##########
@@ -238,6 +238,16 @@ public boolean prefetch(long offset, long length) throws 
IOException {
    */
   public void updateIOContext(IOContext context) throws IOException {}
 
+  /**
+   * Returns true if reading this input is as efficient as reading an input 
opened with the given
+   * {@code IOContext}. If not, callers that read with this context may open 
the file again.
+   *
+   * <p>The default implementation returns {@code true}.
+   */
+  public boolean readsAs(IOContext context) {

Review Comment:
   I reworded it around the decision rather than the claim: false means callers 
should open the file again, and the default true means they never do. An 
Optional would leave every caller to map "unknown" to "don't open again", which 
is what true already says?



##########
lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90CompoundReader.java:
##########
@@ -148,13 +150,17 @@ private Map<String, FileEntry> readMapping(IndexInput 
entriesStream) throws IOEx
 
   @Override
   public void close() throws IOException {
-    IndexInput merge;
+    List<IndexInput> others = new ArrayList<>();
     synchronized (this) {
       closed = true;
-      merge = mergeHandle == handle ? null : mergeHandle;
-      mergeHandle = null;
+      for (Mapping mapping : mappings) {
+        if (mapping.data != handle) {
+          others.add(mapping.data);
+        }
+      }
+      mappings.clear();
     }
-    IOUtils.close(handle, merge);
+    IOUtils.close(handle, () -> IOUtils.close(others));

Review Comment:
   Done. The reader's mapping is in the list from the start and close just 
closes the list.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to