@@ -496,22 +496,26 @@ tasks.named('stringTemplates').configure {
496496 * Generates pairwise states. We generate the ones that we need at the moment,
497497 * but add more if you need more.
498498 */
499- File twoStateInputFile = file(" src/main/java/org/elasticsearch/compute/aggregation/X-2State.java.st" )
500- [longProperties]. forEach { v1 ->
501- [intProperties, longProperties, floatProperties, doubleProperties, bytesRefProperties]. forEach { v2 ->
502- {
503- var properties = [:]
504- v1. forEach { k , v -> properties[" v1_" + k] = v}
505- v2. forEach { k , v -> properties[" v2_" + k] = v}
499+ def generateTwoStateFiles = { inputFile , prefix = " " ->
500+ def v1Props = [longProperties]
501+ def v2Props = [intProperties, longProperties, floatProperties, doubleProperties, bytesRefProperties]
502+ v1Props. forEach { v1 ->
503+ v2Props. forEach { v2 ->
504+ def properties = [:]
505+ v1. forEach { k , v -> properties[" v1_" + k] = v }
506+ v2. forEach { k , v -> properties[" v2_" + k] = v }
506507 template {
507508 it. properties = properties
508- it. inputFile = twoStateInputFile
509- it. outputFile = " org/elasticsearch/compute/aggregation/${ v1.Type}${ v2.Type} State.java"
509+ it. inputFile = inputFile
510+ it. outputFile = " org/elasticsearch/compute/aggregation/${ prefix }${ v1.Type}${ v2.Type} State.java"
510511 }
511512 }
512513 }
513514 }
514515
516+ generateTwoStateFiles(file(" src/main/java/org/elasticsearch/compute/aggregation/X-2State.java.st" ))
517+ generateTwoStateFiles(file(" src/main/java/org/elasticsearch/compute/aggregation/X-All2State.java.st" ), " All" )
518+
515519 File irateAggregatorInputFile = file(" src/main/java/org/elasticsearch/compute/aggregation/X-IrateAggregator.java.st" )
516520 template {
517521 it. properties = intProperties
@@ -958,37 +962,42 @@ tasks.named('stringTemplates').configure {
958962 }
959963
960964 // TODO: add {value}_over_time for other types: boolean, bytes_refs
961- File valueByTimestampAggregatorInputFile = file(" src/main/java/org/elasticsearch/compute/aggregation/X-ValueByTimestampAggregator.java.st" )
962- [" First" , " Last" ]. forEach { Occurrence ->
963- {
964- template {
965- it. properties = addOccurrence(intProperties, Occurrence )
966- it. inputFile = valueByTimestampAggregatorInputFile
967- it. outputFile = " org/elasticsearch/compute/aggregation/${ Occurrence} IntByTimestampAggregator.java"
968- }
969- template {
970- it. properties = addOccurrence(longProperties, Occurrence )
971- it. inputFile = valueByTimestampAggregatorInputFile
972- it. outputFile = " org/elasticsearch/compute/aggregation/${ Occurrence} LongByTimestampAggregator.java"
973- }
974- template {
975- it. properties = addOccurrence(floatProperties, Occurrence )
976- it. inputFile = valueByTimestampAggregatorInputFile
977- it. outputFile = " org/elasticsearch/compute/aggregation/${ Occurrence} FloatByTimestampAggregator.java"
978- }
979- template {
980- it. properties = addOccurrence(doubleProperties, Occurrence )
981- it. inputFile = valueByTimestampAggregatorInputFile
982- it. outputFile = " org/elasticsearch/compute/aggregation/${ Occurrence} DoubleByTimestampAggregator.java"
983- }
984- template {
985- it. properties = addOccurrence(bytesRefProperties, Occurrence )
986- it. inputFile = valueByTimestampAggregatorInputFile
987- it. outputFile = " org/elasticsearch/compute/aggregation/${ Occurrence} BytesRefByTimestampAggregator.java"
965+ def generateTimestampAggregatorClasses = { inputFilename , prefix = " " ->
966+ def inputFile = file(inputFilename)
967+ [" First" , " Last" ]. forEach { Occurrence ->
968+ {
969+ template {
970+ it. properties = addOccurrence(intProperties, Occurrence ) + [Prefix : prefix]
971+ it. inputFile = inputFile
972+ it. outputFile = " org/elasticsearch/compute/aggregation/${ prefix}${ Occurrence} IntByTimestampAggregator.java"
973+ }
974+ template {
975+ it. properties = addOccurrence(longProperties, Occurrence ) + [Prefix : prefix]
976+ it. inputFile = inputFile
977+ it. outputFile = " org/elasticsearch/compute/aggregation/${ prefix}${ Occurrence} LongByTimestampAggregator.java"
978+ }
979+ template {
980+ it. properties = addOccurrence(floatProperties, Occurrence ) + [Prefix : prefix]
981+ it. inputFile = inputFile
982+ it. outputFile = " org/elasticsearch/compute/aggregation/${ prefix}${ Occurrence} FloatByTimestampAggregator.java"
983+ }
984+ template {
985+ it. properties = addOccurrence(doubleProperties, Occurrence ) + [Prefix : prefix]
986+ it. inputFile = inputFile
987+ it. outputFile = " org/elasticsearch/compute/aggregation/${ prefix}${ Occurrence} DoubleByTimestampAggregator.java"
988+ }
989+ template {
990+ it. properties = addOccurrence(bytesRefProperties, Occurrence ) + [Prefix : prefix]
991+ it. inputFile = inputFile
992+ it. outputFile = " org/elasticsearch/compute/aggregation/${ prefix}${ Occurrence} BytesRefByTimestampAggregator.java"
993+ }
988994 }
989995 }
990996 }
991997
998+ generateTimestampAggregatorClasses(" src/main/java/org/elasticsearch/compute/aggregation/X-ValueByTimestampAggregator.java.st" , " " )
999+ generateTimestampAggregatorClasses(" src/main/java/org/elasticsearch/compute/aggregation/X-AllValueByTimestampAggregator.java.st" , " All" )
1000+
9921001 File rateAggregatorInputFile = file(" src/main/java/org/elasticsearch/compute/aggregation/X-RateGroupingAggregatorFunction.java.st" )
9931002 template {
9941003 it. properties = intProperties
0 commit comments