From 9c5f0329607bca206c428162ee4fa17653dde7be Mon Sep 17 00:00:00 2001 From: 761417898 <761417898@qq.com> Date: Mon, 19 Oct 2026 15:54:00 +0800 Subject: [PATCH 1/2] Avoid eager aggregation type coverage checks on first query --- .../java/org/apache/iotdb/db/utils/TypeServices.java | 11 ++--------- .../org/apache/iotdb/db/utils/TypeServicesTest.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeServices.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeServices.java index 25e75046ea6bc..ca2013cf3b400 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeServices.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeServices.java @@ -914,6 +914,8 @@ private Transformation() { public static final class Aggregation { + // Validate all type branches in TypeServicesTest. Doing so here eagerly constructs unrelated + // strategies and initializes the calc registry on the first aggregation query. public static final TypeService EXTREME_VALUE_ACCUMULATOR_STRATEGY_SERVICE = type -> @@ -1458,15 +1460,6 @@ public void writeResult(final ColumnBuilder builder, final TsPrimitiveType resul }; }; - static { - EXTREME_VALUE_ACCUMULATOR_STRATEGY_SERVICE.check(); - TIME_VALUE_ACCUMULATOR_STRATEGY_SERVICE.check(); - MAX_MIN_BY_ACCUMULATOR_STRATEGY_SERVICE.check(); - EVENT_WINDOW_MANAGER_PROVIDER_SERVICE.check(); - OUTPUT_COLUMN_SIZE_PER_LINE_SERVICE.check(); - MODE_ACCUMULATOR_PROVIDER_SERVICE.check(); - } - private Aggregation() { // Utility class } diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/TypeServicesTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/TypeServicesTest.java index 6afb127905bdd..708ee48d49f1f 100644 --- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/TypeServicesTest.java +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/TypeServicesTest.java @@ -53,6 +53,16 @@ public class TypeServicesTest { + @Test + public void testAggregationServicesCoverAllTypes() { + TypeServices.Aggregation.EXTREME_VALUE_ACCUMULATOR_STRATEGY_SERVICE.check(); + TypeServices.Aggregation.TIME_VALUE_ACCUMULATOR_STRATEGY_SERVICE.check(); + TypeServices.Aggregation.MAX_MIN_BY_ACCUMULATOR_STRATEGY_SERVICE.check(); + TypeServices.Aggregation.EVENT_WINDOW_MANAGER_PROVIDER_SERVICE.check(); + TypeServices.Aggregation.OUTPUT_COLUMN_SIZE_PER_LINE_SERVICE.check(); + TypeServices.Aggregation.MODE_ACCUMULATOR_PROVIDER_SERVICE.check(); + } + @Test public void testTabletBinarySerializationMatchesLegacyFormat() throws IOException { Binary[] values = { From bd3de20013fd571b20557a6970b72ee40fcc56ae Mon Sep 17 00:00:00 2001 From: 761417898 <761417898@qq.com> Date: Mon, 19 Oct 2026 16:05:18 +0800 Subject: [PATCH 2/2] Remove aggregation initialization comment --- .../src/main/java/org/apache/iotdb/db/utils/TypeServices.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeServices.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeServices.java index ca2013cf3b400..d44ef10bf4721 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeServices.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeServices.java @@ -914,8 +914,6 @@ private Transformation() { public static final class Aggregation { - // Validate all type branches in TypeServicesTest. Doing so here eagerly constructs unrelated - // strategies and initializes the calc registry on the first aggregation query. public static final TypeService EXTREME_VALUE_ACCUMULATOR_STRATEGY_SERVICE = type ->