|
28 | 28 | import org.apache.lucene.store.IndexInput; |
29 | 29 | import org.apache.lucene.store.IndexOutput; |
30 | 30 | import org.apache.lucene.store.RandomAccessInput; |
| 31 | +import org.apache.lucene.store.ReadAdvice; |
31 | 32 | import org.apache.lucene.util.LongValues; |
32 | 33 | import org.apache.lucene.util.VectorUtil; |
33 | 34 | import org.elasticsearch.core.IOUtils; |
@@ -295,9 +296,17 @@ private void mergeOneFieldIVF(FieldInfo fieldInfo, MergeState mergeState) throws |
295 | 296 | } |
296 | 297 | } |
297 | 298 | } |
| 299 | + // now open the temp file and build the index structures. It is expected these files to be read in sequential order. |
| 300 | + // Even when the file might be sample, the reads will be always in increase order, therefore we set the ReadAdvice to SEQUENTIAL |
| 301 | + // so the OS can optimize read ahead in low memory situations. |
298 | 302 | try ( |
299 | | - IndexInput vectors = mergeState.segmentInfo.dir.openInput(tempRawVectorsFileName, IOContext.DEFAULT); |
300 | | - IndexInput docs = docsFileName == null ? null : mergeState.segmentInfo.dir.openInput(docsFileName, IOContext.DEFAULT) |
| 303 | + IndexInput vectors = mergeState.segmentInfo.dir.openInput( |
| 304 | + tempRawVectorsFileName, |
| 305 | + IOContext.DEFAULT.withReadAdvice(ReadAdvice.SEQUENTIAL) |
| 306 | + ); |
| 307 | + IndexInput docs = docsFileName == null |
| 308 | + ? null |
| 309 | + : mergeState.segmentInfo.dir.openInput(docsFileName, IOContext.DEFAULT.withReadAdvice(ReadAdvice.SEQUENTIAL)) |
301 | 310 | ) { |
302 | 311 | final FloatVectorValues floatVectorValues = getFloatVectorValues(fieldInfo, docs, vectors, numVectors); |
303 | 312 |
|
|
0 commit comments