Skip to content

Commit f1d6280

Browse files
committed
Add comment
1 parent 57ab327 commit f1d6280

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/lucene/TimeSeriesSortedSourceOperatorFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,16 @@ public Page getOutput() {
187187

188188
private DocVector buildDocVector(IntVector shards, IntVector segments, IntVector docs, int[] docPerSegments) {
189189
if (segments.isConstant()) {
190+
// DocIds are sorted in each segment. Hence, if docIds come from a single segment, we can mark this DocVector
191+
// as singleSegmentNonDecreasing to enable optimizations in the ValuesSourceReaderOperator.
190192
return new DocVector(shards, segments, docs, true);
191193
}
192194
boolean success = false;
193195
int positionCount = shards.getPositionCount();
194196
long estimatedSize = DocVector.sizeOfSegmentDocMap(positionCount);
195197
blockFactory.adjustBreaker(estimatedSize);
198+
// Use docPerSegments to build a forward/backward docMap in O(N)
199+
// instead of O(N*log(N)) in DocVector#buildShardSegmentDocMapIfMissing.
196200
try {
197201
final int[] forwards = new int[positionCount];
198202
final int[] starts = new int[docPerSegments.length];

0 commit comments

Comments
 (0)