Skip to content

Commit b3568ba

Browse files
authored
ESQL: Move some of ENRICH into compute (#116338)
* ESQL: Move some of ENRICH into compute Move much of the code powering ENRICH and LOOKUP from index into the `compute` project which has better support for testing `Operator`s. This is *almost* just a move - except that I had to change the way `QueryList` looks at `DataType` - because `compute` doesn't have `DataType`. Instead I've moved the places where we used `DataType` into method calls. I haven't changed how anything works in the tight loop - but I have changed how it works in the setup. * Do better * Rename * Drop extra
1 parent 138bfec commit b3568ba

File tree

19 files changed

+158
-140
lines changed

19 files changed

+158
-140
lines changed

x-pack/plugin/esql/build.gradle

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -289,34 +289,6 @@ tasks.named('stringTemplates').configure {
289289
var doubleProperties = prop("Double", "double", "DOUBLE", "Double.BYTES", "DoubleArray")
290290
var bytesRefProperties = prop("BytesRef", "BytesRef", "BYTES_REF", "org.apache.lucene.util.RamUsageEstimator.NUM_BYTES_OBJECT_REF", "")
291291
var booleanProperties = prop("Boolean", "boolean", "BOOLEAN", "Byte.BYTES", "BitArray")
292-
// enrich
293-
File enrichResultBuilderInput = file("src/main/java/org/elasticsearch/xpack/esql/enrich/X-EnrichResultBuilder.java.st")
294-
template {
295-
it.properties = intProperties
296-
it.inputFile = enrichResultBuilderInput
297-
it.outputFile = "org/elasticsearch/xpack/esql/enrich/EnrichResultBuilderForInt.java"
298-
}
299-
template {
300-
it.properties = longProperties
301-
it.inputFile = enrichResultBuilderInput
302-
it.outputFile = "org/elasticsearch/xpack/esql/enrich/EnrichResultBuilderForLong.java"
303-
}
304-
template {
305-
it.properties = doubleProperties
306-
it.inputFile = enrichResultBuilderInput
307-
it.outputFile = "org/elasticsearch/xpack/esql/enrich/EnrichResultBuilderForDouble.java"
308-
}
309-
template {
310-
it.properties = bytesRefProperties
311-
it.inputFile = enrichResultBuilderInput
312-
it.outputFile = "org/elasticsearch/xpack/esql/enrich/EnrichResultBuilderForBytesRef.java"
313-
}
314-
template {
315-
it.properties = booleanProperties
316-
it.inputFile = enrichResultBuilderInput
317-
it.outputFile = "org/elasticsearch/xpack/esql/enrich/EnrichResultBuilderForBoolean.java"
318-
}
319-
320292

321293
File inInputFile = file("src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/X-InEvaluator.java.st")
322294
template {

x-pack/plugin/esql/compute/build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,4 +803,32 @@ tasks.named('stringTemplates').configure {
803803
it.inputFile = bucketedSortInputFile
804804
it.outputFile = "org/elasticsearch/compute/data/sort/DoubleBucketedSort.java"
805805
}
806+
807+
File enrichResultBuilderInput = file("src/main/java/org/elasticsearch/compute/operator/lookup/X-EnrichResultBuilder.java.st")
808+
template {
809+
it.properties = intProperties
810+
it.inputFile = enrichResultBuilderInput
811+
it.outputFile = "org/elasticsearch/xpack/compute/operator/lookup/EnrichResultBuilderForInt.java"
812+
}
813+
template {
814+
it.properties = longProperties
815+
it.inputFile = enrichResultBuilderInput
816+
it.outputFile = "org/elasticsearch/xpack/compute/operator/lookup/EnrichResultBuilderForLong.java"
817+
}
818+
template {
819+
it.properties = doubleProperties
820+
it.inputFile = enrichResultBuilderInput
821+
it.outputFile = "org/elasticsearch/xpack/compute/operator/lookup/EnrichResultBuilderForDouble.java"
822+
}
823+
template {
824+
it.properties = bytesRefProperties
825+
it.inputFile = enrichResultBuilderInput
826+
it.outputFile = "org/elasticsearch/xpack/compute/operator/lookup/EnrichResultBuilderForBytesRef.java"
827+
}
828+
template {
829+
it.properties = booleanProperties
830+
it.inputFile = enrichResultBuilderInput
831+
it.outputFile = "org/elasticsearch/xpack/compute/operator/lookup/EnrichResultBuilderForBoolean.java"
832+
}
833+
806834
}
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
exports org.elasticsearch.compute.operator.exchange;
3030
exports org.elasticsearch.compute.aggregation.blockhash;
3131
exports org.elasticsearch.compute.aggregation.spatial;
32+
exports org.elasticsearch.compute.operator.lookup;
3233
exports org.elasticsearch.compute.operator.topn;
3334
exports org.elasticsearch.compute.operator.mvdedupe;
3435
exports org.elasticsearch.compute.aggregation.table;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichQuerySourceOperator.java renamed to x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/lookup/EnrichQuerySourceOperator.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
package org.elasticsearch.xpack.esql.enrich;
8+
package org.elasticsearch.compute.operator.lookup;
99

1010
import org.apache.lucene.index.IndexReader;
1111
import org.apache.lucene.index.LeafReaderContext;
@@ -32,8 +32,7 @@
3232
* This operator will emit Pages consisting of a {@link DocVector} and {@link IntBlock} of positions for each query of the input queries.
3333
* The position block will be used as keys to combine the extracted values by {@link MergePositionsOperator}.
3434
*/
35-
final class EnrichQuerySourceOperator extends SourceOperator {
36-
35+
public final class EnrichQuerySourceOperator extends SourceOperator {
3736
private final BlockFactory blockFactory;
3837
private final QueryList queryList;
3938
private int queryPosition = -1;
@@ -42,9 +41,9 @@ final class EnrichQuerySourceOperator extends SourceOperator {
4241
private final int maxPageSize;
4342

4443
// using smaller pages enables quick cancellation and reduces sorting costs
45-
static final int DEFAULT_MAX_PAGE_SIZE = 256;
44+
public static final int DEFAULT_MAX_PAGE_SIZE = 256;
4645

47-
EnrichQuerySourceOperator(BlockFactory blockFactory, int maxPageSize, QueryList queryList, IndexReader indexReader) {
46+
public EnrichQuerySourceOperator(BlockFactory blockFactory, int maxPageSize, QueryList queryList, IndexReader indexReader) {
4847
this.blockFactory = blockFactory;
4948
this.maxPageSize = maxPageSize;
5049
this.queryList = queryList;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichResultBuilder.java renamed to x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/lookup/EnrichResultBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
package org.elasticsearch.xpack.esql.enrich;
8+
package org.elasticsearch.compute.operator.lookup;
99

1010
import org.elasticsearch.compute.data.Block;
1111
import org.elasticsearch.compute.data.BlockFactory;

0 commit comments

Comments
 (0)