Skip to content

Commit c6cc1e7

Browse files
committed
iter
1 parent 1d0a210 commit c6cc1e7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

server/src/main/java/org/elasticsearch/index/engine/LuceneSyntheticSourceChangesSnapshot.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,18 @@ private Translog.Operation[] loadDocuments(List<SearchRecord> documentRecords) t
194194
maxDoc = leafReaderContext.reader().maxDoc();
195195
} while (docRecord.docID() >= docBase + maxDoc);
196196

197+
// TODO: instead of building an array, let's just check whether doc ids are (semi) dense
197198
IntArrayList nextDocIds = new IntArrayList();
198199
for (int j = i; j < documentRecords.size(); j++) {
199-
int docID = documentRecords.get(j).docID();
200-
if (docBase + maxDoc >= docID) {
201-
break;
200+
var record = documentRecords.get(j);
201+
if (record.isTombstone()) {
202+
continue;
203+
}
204+
int docID = record.docID();
205+
if (docID >= docBase && docID < docBase + maxDoc) {
206+
int segmentDocID = docID - docBase;
207+
nextDocIds.add(segmentDocID);
202208
}
203-
int segmentDocID = docID - docBase;
204-
nextDocIds.add(segmentDocID);
205209
}
206210

207211
int[] nextDocIdArray = nextDocIds.toArray();

0 commit comments

Comments
 (0)