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


##########
lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90CompoundReader.java:
##########
@@ -176,28 +182,50 @@ public IndexInput openInput(String name, IOContext 
context) throws IOException {
               + entries.keySet()
               + ")");
     }
-    IndexInput data = context.context() == IOContext.Context.MERGE ? 
mergeHandle() : handle;
-    return data.slice(name, entry.offset, entry.length, context);
+    synchronized (this) {
+      Mapping mapping = mappingFor(id, context);
+      IndexInput slice = mapping.data.slice(name, entry.offset, entry.length, 
context);
+      mapping.firstOpens.putIfAbsent(id, slice);

Review Comment:
   A mapping serves every inner file opened on it, so it can't be keyed by 
file. I inlined mappingFor into one loop in openInput: reuse the first mapping 
where the file is not open yet or its slice serves the context, otherwise map 
the data file again.



-- 
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