You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2025/05/11 21:23:48 UTC
(lucene) branch main updated: Use the preload hint on completion fields and memory terms dictionaries. (#14634)
This is an automated email from the ASF dual-hosted git repository.
jpountz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new 9c6c1cb3ce1 Use the preload hint on completion fields and memory terms dictionaries. (#14634)
9c6c1cb3ce1 is described below
commit 9c6c1cb3ce1ef24d71df23e19eb82201a165b71e
Author: Adrien Grand <jp...@gmail.com>
AuthorDate: Sun May 11 23:23:43 2025 +0200
Use the preload hint on completion fields and memory terms dictionaries. (#14634)
This enables the `PreloadHint` introduced in #14604 on completion fields and
memory terms dictionaries, which are both expected to fit in the page cache in
practice.
I don't have specific interest in these two file formats, I was more interested
in having more than one file format that uses `PreloadHint` to make sure it's
generally useful and not only to KNN vectors.
---
.../src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java | 4 +++-
.../lucene/search/suggest/document/CompletionFieldsProducer.java | 6 +++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java
index c56abb16862..e33e15f628b 100644
--- a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java
+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsReader.java
@@ -41,6 +41,7 @@ import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.store.ByteArrayDataInput;
import org.apache.lucene.store.FileTypeHint;
import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.store.PreloadHint;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
@@ -75,7 +76,8 @@ public class FSTTermsReader extends FieldsProducer {
this.postingsReader = postingsReader;
this.fstTermsInput =
- state.directory.openInput(termsFileName, state.context.withHints(FileTypeHint.INDEX));
+ state.directory.openInput(
+ termsFileName, state.context.withHints(FileTypeHint.DATA, PreloadHint.INSTANCE));
IndexInput in = this.fstTermsInput;
diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionFieldsProducer.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionFieldsProducer.java
index 13f3df5c19e..310c896fa83 100644
--- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionFieldsProducer.java
+++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionFieldsProducer.java
@@ -36,7 +36,9 @@ import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.SegmentReadState;
import org.apache.lucene.index.Terms;
import org.apache.lucene.store.ChecksumIndexInput;
+import org.apache.lucene.store.FileTypeHint;
import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.store.PreloadHint;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.Accountables;
import org.apache.lucene.util.CollectionUtil;
@@ -77,7 +79,9 @@ final class CompletionFieldsProducer extends FieldsProducer implements Accountab
String dictFile =
IndexFileNames.segmentFileName(
state.segmentInfo.name, state.segmentSuffix, DICT_EXTENSION);
- dictIn = state.directory.openInput(dictFile, state.context);
+ dictIn =
+ state.directory.openInput(
+ dictFile, state.context.withHints(FileTypeHint.DATA, PreloadHint.INSTANCE));
CodecUtil.checkIndexHeader(
dictIn,
codecName,