Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 33 additions & 22 deletions x-pack/plugin/esql/compute/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ def prop(Name, Type, type, Wrapper, TYPE, BYTES, Array, Hash) {
]
}

def addOccurrence(props, Occurrence) {
def newProps = props.collectEntries { [(it.key): it.value] }
newProps["Occurrence"] = Occurrence
newProps["First"] = Occurrence == "First" ? "true" : ""
newProps["Last"] = Occurrence == "Last" ? "true" : ""
return newProps
}

tasks.named('stringTemplates').configure {
var intProperties = prop("Int", "Int", "int", "Integer", "INT", "Integer.BYTES", "IntArray", "LongHash")
var floatProperties = prop("Float", "Float", "float", "Float", "FLOAT", "Float.BYTES", "FloatArray", "LongHash")
Expand Down Expand Up @@ -862,27 +870,30 @@ tasks.named('stringTemplates').configure {
it.outputFile = "org/elasticsearch/xpack/compute/operator/lookup/EnrichResultBuilderForBoolean.java"
}

// TODO: add last_over_time for other types: boolean, bytes_refs
File lastOverTimeAggregatorInputFile = file("src/main/java/org/elasticsearch/compute/aggregation/X-LastOverTimeAggregator.java.st")
template {
it.properties = intProperties
it.inputFile = lastOverTimeAggregatorInputFile
it.outputFile = "org/elasticsearch/compute/aggregation/LastOverTimeIntAggregator.java"
}
template {
it.properties = longProperties
it.inputFile = lastOverTimeAggregatorInputFile
it.outputFile = "org/elasticsearch/compute/aggregation/LastOverTimeLongAggregator.java"
// TODO: add {value}_over_time for other types: boolean, bytes_refs
File valueOverTimeAggregatorInputFile = file("src/main/java/org/elasticsearch/compute/aggregation/X-ValueOverTimeAggregator.java.st")
["First", "Last"].forEach { Occurrence ->
{
template {
it.properties = addOccurrence(intProperties, Occurrence)
it.inputFile = valueOverTimeAggregatorInputFile
it.outputFile = "org/elasticsearch/compute/aggregation/${Occurrence}OverTimeIntAggregator.java"
}
template {
it.properties = addOccurrence(longProperties, Occurrence)
it.inputFile = valueOverTimeAggregatorInputFile
it.outputFile = "org/elasticsearch/compute/aggregation/${Occurrence}OverTimeLongAggregator.java"
}
template {
it.properties = addOccurrence(floatProperties, Occurrence)
it.inputFile = valueOverTimeAggregatorInputFile
it.outputFile = "org/elasticsearch/compute/aggregation/${Occurrence}OverTimeFloatAggregator.java"
}
template {
it.properties = addOccurrence(doubleProperties, Occurrence)
it.inputFile = valueOverTimeAggregatorInputFile
it.outputFile = "org/elasticsearch/compute/aggregation/${Occurrence}OverTimeDoubleAggregator.java"
}
}
}
template {
it.properties = floatProperties
it.inputFile = lastOverTimeAggregatorInputFile
it.outputFile = "org/elasticsearch/compute/aggregation/LastOverTimeFloatAggregator.java"
}
template {
it.properties = doubleProperties
it.inputFile = lastOverTimeAggregatorInputFile
it.outputFile = "org/elasticsearch/compute/aggregation/LastOverTimeDoubleAggregator.java"
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading