Skip to content

Commit 84014cd

Browse files
authored
ESQL: Block loader for pushing LENGTH (#137217)
Creates a `BlockLoader` for pushing the `LENGTH` function down into the loader for `keyword` fields. It takes advantage of the terms dictionary so we only need to calculate the code point count once per unique term loaded. This `BlockLoader` implementation isn't plugged into the infrastructure for emitting it because we're waiting on the infrastructure we've started in #137002. We'll make a follow up PR to plug this in. We're doing this mostly to demonstrate another function that we can push into field loading, in addition to the vector similarity functions we're building in #137002. We don't expect `LENGTH` to be a super hot function. If it happens to be then this'll help. Before we plug this in we'll have to figure out emitting warnings from functions that we've fused to field loading. Because `LENGTH` can emit a warning, specifically when it hits a multivalued field.
1 parent 6e35e1a commit 84014cd

File tree

8 files changed

+791
-0
lines changed

8 files changed

+791
-0
lines changed

server/src/main/java/org/elasticsearch/index/mapper/BlockLoader.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.apache.lucene.index.SortedDocValues;
1414
import org.apache.lucene.index.SortedSetDocValues;
1515
import org.apache.lucene.util.BytesRef;
16+
import org.elasticsearch.common.breaker.CircuitBreakingException;
1617
import org.elasticsearch.core.Nullable;
1718
import org.elasticsearch.core.Releasable;
1819
import org.elasticsearch.index.mapper.blockloader.docvalues.BlockDocValuesReader;
@@ -377,6 +378,13 @@ interface Docs {
377378
* also a test implementation, but there may be no more other implementations.
378379
*/
379380
interface BlockFactory {
381+
/**
382+
* Adjust the circuit breaker with the given delta, if the delta is negative, the breaker will
383+
* be adjusted without tripping.
384+
* @throws CircuitBreakingException if the breaker was put above its limit
385+
*/
386+
void adjustBreaker(long delta) throws CircuitBreakingException;
387+
380388
/**
381389
* Build a builder to load booleans as loaded from doc values. Doc values
382390
* load booleans in sorted order.
@@ -486,6 +494,12 @@ interface BlockFactory {
486494
*/
487495
Block constantBytes(BytesRef value, int count);
488496

497+
/**
498+
* Build a block that contains {@code value} repeated
499+
* {@code count} times.
500+
*/
501+
Block constantInt(int value, int count);
502+
489503
/**
490504
* Build a reader for reading {@link SortedDocValues}
491505
*/

0 commit comments

Comments
 (0)