-
Notifications
You must be signed in to change notification settings - Fork 25.5k
ESQL: Standardize block args #135160
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
ESQL: Standardize block args #135160
Conversation
Standardizes how aggs and scalars work with arguments that take all values at a position. Aggs were using an arrays of values that we had to copy all of the values into the array. And allocate it. Scalars passed down the `Block` and the scalar read from the block on it's own. That's generally more efficient and not a lot harder. So I standardized on that. Previously scalars that took a `Block` parameter also took an implicit builder and position parameter. But aggs don't need the builder. And *do* need the position. This makes both of those parameters explicit rather than implicit.
Pinging @elastic/es-analytical-engine (Team:Analytics) |
case StandardArgument sa -> Stream.of(new AggregationParameter(sa.name(), sa.type(), false)); | ||
case BlockArgument ba -> Stream.of(new AggregationParameter(ba.name(), Types.elementType(ba.type()), true)); | ||
case PositionArgument pa -> Stream.of(); | ||
default -> throw new IllegalArgumentException("unsupported argument [" + declarationType + "][" + a + "]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the next PR I should be ale to remove this instanceof
and just us the Argument
directly. It'll need a few more methods, but should be fine.
current.add(values); | ||
public static void combine(SpatialExtentState current, @Position int p, IntBlock values) { | ||
current.add(p, values); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the shift from arrays to Block
.
|
||
@Evaluator(extraName = "Int") | ||
static void process(IntBlock.Builder builder, int position, IntBlock field1, IntBlock field2) { | ||
static void process(IntBlock.Builder builder, @Position int position, IntBlock field1, IntBlock field2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here's the explicit @Position
parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks Nik!
"int valuesEnd = valuesStart + $L.getValueCount(valuesPosition)", | ||
aggParams.getFirst().blockName() | ||
); | ||
builder.addStatement("$L[] valuesArray = new $L[valuesEnd - valuesStart]", arrayType, arrayType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Thanks @dnhatn ! |
Standardizes how aggs and scalars work with arguments that take all values at a position. Aggs were using an arrays of values that we had to copy all of the values into the array. And allocate it. Scalars passed down the `Block` and the scalar read from the block on it's own. That's generally more efficient and not a lot harder. So I standardized on that. Previously scalars that took a `Block` parameter also took an implicit builder and position parameter. But aggs don't need the builder. And *do* need the position. This makes both of those parameters explicit rather than implicit.
Standardizes how aggs and scalars work with arguments that take all values at a position. Aggs were using an arrays of values that we had to copy all of the values into the array. And allocate it. Scalars passed down the `Block` and the scalar read from the block on it's own. That's generally more efficient and not a lot harder. So I standardized on that. Previously scalars that took a `Block` parameter also took an implicit builder and position parameter. But aggs don't need the builder. And *do* need the position. This makes both of those parameters explicit rather than implicit.
Standardizes how aggs and scalars work with arguments that take all
values at a position.
Aggs were using an arrays of values that we had to copy all of the
values into the array. And allocate it. Scalars passed down the
Block
and the scalar read from the block on it's own. That's generally more
efficient and not a lot harder. So I standardized on that.
Previously scalars that took a
Block
parameter also took an implicitbuilder and position parameter. But aggs don't need the builder. And
do need the position. This makes both of those parameters explicit
rather than implicit.
Relates to #108385