thecoop commented on code in PR #16883:
URL: https://github.com/apache/lucene/pull/16883#discussion_r4361487693
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90CompoundReader.java:
##########
@@ -176,28 +185,33 @@ 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);
- }
-
- /**
- * A merge reads through a mapping of its own, so the access it advises does
not replace the
- * advice of searches reading the same inner files. Merges of this segment
share it. Like the
- * search mapping, it is opened without advice: each inner file is advised
on its own region.
- */
- private synchronized IndexInput mergeHandle() throws IOException {
- if (closed) {
- throw new AlreadyClosedException("this Directory is closed");
- }
- if (mergeHandle == null) {
- try {
- mergeHandle = directory.openInput(dataFileName, IOContext.DEFAULT);
- } catch (@SuppressWarnings("unused") FileNotFoundException |
NoSuchFileException e) {
- // an open reader outlives its files, so fall back to the mapping it
already holds
- mergeHandle = handle;
+ synchronized (this) {
+ if (closed) {
+ throw new AlreadyClosedException("this Directory is closed");
+ }
+ List<Slice> fileSlices = slices.computeIfAbsent(id, _ -> new
ArrayList<>());
+ int copy = 0;
+ while (copy < fileSlices.size()
+ && fileSlices.get(copy).input().isEfficientFor(context) == false) {
+ copy++;
+ }
+ // each slice of an inner file is on its own copy of the data file, so
it keeps its own advice
+ if (copy == fileSlices.size()) {
+ try {
+ if (copy == data.size()) {
+ // without advice, like handle, so inner files advise their own
pages
+ data.add(directory.openInput(dataFileName, IOContext.DEFAULT));
+ }
+ IndexInput input = data.get(copy).slice(name, entry.offset,
entry.length, context);
Review Comment:
Yes, thats much clearer!
--
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]