Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ReadAdvice#NORMAL on files that have a forward-only access pattern. #13450

Merged
merged 5 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.apache.lucene.store.DataInput;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.RandomAccessInput;
import org.apache.lucene.store.ReadAdvice;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LongValues;
Expand Down Expand Up @@ -106,7 +107,10 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {

String dataName =
IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, dataExtension);
this.data = state.directory.openInput(dataName, state.context);
// Doc-values have a forward-only access pattern, so pass ReadAdvice.NORMAL to perform
// readahead.
this.data =
state.directory.openInput(dataName, state.context.withReadAdvice(ReadAdvice.NORMAL));
boolean success = false;
try {
final int version2 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.lucene.store.ChecksumIndexInput;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.RandomAccessInput;
import org.apache.lucene.store.ReadAdvice;
import org.apache.lucene.util.IOUtils;

/** Reader for {@link Lucene90NormsFormat} */
Expand Down Expand Up @@ -80,7 +81,8 @@ final class Lucene90NormsProducer extends NormsProducer implements Cloneable {

String dataName =
IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, dataExtension);
data = state.directory.openInput(dataName, state.context);
// Norms have a forward-only access pattern, so pass ReadAdvice.NORMAL to perform readahead.
data = state.directory.openInput(dataName, state.context.withReadAdvice(ReadAdvice.NORMAL));
boolean success = false;
try {
final int version2 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public Lucene90PointsReader(SegmentReadState readState) throws IOException {
readState.segmentSuffix);
CodecUtil.retrieveChecksum(indexIn);

dataIn = readState.directory.openInput(dataFileName, readState.context);
// Points read whole ranges of bytes at once, so pass ReadAdvice.NORMAL to perform readahead.
dataIn =
readState.directory.openInput(
dataFileName, readState.context.withReadAdvice(ReadAdvice.NORMAL));
CodecUtil.checkIndexHeader(
dataIn,
Lucene90PointsFormat.DATA_CODEC_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.lucene.index.SlowImpactsEnum;
import org.apache.lucene.store.DataInput;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.ReadAdvice;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.BitUtil;
import org.apache.lucene.util.BytesRef;
Expand Down Expand Up @@ -78,7 +79,9 @@ public Lucene99PostingsReader(SegmentReadState state) throws IOException {
IndexFileNames.segmentFileName(
state.segmentInfo.name, state.segmentSuffix, Lucene99PostingsFormat.DOC_EXTENSION);
try {
docIn = state.directory.openInput(docName, state.context);
// Postings have a forward-only access pattern, so pass ReadAdvice.NORMAL to perform
// readahead.
docIn = state.directory.openInput(docName, state.context.withReadAdvice(ReadAdvice.NORMAL));
version =
CodecUtil.checkIndexHeader(
docIn,
Expand Down