Skip to content

Optimize ParallelLeafReader to improve term vector fetching efficienc #14373

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
merged 3 commits into from
Mar 24, 2025
Merged
Changes from 1 commit
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 @@ -348,15 +348,24 @@ public void prefetch(int docID) throws IOException {
@Override
public Fields get(int docID) throws IOException {
ParallelFields fields = null;
for (Map.Entry<String, LeafReader> ent : tvFieldToReader.entrySet()) {
String fieldName = ent.getKey();
TermVectors termVectors = readerToTermVectors.get(ent.getValue());
Terms vector = termVectors.get(docID, fieldName);
if (vector != null) {
if (fields == null) {
fields = new ParallelFields();
}
fields.addField(fieldName, vector);

// Step 2: Fetch all term vectors once per reader
for (Map.Entry<LeafReader, TermVectors> entry : readerToTermVectors.entrySet()) {
TermVectors termVectors = entry.getValue();
Fields docFields = termVectors.get(docID); // Fetch all fields at once

if (docFields != null) {
if (fields == null) {
fields = new ParallelFields();
}

// Step 3: Aggregate only required fields
for (String fieldName : docFields) {
Terms vector = docFields.terms(fieldName);
if (vector != null) {
fields.addField(fieldName, vector);
}
}
}
}

Expand Down
Loading