Skip to content

Commit 586b109

Browse files
committed
Add TODOs
1 parent 50d6a85 commit 586b109

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/ChangePointLongAggregator.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,20 @@
3737
import java.util.function.Function;
3838

3939
/**
40-
* Aggregates field values for long.
41-
* TODO: make .java.st from this to support other types
42-
* TODO: add "includeTimestamp" to @Aggregator
40+
* Change point detection for series of long values.
4341
*/
44-
// TODO: add normal @Aggregator
45-
// @Aggregator({
46-
// includeTimestamps = true,
47-
// @IntermediateState(name = "timestamps", type = "LONG_BLOCK"),
48-
// @IntermediateState(name = "values", type = "LONG_BLOCK") })
42+
43+
// TODO: make .java.st from this to support different types
44+
45+
// TODO: add non-grouping @Aggregator, like this:
46+
/*
47+
@Aggregator(
48+
includeTimestamps = true,
49+
value = { @IntermediateState(name = "timestamps", type = "LONG_BLOCK"), @IntermediateState(name = "values", type = "LONG_BLOCK") }
50+
)
51+
*/
52+
// This need "includeTimestamps" support in @Aggregator.
53+
4954
@GroupingAggregator(
5055
includeTimestamps = true,
5156
value = { @IntermediateState(name = "timestamps", type = "LONG_BLOCK"), @IntermediateState(name = "values", type = "LONG_BLOCK") }
@@ -123,7 +128,7 @@ public int compareTo(TimeAndValue other) {
123128
}
124129

125130
void sort() {
126-
// TODO: this is very inefficient and doesn't account for memory!
131+
// TODO: this copying is a bit inefficient and doesn't account for memory
127132
List<TimeAndValue> list = new ArrayList<>(count);
128133
for (int i = 0; i < count; i++) {
129134
list.add(new TimeAndValue(timestamps.get(i), values.get(i)));
@@ -185,6 +190,7 @@ void toIntermediate(Block[] blocks, int offset, IntVector selected, DriverContex
185190
}
186191

187192
public Block evaluateFinal(IntVector selected, BlockFactory blockFactory) {
193+
// TODO: this needs to output multiple columns or a composite object, not a JSON blob.
188194
try (BytesRefBlock.Builder builder = blockFactory.newBytesRefBlockBuilder(selected.getPositionCount())) {
189195
for (int s = 0; s < selected.getPositionCount(); s++) {
190196
SingleState state = states.get(selected.getInt(s));
@@ -244,7 +250,6 @@ Block toBlock(Function<SingleState, LongArray> getArray, BlockFactory blockFacto
244250
}
245251

246252
void enableGroupIdTracking(SeenGroupIds seenGroupIds) {
247-
// noop - we handle the null states inside `toIntermediate` and `evaluateFinal`
248253
}
249254

250255
@Override

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/ChangePoint.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class ChangePoint extends AggregateFunction implements ToAggregator {
3636
ChangePoint::new
3737
);
3838

39+
// TODO: make "timestamp" field optional
3940
@FunctionInfo(returnType = { "string" }, description = "...", isAggregation = true)
4041
public ChangePoint(
4142
Source source,
@@ -77,6 +78,7 @@ public ChangePoint replaceChildren(List<Expression> newChildren) {
7778
return new ChangePoint(source(), newChildren.get(0), newChildren.get(1), newChildren.get(2));
7879
}
7980

81+
// TODO: this needs to output multiple columns or a composite object
8082
@Override
8183
public DataType dataType() {
8284
return DataType.KEYWORD;
@@ -103,6 +105,7 @@ public AggregatorFunctionSupplier supplier(List<Integer> inputChannels) {
103105
final DataType type = field().dataType();
104106
return switch (type) {
105107
case LONG -> new ChangePointLongAggregatorFunctionSupplier(inputChannels);
108+
// TODO: support other types
106109
default -> throw EsqlIllegalArgumentException.illegalDataType(type);
107110
};
108111
}

0 commit comments

Comments
 (0)