Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,11 @@ public Block eval(Page page) {
return mask;
}

@Override
public long baseRamBytesUsed() {
return 0;
}

@Override
public void close() {
mask.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class EvalBenchmark {
public String operation;

private static Operator operator(String operation) {
return new EvalOperator(driverContext.blockFactory(), evaluator(operation));
return new EvalOperator(driverContext, evaluator(operation));
}

private static EvalOperator.ExpressionEvaluator evaluator(String operation) {
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog/133392.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 133392
summary: Track memory in evaluators
area: ES|QL
type: bug
issues: []

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/description/md5.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 27 additions & 3 deletions docs/reference/esql/functions/examples/to_ip.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/reference/esql/functions/kibana/definition/avg.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/kibana/definition/md5.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion docs/reference/esql/functions/kibana/definition/to_ip.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions docs/reference/esql/functions/kibana/docs/date_trunc.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/kibana/docs/md5.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/kibana/inline_cast.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/reference/esql/functions/layout/to_ip.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/parameters/avg.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/reference/esql/functions/parameters/to_ip.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/signature/to_ip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/reference/esql/functions/types/to_ip.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
*/
package org.elasticsearch.xpack.esql.core.expression;

import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.RamUsageEstimator;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -35,7 +37,9 @@
/**
* Literal or constant.
*/
public class Literal extends LeafExpression {
public class Literal extends LeafExpression implements Accountable {
private static final long BASE_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(Literal.class);

public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(
Expression.class,
"Literal",
Expand Down Expand Up @@ -169,6 +173,17 @@ public String nodeString() {
return toString() + "[" + dataType + "]";
}

@Override
public long ramBytesUsed() {
long ramBytesUsed = BASE_RAM_BYTES_USED;
if (value instanceof BytesRef b) {
ramBytesUsed += b.length;
} else {
ramBytesUsed += RamUsageEstimator.sizeOfObject(value);
}
return ramBytesUsed;
}

/**
* Utility method for creating a literal out of a foldable expression.
* Throws an exception if the expression is not foldable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;

import static org.elasticsearch.compute.gen.EvaluatorImplementer.baseRamBytesUsed;
import static org.elasticsearch.compute.gen.Methods.buildFromFactory;
import static org.elasticsearch.compute.gen.Methods.getMethod;
import static org.elasticsearch.compute.gen.Types.ABSTRACT_CONVERT_FUNCTION_EVALUATOR;
Expand Down Expand Up @@ -98,6 +99,7 @@ private TypeSpec type() {
builder.addJavadoc("This class is generated. Edit {@code " + getClass().getSimpleName() + "} instead.");
builder.addModifiers(Modifier.PUBLIC, Modifier.FINAL);
builder.superclass(ABSTRACT_CONVERT_FUNCTION_EVALUATOR);
builder.addField(baseRamBytesUsed(implementation));

for (EvaluatorImplementer.ProcessFunctionArg a : processFunction.args) {
a.declareField(builder);
Expand All @@ -113,6 +115,7 @@ private TypeSpec type() {
}
builder.addMethod(processFunction.toStringMethod(implementation));
builder.addMethod(processFunction.close());
builder.addMethod(processFunction.baseRamBytesUsed());
builder.addType(factory());
return builder.build();
}
Expand Down
Loading