Skip to content

Commit 182e96e

Browse files
Merge branch 'main' into clean-ali-inference-code
2 parents 3b7439b + 53773cb commit 182e96e

File tree

202 files changed

+2701
-1119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+2701
-1119
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/compute/operator/EvalBenchmark.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.elasticsearch.core.TimeValue;
2828
import org.elasticsearch.xpack.esql.core.expression.Expression;
2929
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
30+
import org.elasticsearch.xpack.esql.core.expression.FoldContext;
3031
import org.elasticsearch.xpack.esql.core.expression.Literal;
3132
import org.elasticsearch.xpack.esql.core.expression.predicate.regex.RLikePattern;
3233
import org.elasticsearch.xpack.esql.core.tree.Source;
@@ -71,12 +72,11 @@ public class EvalBenchmark {
7172
BigArrays.NON_RECYCLING_INSTANCE
7273
);
7374

75+
private static final FoldContext FOLD_CONTEXT = FoldContext.small();
76+
7477
private static final int BLOCK_LENGTH = 8 * 1024;
7578

76-
static final DriverContext driverContext = new DriverContext(
77-
BigArrays.NON_RECYCLING_INSTANCE,
78-
BlockFactory.getInstance(new NoopCircuitBreaker("noop"), BigArrays.NON_RECYCLING_INSTANCE)
79-
);
79+
static final DriverContext driverContext = new DriverContext(BigArrays.NON_RECYCLING_INSTANCE, blockFactory);
8080

8181
static {
8282
// Smoke test all the expected values and force loading subclasses more like prod
@@ -114,18 +114,20 @@ private static EvalOperator.ExpressionEvaluator evaluator(String operation) {
114114
return switch (operation) {
115115
case "abs" -> {
116116
FieldAttribute longField = longField();
117-
yield EvalMapper.toEvaluator(new Abs(Source.EMPTY, longField), layout(longField)).get(driverContext);
117+
yield EvalMapper.toEvaluator(FOLD_CONTEXT, new Abs(Source.EMPTY, longField), layout(longField)).get(driverContext);
118118
}
119119
case "add" -> {
120120
FieldAttribute longField = longField();
121121
yield EvalMapper.toEvaluator(
122+
FOLD_CONTEXT,
122123
new Add(Source.EMPTY, longField, new Literal(Source.EMPTY, 1L, DataType.LONG)),
123124
layout(longField)
124125
).get(driverContext);
125126
}
126127
case "add_double" -> {
127128
FieldAttribute doubleField = doubleField();
128129
yield EvalMapper.toEvaluator(
130+
FOLD_CONTEXT,
129131
new Add(Source.EMPTY, doubleField, new Literal(Source.EMPTY, 1D, DataType.DOUBLE)),
130132
layout(doubleField)
131133
).get(driverContext);
@@ -140,7 +142,8 @@ private static EvalOperator.ExpressionEvaluator evaluator(String operation) {
140142
lhs = new Add(Source.EMPTY, lhs, new Literal(Source.EMPTY, 1L, DataType.LONG));
141143
rhs = new Add(Source.EMPTY, rhs, new Literal(Source.EMPTY, 1L, DataType.LONG));
142144
}
143-
yield EvalMapper.toEvaluator(new Case(Source.EMPTY, condition, List.of(lhs, rhs)), layout(f1, f2)).get(driverContext);
145+
yield EvalMapper.toEvaluator(FOLD_CONTEXT, new Case(Source.EMPTY, condition, List.of(lhs, rhs)), layout(f1, f2))
146+
.get(driverContext);
144147
}
145148
case "date_trunc" -> {
146149
FieldAttribute timestamp = new FieldAttribute(
@@ -149,35 +152,37 @@ private static EvalOperator.ExpressionEvaluator evaluator(String operation) {
149152
new EsField("timestamp", DataType.DATETIME, Map.of(), true)
150153
);
151154
yield EvalMapper.toEvaluator(
155+
FOLD_CONTEXT,
152156
new DateTrunc(Source.EMPTY, new Literal(Source.EMPTY, Duration.ofHours(24), DataType.TIME_DURATION), timestamp),
153157
layout(timestamp)
154158
).get(driverContext);
155159
}
156160
case "equal_to_const" -> {
157161
FieldAttribute longField = longField();
158162
yield EvalMapper.toEvaluator(
163+
FOLD_CONTEXT,
159164
new Equals(Source.EMPTY, longField, new Literal(Source.EMPTY, 100_000L, DataType.LONG)),
160165
layout(longField)
161166
).get(driverContext);
162167
}
163168
case "long_equal_to_long" -> {
164169
FieldAttribute lhs = longField();
165170
FieldAttribute rhs = longField();
166-
yield EvalMapper.toEvaluator(new Equals(Source.EMPTY, lhs, rhs), layout(lhs, rhs)).get(driverContext);
171+
yield EvalMapper.toEvaluator(FOLD_CONTEXT, new Equals(Source.EMPTY, lhs, rhs), layout(lhs, rhs)).get(driverContext);
167172
}
168173
case "long_equal_to_int" -> {
169174
FieldAttribute lhs = longField();
170175
FieldAttribute rhs = intField();
171-
yield EvalMapper.toEvaluator(new Equals(Source.EMPTY, lhs, rhs), layout(lhs, rhs)).get(driverContext);
176+
yield EvalMapper.toEvaluator(FOLD_CONTEXT, new Equals(Source.EMPTY, lhs, rhs), layout(lhs, rhs)).get(driverContext);
172177
}
173178
case "mv_min", "mv_min_ascending" -> {
174179
FieldAttribute longField = longField();
175-
yield EvalMapper.toEvaluator(new MvMin(Source.EMPTY, longField), layout(longField)).get(driverContext);
180+
yield EvalMapper.toEvaluator(FOLD_CONTEXT, new MvMin(Source.EMPTY, longField), layout(longField)).get(driverContext);
176181
}
177182
case "rlike" -> {
178183
FieldAttribute keywordField = keywordField();
179184
RLike rlike = new RLike(Source.EMPTY, keywordField, new RLikePattern(".ar"));
180-
yield EvalMapper.toEvaluator(rlike, layout(keywordField)).get(driverContext);
185+
yield EvalMapper.toEvaluator(FOLD_CONTEXT, rlike, layout(keywordField)).get(driverContext);
181186
}
182187
default -> throw new UnsupportedOperationException();
183188
};

docs/changelog/118602.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 118602
2+
summary: Limit memory usage of `fold`
3+
area: ES|QL
4+
type: bug
5+
issues: []

docs/reference/esql/functions/kibana/definition/bucket.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/definition/date_format.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/definition/match_operator.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/docs/match_operator.md

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/types/date_format.asciidoc

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)