Skip to content

Commit 98af2ef

Browse files
authored
ESQL: Explain test operators (#132374)
Adds javadoc to the `NullInserting` and `PositionMerging` operators we use for testing the standard behavior for aggs. Relates to #108385
1 parent 8d04055 commit 98af2ef

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/NullInsertingSourceOperator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import static org.elasticsearch.test.ESTestCase.between;
2525

2626
/**
27-
* Inserts nulls into blocks
27+
* Inserts "null rows" between incoming rows. By default, a "null row" contains
28+
* {@code null} in every {@link Block}. Override {@link #appendNull} to customize
29+
* how "null rows" are built.
2830
*/
2931
public class NullInsertingSourceOperator extends MappingSourceOperator {
3032
final BlockFactory blockFactory;
@@ -58,6 +60,9 @@ protected Page map(Page page) {
5860
return result;
5961
}
6062

63+
/**
64+
* Called on a "null row" to insert values.
65+
*/
6166
protected void appendNull(ElementType elementType, Block.Builder builder, int blockId) {
6267
builder.appendNull();
6368
}

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/PositionMergingSourceOperator.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,31 @@
1818
import org.elasticsearch.compute.data.LongBlock;
1919
import org.elasticsearch.compute.data.Page;
2020

21+
/**
22+
* Merges adjacent pairs of positions together into one, block by block.
23+
* <p>
24+
* For example:
25+
* </p>
26+
* <pre>{@code
27+
* a | b
28+
* ----- | -----
29+
* 1 | a
30+
* 2 | b
31+
* 3, 4 | c, d
32+
* 5, 6 | e, f
33+
* 7 | null <---- nulls count as empty lists
34+
* null | g
35+
* 4 | d <---- if the input is odd, trailing rows are dropped
36+
* }</pre>
37+
* becomes
38+
* <pre>{@code
39+
* a | b
40+
* ---------- | ----------
41+
* 1, 2 | a, b
42+
* 3, 4, 5, 6 | c, d, e, f
43+
* 7 | g
44+
* }</pre>
45+
*/
2146
public class PositionMergingSourceOperator extends MappingSourceOperator {
2247
final BlockFactory blockFactory;
2348

0 commit comments

Comments
 (0)