-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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: Begin optimizing Block#lookup
#108482
Conversation
This creates the infrastructure to allow optimizing the `lookup` method when applied to `Vector`s and then implements that optimization for constant vectors. Constant vectors now take one of six paths: 1. An empty positions `Block` yields an empty result set. 2. If `positions` is a `Block`, perform the un-optimized lookup. 3. If the `min` of the `positions` *Vector* is less that 0 then throw an exception. 4. If the `min` of the positions Vector is greater than the number of positions in the lookup block then return a single `ConstantNullBlock` because you are looking up outside the range. 5. If the `max` of the positions Vector is less than the number of positions in the lookup block then return a `Constant$Type$Block` with the same value as the lookup block. This is a lookup that's entirely within range. 6. Otherwise return the unoptimized lookup. This is *fairly* simple but demonstrates how we can plug in more complex optimizations later.
Pinging @elastic/es-analytical-engine (Team:Analytics) |
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.
Core lib change looks good to me, one small suggestion.
|
||
@Override | ||
public T next() { | ||
return null; |
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.
We could assert false here? next should never be called in this case
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.
Sounds good!
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.
LGTM. Thanks Nik!
This creates the infrastructure to allow optimizing the
lookup
method when applied toVector
s and then implements that optimization for constant vectors. Constant vectors now take one of six paths:Block
yields an empty result set.positions
is aBlock
, perform the un-optimized lookup.min
of thepositions
Vector is less that 0 then throw an exception.min
of the positions Vector is greater than the number of positions in the lookup block then return a singleConstantNullBlock
because you are looking up outside the range.max
of the positions Vector is less than the number of positions in the lookup block then return aConstant$Type$Block
with the same value as the lookup block. This is a lookup that's entirely within range.This is fairly simple but demonstrates how we can plug in more complex optimizations later.