File tree Expand file tree Collapse file tree 3 files changed +59
-1
lines changed
x-pack/plugin/esql/compute/src
main/java/org/elasticsearch/compute/operator/topn
test/java/org/elasticsearch/compute/data Expand file tree Collapse file tree 3 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ static ResultBuilder resultBuilderFor(
63
63
case NULL -> new ResultBuilderForNull (blockFactory );
64
64
case DOC -> new ResultBuilderForDoc (blockFactory , positions );
65
65
case AGGREGATE_METRIC_DOUBLE -> new ResultBuilderForAggregateMetricDouble (blockFactory , positions );
66
+ case DATE_RANGE -> new ResultBuilderForDateRange (blockFactory , positions );
66
67
default -> {
67
68
assert false : "Result builder for [" + elementType + "]" ;
68
69
throw new UnsupportedOperationException ("Result builder for [" + elementType + "]" );
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0; you may not use this file except in compliance with the Elastic License
5
+ * 2.0.
6
+ */
7
+
8
+ package org .elasticsearch .compute .operator .topn ;
9
+
10
+ import org .apache .lucene .util .BytesRef ;
11
+ import org .elasticsearch .compute .data .DateRangeBlockBuilder ;
12
+ import org .elasticsearch .compute .data .Block ;
13
+ import org .elasticsearch .compute .data .BlockFactory ;
14
+ import org .elasticsearch .index .mapper .BlockLoader ;
15
+
16
+ import java .util .List ;
17
+
18
+ public class ResultBuilderForDateRange implements ResultBuilder {
19
+
20
+ private final DateRangeBlockBuilder builder ;
21
+
22
+ ResultBuilderForDateRange (BlockFactory blockFactory , int positions ) {
23
+ this .builder = blockFactory .newDateRangeBlockBuilder (positions );
24
+ }
25
+
26
+ @ Override
27
+ public void decodeKey (BytesRef keys ) {
28
+ throw new AssertionError ("DateRangeBlock can't be a key" );
29
+ }
30
+
31
+ @ Override
32
+ public void decodeValue (BytesRef values ) {
33
+ int count = TopNEncoder .DEFAULT_UNSORTABLE .decodeVInt (values );
34
+ if (count == 0 ) {
35
+ builder .appendNull ();
36
+ } else {
37
+ builder .from ().appendLong (TopNEncoder .DEFAULT_UNSORTABLE .decodeLong (values ));
38
+ builder .to ().appendLong (TopNEncoder .DEFAULT_UNSORTABLE .decodeLong (values ));
39
+ }
40
+ }
41
+
42
+ @ Override
43
+ public Block build () {
44
+ return builder .build ();
45
+ }
46
+
47
+ @ Override
48
+ public String toString () {
49
+ return "ResultBuilderForDateRange" ;
50
+ }
51
+
52
+ @ Override
53
+ public void close () {
54
+ builder .close ();
55
+ }
56
+ }
Original file line number Diff line number Diff line change @@ -34,7 +34,8 @@ public static List<Object[]> params() {
34
34
|| e == ElementType .NULL
35
35
|| e == ElementType .DOC
36
36
|| e == ElementType .COMPOSITE
37
- || e == ElementType .AGGREGATE_METRIC_DOUBLE ) {
37
+ || e == ElementType .AGGREGATE_METRIC_DOUBLE
38
+ || e == ElementType .DATE_RANGE ) {
38
39
continue ;
39
40
}
40
41
params .add (new Object [] { e });
You can’t perform that action at this time.
0 commit comments