Skip to content

Commit c064318

Browse files
authored
Merge branch 'main' into fork
2 parents f444947 + 8cfc622 commit c064318

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

muted-tests.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,15 @@ tests:
407407
- class: org.elasticsearch.search.SearchCancellationIT
408408
method: testCancelFailedSearchWhenPartialResultDisallowed
409409
issue: https://github.com/elastic/elasticsearch/issues/121719
410+
- class: org.elasticsearch.xpack.esql.analysis.VerifierTests
411+
method: testChangePoint
412+
issue: https://github.com/elastic/elasticsearch/issues/122179
413+
- class: org.elasticsearch.xpack.esql.analysis.VerifierTests
414+
method: testChangePoint_keySortable
415+
issue: https://github.com/elastic/elasticsearch/issues/122180
416+
- class: org.elasticsearch.xpack.esql.analysis.VerifierTests
417+
method: testChangePoint_valueNumeric
418+
issue: https://github.com/elastic/elasticsearch/issues/122181
410419

411420
# Examples:
412421
#

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package org.elasticsearch.index.engine;
1111

12+
import com.carrotsearch.hppc.IntArrayList;
13+
1214
import org.apache.lucene.index.LeafReaderContext;
1315
import org.apache.lucene.search.FieldDoc;
1416
import org.apache.lucene.search.ScoreDoc;
@@ -191,8 +193,28 @@ private Translog.Operation[] loadDocuments(List<SearchRecord> documentRecords) t
191193
maxDoc = leafReaderContext.reader().maxDoc();
192194
} while (docRecord.docID() >= docBase + maxDoc);
193195

194-
leafFieldLoader = storedFieldLoader.getLoader(leafReaderContext, null);
195-
leafSourceLoader = sourceLoader.leaf(leafReaderContext.reader(), null);
196+
// TODO: instead of building an array, consider just checking whether doc ids are dense.
197+
// Note, field loaders then would lose the ability to optionally eagerly loading values.
198+
IntArrayList nextDocIds = new IntArrayList();
199+
for (int j = i; j < documentRecords.size(); j++) {
200+
var record = documentRecords.get(j);
201+
if (record.isTombstone()) {
202+
continue;
203+
}
204+
int docID = record.docID();
205+
if (docID >= docBase + maxDoc) {
206+
break;
207+
}
208+
int segmentDocID = docID - docBase;
209+
nextDocIds.add(segmentDocID);
210+
}
211+
212+
// This computed doc ids arrays us used by stored field loader as a heuristic to determine whether to use a sequential
213+
// stored field reader (which bulk loads stored fields and avoids decompressing the same blocks multiple times). For
214+
// source loader, it is also used as a heuristic for bulk reading doc values (E.g. SingletonDocValuesLoader).
215+
int[] nextDocIdArray = nextDocIds.toArray();
216+
leafFieldLoader = storedFieldLoader.getLoader(leafReaderContext, nextDocIdArray);
217+
leafSourceLoader = sourceLoader.leaf(leafReaderContext.reader(), nextDocIdArray);
196218
setNextSourceMetadataReader(leafReaderContext);
197219
}
198220
int segmentDocID = docRecord.docID() - docBase;

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,7 @@ public void testCategorizeWithFilteredAggregations() {
20182018
}
20192019

20202020
public void testChangePoint() {
2021+
assumeTrue("change_point must be enabled", EsqlCapabilities.Cap.CHANGE_POINT.isEnabled());
20212022
var airports = AnalyzerTestUtils.analyzer(loadMapping("mapping-airports.json", "airports"));
20222023
assertEquals("1:30: Unknown column [blahblah]", error("FROM airports | CHANGE_POINT blahblah ON scalerank", airports));
20232024
assertEquals("1:43: Unknown column [blahblah]", error("FROM airports | CHANGE_POINT scalerank ON blahblah", airports));
@@ -2026,6 +2027,7 @@ public void testChangePoint() {
20262027
}
20272028

20282029
public void testChangePoint_keySortable() {
2030+
assumeTrue("change_point must be enabled", EsqlCapabilities.Cap.CHANGE_POINT.isEnabled());
20292031
List<DataType> sortableTypes = List.of(BOOLEAN, DOUBLE, DATE_NANOS, DATETIME, INTEGER, IP, KEYWORD, LONG, UNSIGNED_LONG, VERSION);
20302032
List<DataType> unsortableTypes = List.of(CARTESIAN_POINT, CARTESIAN_SHAPE, GEO_POINT, GEO_SHAPE);
20312033
for (DataType type : sortableTypes) {
@@ -2040,6 +2042,7 @@ public void testChangePoint_keySortable() {
20402042
}
20412043

20422044
public void testChangePoint_valueNumeric() {
2045+
assumeTrue("change_point must be enabled", EsqlCapabilities.Cap.CHANGE_POINT.isEnabled());
20432046
List<DataType> numericTypes = List.of(DOUBLE, INTEGER, LONG, UNSIGNED_LONG);
20442047
List<DataType> nonNumericTypes = List.of(
20452048
BOOLEAN,

0 commit comments

Comments
 (0)