mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 15:17:30 -04:00
ESQL: Begin optimizing Block#lookup
(#108482)
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.
This commit is contained in:
parent
2d14095ebf
commit
04d3b9989f
37 changed files with 431 additions and 28 deletions
|
@ -46,4 +46,30 @@ public interface ReleasableIterator<T> extends Releasable, Iterator<T> {
|
|||
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an empty iterator over the supplied value.
|
||||
*/
|
||||
static <T extends Releasable> ReleasableIterator<T> empty() {
|
||||
return new ReleasableIterator<>() {
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
assert false : "hasNext is always false so next should never be called";
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReleasableIterator[<empty>]";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue