thecoop commented on code in PR #16905:
URL: https://github.com/apache/lucene/pull/16905#discussion_r4376494260
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99FlatVectorsReader.java:
##########
@@ -212,40 +215,44 @@ public void checkIntegrity(MergePolicy.OneMerge merge)
throws IOException {
@Override
public FlatVectorsReader getMergeInstance() throws IOException {
- IndexInput data = original.sequentialVectorData();
+ IndexInput data =
original.vectorDataFor(IOContext.merge().withHints(sequentialHints()));
return data == vectorData ? this : new Lucene99FlatVectorsReader(this,
data.clone());
}
- /** Returns the input for sequential reads, opening the data file again if
needed. */
- private synchronized IndexInput sequentialVectorData() throws IOException {
+ /** Returns an input efficient for {@code context}, opening the data file
again if none is. */
+ private synchronized IndexInput vectorDataFor(IOContext context) throws
IOException {
assert original == this;
if (closed) {
throw new AlreadyClosedException("this reader is closed");
}
- if (sequentialVectorData == null) {
- IOContext sequential = sequentialContext();
- if (vectorData.isEfficientFor(sequential)) {
- sequentialVectorData = vectorData;
- } else {
- try {
- sequentialVectorData = directory.openInput(vectorDataFN, sequential);
- } catch (FileNotFoundException | NoSuchFileException _) {
- // an open reader outlives its files, so read through the input it
already holds
- sequentialVectorData = vectorData;
- }
+ if (vectorData.isEfficientFor(context)) {
+ return vectorData;
+ }
+ IndexInput data = otherVectorData.get(context);
+ if (data != null) {
+ return data;
+ }
+ for (IndexInput other : otherVectorData.values()) {
+ if (other.isEfficientFor(context)) {
+ return other;
Review Comment:
Should `other` be added back to the map with `context` as another key?
--
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]