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

Conditionally use sequential stored field reader in LuceneSyntheticSourceChangesSnapshot #121636

Prev Previous commit
Next Next commit
iter
  • Loading branch information
martijnvg committed Feb 6, 2025
commit c6cc1e79ccba7e587a2efb6873a38cdd110f4690
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,18 @@ private Translog.Operation[] loadDocuments(List<SearchRecord> documentRecords) t
maxDoc = leafReaderContext.reader().maxDoc();
} while (docRecord.docID() >= docBase + maxDoc);

// TODO: instead of building an array, let's just check whether doc ids are (semi) dense
IntArrayList nextDocIds = new IntArrayList();
for (int j = i; j < documentRecords.size(); j++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand we're not increasing the complexity of the method by iterating on documentRecords again here (as we already iterates on documentRecords in the outer loop), because we only compute nextDocIds for 1 leaf reader. Can you confirm?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we only compute the docids for the current lead reader. If docid is higher then or equal to docbase + maxDoc then it means current document record belongs to the next leaf reader.

int docID = documentRecords.get(j).docID();
if (docBase + maxDoc >= docID) {
break;
var record = documentRecords.get(j);
if (record.isTombstone()) {
continue;
}
int docID = record.docID();
if (docID >= docBase && docID < docBase + maxDoc) {
int segmentDocID = docID - docBase;
nextDocIds.add(segmentDocID);
}
int segmentDocID = docID - docBase;
nextDocIds.add(segmentDocID);
}

int[] nextDocIdArray = nextDocIds.toArray();
Expand Down