Skip to content

Commit 5965752

Browse files
committed
Add SPARKLINE aggregation fuction
1 parent 7f90465 commit 5965752

File tree

42 files changed

+6861
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+6861
-172
lines changed

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def prop(Name, Type, type, Wrapper, TYPE, BYTES, Array, Hash) {
7878
"boolean" : Name == "Boolean" ? "true" : "",
7979
"BytesRef": Name == "BytesRef" ? "true" : "",
8080
"Ip" : Name == "Ip" ? "true" : "",
81+
"Tuple" : Name.startsWith("Tuple") ? "true" : "",
8182
]
8283
}
8384

@@ -107,6 +108,10 @@ tasks.named('stringTemplates').configure {
107108
"BytesRefHash"
108109
)
109110
var ipProperties = prop("Ip", "BytesRef", "BytesRef", "", "BYTES_REF", "16", "", "")
111+
var tupleLongIntProperties = prop("TupleLongInt", "Int", "Tuple<Long, Integer>", "Integer", "OBJECT", "Long.BYTES + Integer.BYTES", "ObjectArray<Tuple<Long, Integer>>", "")
112+
var tupleLongFloatProperties = prop("TupleLongFloat", "Float", "Tuple<Long, Float>", "Float", "OBJECT", "Long.BYTES + Float.BYTES", "ObjectArray<Tuple<Long, Float>>", "")
113+
var tupleLongLongProperties = prop("TupleLongLong", "Long", "Tuple<Long, Long>", "Long", "OBJECT", "2 * Long.BYTES", "ObjectArray<Tuple<Long, Long>>", "")
114+
var tupleLongDoubleProperties = prop("TupleLongDouble", "Double", "Tuple<Long, Double>", "Double", "OBJECT", "Long.BYTES + Double.BYTES", "ObjectArray<Tuple<Long, Double>>", "")
110115

111116
// primitive vectors
112117
File vectorInputFile = new File("${projectDir}/src/main/java/org/elasticsearch/compute/data/X-Vector.java.st")
@@ -628,6 +633,28 @@ tasks.named('stringTemplates').configure {
628633
it.outputFile = "org/elasticsearch/compute/aggregation/ValuesBytesRefAggregator.java"
629634
}
630635

636+
File sparklineAggregatorInputFile = new File("${projectDir}/src/main/java/org/elasticsearch/compute/aggregation/X-SparklineAggregator.java.st")
637+
template {
638+
it.properties = intProperties
639+
it.inputFile = sparklineAggregatorInputFile
640+
it.outputFile = "org/elasticsearch/compute/aggregation/SparklineIntAggregator.java"
641+
}
642+
template {
643+
it.properties = longProperties
644+
it.inputFile = sparklineAggregatorInputFile
645+
it.outputFile = "org/elasticsearch/compute/aggregation/SparklineLongAggregator.java"
646+
}
647+
template {
648+
it.properties = floatProperties
649+
it.inputFile = sparklineAggregatorInputFile
650+
it.outputFile = "org/elasticsearch/compute/aggregation/SparklineFloatAggregator.java"
651+
}
652+
template {
653+
it.properties = doubleProperties
654+
it.inputFile = sparklineAggregatorInputFile
655+
it.outputFile = "org/elasticsearch/compute/aggregation/SparklineDoubleAggregator.java"
656+
}
657+
631658
File rateAggregatorInputFile = file("src/main/java/org/elasticsearch/compute/aggregation/X-RateAggregator.java.st")
632659
template {
633660
it.properties = intProperties
@@ -893,6 +920,26 @@ tasks.named('stringTemplates').configure {
893920
it.inputFile = bucketedSortInputFile
894921
it.outputFile = "org/elasticsearch/compute/data/sort/DoubleBucketedSort.java"
895922
}
923+
template {
924+
it.properties = tupleLongIntProperties
925+
it.inputFile = bucketedSortInputFile
926+
it.outputFile = "org/elasticsearch/compute/data/sort/TupleLongIntBucketedSort.java"
927+
}
928+
template {
929+
it.properties = tupleLongLongProperties
930+
it.inputFile = bucketedSortInputFile
931+
it.outputFile = "org/elasticsearch/compute/data/sort/TupleLongLongBucketedSort.java"
932+
}
933+
template {
934+
it.properties = tupleLongFloatProperties
935+
it.inputFile = bucketedSortInputFile
936+
it.outputFile = "org/elasticsearch/compute/data/sort/TupleLongFloatBucketedSort.java"
937+
}
938+
template {
939+
it.properties = tupleLongDoubleProperties
940+
it.inputFile = bucketedSortInputFile
941+
it.outputFile = "org/elasticsearch/compute/data/sort/TupleLongDoubleBucketedSort.java"
942+
}
896943

897944
File enrichResultBuilderInput = file("src/main/java/org/elasticsearch/compute/operator/lookup/X-EnrichResultBuilder.java.st")
898945
template {

x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/AggregatorImplementer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ private MethodSpec addIntermediateInput() {
604604
declarationType,
605605
requireVoidType(),
606606
requireName("combineIntermediate"),
607-
requireArgs(
607+
requireArgsStartsWith(
608608
Stream.concat(
609609
Stream.of(aggState.declaredType()), // aggState
610610
intermediateState.stream().map(IntermediateStateDesc::combineArgType) // intermediate state

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

Lines changed: 153 additions & 0 deletions
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/generated-src/org/elasticsearch/compute/aggregation/SparklineFloatAggregator.java

Lines changed: 153 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)