Skip to content

Conditionally force sequential reading in LuceneSyntheticSourceChangesSnapshot #128473

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

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
5 changes: 5 additions & 0 deletions docs/changelog/128473.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 128473
summary: Conditionally force sequential reading in `LuceneSyntheticSourceChangesSnapshot`
area: Logs
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.apache.lucene.util.ArrayUtil;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.codec.CodecService;
import org.elasticsearch.index.fieldvisitor.LeafStoredFieldLoader;
import org.elasticsearch.index.fieldvisitor.StoredFieldLoader;
import org.elasticsearch.index.mapper.MapperService;
Expand Down Expand Up @@ -85,7 +86,10 @@ public LuceneSyntheticSourceChangesSnapshot(
this.maxMemorySizeInBytes = maxMemorySizeInBytes > 0 ? maxMemorySizeInBytes : 1;
this.sourceLoader = mapperService.mappingLookup().newSourceLoader(null, SourceFieldMetrics.NOOP);
Set<String> storedFields = sourceLoader.requiredStoredFields();
this.storedFieldLoader = StoredFieldLoader.create(false, storedFields);
String defaultCodec = EngineConfig.INDEX_CODEC_SETTING.get(mapperService.getIndexSettings().getSettings());
// zstd best compression stores upto 2048 docs in a block, so it is likely that in this case docs are co-located in same block:
boolean forceSequentialReader = CodecService.BEST_COMPRESSION_CODEC.equals(defaultCodec);
this.storedFieldLoader = StoredFieldLoader.create(false, storedFields, forceSequentialReader);
this.lastSeenSeqNo = fromSeqNo - 1;
}

Expand Down
Loading