Skip to content

ESQL: Specialize aggs AddInput for each block type #127582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/127582.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 127582
summary: Specialize ags `AddInput` for each block type
area: ES|QL
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
import static org.elasticsearch.compute.gen.Types.GROUPING_AGGREGATOR_FUNCTION;
import static org.elasticsearch.compute.gen.Types.GROUPING_AGGREGATOR_FUNCTION_ADD_INPUT;
import static org.elasticsearch.compute.gen.Types.INTERMEDIATE_STATE_DESC;
import static org.elasticsearch.compute.gen.Types.INT_BLOCK;
import static org.elasticsearch.compute.gen.Types.INT_ARRAY_BLOCK;
import static org.elasticsearch.compute.gen.Types.INT_BIG_ARRAY_BLOCK;
import static org.elasticsearch.compute.gen.Types.INT_VECTOR;
import static org.elasticsearch.compute.gen.Types.LIST_AGG_FUNC_DESC;
import static org.elasticsearch.compute.gen.Types.LIST_INTEGER;
Expand All @@ -76,6 +77,8 @@
* and break-point-able as possible.
*/
public class GroupingAggregatorImplementer {
private static final List<ClassName> GROUP_IDS_CLASSES = List.of(INT_ARRAY_BLOCK, INT_BIG_ARRAY_BLOCK, INT_VECTOR);

private final TypeElement declarationType;
private final List<TypeMirror> warnExceptions;
private final ExecutableElement init;
Expand Down Expand Up @@ -196,10 +199,10 @@ private TypeSpec type() {
builder.addMethod(intermediateStateDesc());
builder.addMethod(intermediateBlockCount());
builder.addMethod(prepareProcessPage());
builder.addMethod(addRawInputLoop(INT_VECTOR, blockType(aggParam.type())));
builder.addMethod(addRawInputLoop(INT_VECTOR, vectorType(aggParam.type())));
builder.addMethod(addRawInputLoop(INT_BLOCK, blockType(aggParam.type())));
builder.addMethod(addRawInputLoop(INT_BLOCK, vectorType(aggParam.type())));
for (ClassName groupIdClass : GROUP_IDS_CLASSES) {
builder.addMethod(addRawInputLoop(groupIdClass, blockType(aggParam.type())));
builder.addMethod(addRawInputLoop(groupIdClass, vectorType(aggParam.type())));
}
builder.addMethod(selectedMayContainUnseenGroups());
builder.addMethod(addIntermediateInput());
builder.addMethod(addIntermediateRowInput());
Expand Down Expand Up @@ -347,15 +350,12 @@ private TypeSpec addInput(Consumer<MethodSpec.Builder> addBlock) {
TypeSpec.Builder builder = TypeSpec.anonymousClassBuilder("");
builder.addSuperinterface(GROUPING_AGGREGATOR_FUNCTION_ADD_INPUT);

MethodSpec.Builder block = MethodSpec.methodBuilder("add").addAnnotation(Override.class).addModifiers(Modifier.PUBLIC);
block.addParameter(TypeName.INT, "positionOffset").addParameter(INT_BLOCK, "groupIds");
addBlock.accept(block);
builder.addMethod(block.build());

MethodSpec.Builder vector = MethodSpec.methodBuilder("add").addAnnotation(Override.class).addModifiers(Modifier.PUBLIC);
vector.addParameter(TypeName.INT, "positionOffset").addParameter(INT_VECTOR, "groupIds");
addBlock.accept(vector);
builder.addMethod(vector.build());
for (ClassName groupIdsType : GROUP_IDS_CLASSES) {
MethodSpec.Builder vector = MethodSpec.methodBuilder("add").addAnnotation(Override.class).addModifiers(Modifier.PUBLIC);
vector.addParameter(TypeName.INT, "positionOffset").addParameter(groupIdsType, "groupIds");
addBlock.accept(vector);
builder.addMethod(vector.build());
}

MethodSpec.Builder close = MethodSpec.methodBuilder("close").addAnnotation(Override.class).addModifiers(Modifier.PUBLIC);
builder.addMethod(close.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class Types {
static final ClassName BOOLEAN_BLOCK = ClassName.get(DATA_PACKAGE, "BooleanBlock");
static final ClassName BYTES_REF_BLOCK = ClassName.get(DATA_PACKAGE, "BytesRefBlock");
static final ClassName INT_BLOCK = ClassName.get(DATA_PACKAGE, "IntBlock");
static final ClassName INT_ARRAY_BLOCK = ClassName.get(DATA_PACKAGE, "IntArrayBlock");
static final ClassName INT_BIG_ARRAY_BLOCK = ClassName.get(DATA_PACKAGE, "IntBigArrayBlock");
static final ClassName LONG_BLOCK = ClassName.get(DATA_PACKAGE, "LongBlock");
static final ClassName DOUBLE_BLOCK = ClassName.get(DATA_PACKAGE, "DoubleBlock");
static final ClassName FLOAT_BLOCK = ClassName.get(DATA_PACKAGE, "FloatBlock");
Expand Down

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.

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.

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.

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.

Loading
Loading