From a3b32fbd26a53008b0d12aee12688e9923136ef5 Mon Sep 17 00:00:00 2001 From: Maytas Monsereenusorn Date: Wed, 17 Jan 2024 21:59:53 -0800 Subject: [PATCH] Fix comparator and remove deprecated methods from spectatorHistogram extension (#15698) * Remove deprecated methods from SpectatorHistogram * Remove deprecated methods from SpectatorHistogram * Remove deprecated methods from SpectatorHistogram --- .../SpectatorHistogramAggregatorFactory.java | 72 +++++++------------ ...torHistogramPercentilesPostAggregator.java | 5 +- .../util/PassthroughAggregatorFactory.java | 7 -- 3 files changed, 26 insertions(+), 58 deletions(-) diff --git a/extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramAggregatorFactory.java b/extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramAggregatorFactory.java index 235d4781da4..42af6e7f870 100644 --- a/extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramAggregatorFactory.java +++ b/extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramAggregatorFactory.java @@ -32,7 +32,7 @@ import org.apache.druid.query.aggregation.ObjectAggregateCombiner; import org.apache.druid.query.cache.CacheKeyBuilder; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.ColumnValueSelector; -import org.apache.druid.segment.column.ValueType; +import org.apache.druid.segment.column.ColumnType; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -54,6 +54,7 @@ public class SpectatorHistogramAggregatorFactory extends AggregatorFactory private final byte cacheTypeId; public static final String TYPE_NAME = "spectatorHistogram"; + public static final ColumnType TYPE = ColumnType.ofComplex(TYPE_NAME); @JsonCreator public SpectatorHistogramAggregatorFactory( @@ -147,17 +148,6 @@ public class SpectatorHistogramAggregatorFactory extends AggregatorFactory } } - @Override - public List getRequiredColumns() - { - return Collections.singletonList( - new SpectatorHistogramAggregatorFactory( - fieldName, - fieldName - ) - ); - } - @Override public Object deserialize(Object serializedHistogram) { @@ -191,21 +181,15 @@ public class SpectatorHistogramAggregatorFactory extends AggregatorFactory } @Override - public String getComplexTypeName() + public ColumnType getIntermediateType() { - return TYPE_NAME; + return TYPE; } @Override - public ValueType getType() + public ColumnType getResultType() { - return ValueType.COMPLEX; - } - - @Override - public ValueType getFinalizedType() - { - return ValueType.COMPLEX; + return TYPE; } @Override @@ -290,6 +274,7 @@ public class SpectatorHistogramAggregatorFactory extends AggregatorFactory public static class Timer extends SpectatorHistogramAggregatorFactory { public static final String TYPE_NAME = "spectatorHistogramTimer"; + public static final ColumnType TYPE = ColumnType.ofComplex(TYPE_NAME); public Timer( @JsonProperty("name") final String name, @@ -305,9 +290,15 @@ public class SpectatorHistogramAggregatorFactory extends AggregatorFactory } @Override - public String getComplexTypeName() + public ColumnType getIntermediateType() { - return TYPE_NAME; + return TYPE; + } + + @Override + public ColumnType getResultType() + { + return TYPE; } @Override @@ -315,23 +306,13 @@ public class SpectatorHistogramAggregatorFactory extends AggregatorFactory { return new SpectatorHistogramAggregatorFactory.Timer(getName(), getName()); } - - @Override - public List getRequiredColumns() - { - return Collections.singletonList( - new SpectatorHistogramAggregatorFactory.Timer( - getFieldName(), - getFieldName() - ) - ); - } } @JsonTypeName(SpectatorHistogramAggregatorFactory.Distribution.TYPE_NAME) public static class Distribution extends SpectatorHistogramAggregatorFactory { public static final String TYPE_NAME = "spectatorHistogramDistribution"; + public static final ColumnType TYPE = ColumnType.ofComplex(TYPE_NAME); public Distribution( @JsonProperty("name") final String name, @@ -347,9 +328,15 @@ public class SpectatorHistogramAggregatorFactory extends AggregatorFactory } @Override - public String getComplexTypeName() + public ColumnType getIntermediateType() { - return TYPE_NAME; + return TYPE; + } + + @Override + public ColumnType getResultType() + { + return TYPE; } @Override @@ -357,16 +344,5 @@ public class SpectatorHistogramAggregatorFactory extends AggregatorFactory { return new SpectatorHistogramAggregatorFactory.Distribution(getName(), getName()); } - - @Override - public List getRequiredColumns() - { - return Collections.singletonList( - new SpectatorHistogramAggregatorFactory.Distribution( - getFieldName(), - getFieldName() - ) - ); - } } } diff --git a/extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramPercentilesPostAggregator.java b/extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramPercentilesPostAggregator.java index 11ce9e0d9bd..ae6d9392644 100644 --- a/extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramPercentilesPostAggregator.java +++ b/extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramPercentilesPostAggregator.java @@ -22,7 +22,6 @@ package org.apache.druid.spectator.histogram; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Preconditions; -import com.google.common.primitives.Doubles; import org.apache.druid.query.aggregation.AggregatorFactory; import org.apache.druid.query.aggregation.PostAggregator; import org.apache.druid.query.aggregation.post.PostAggregatorIds; @@ -91,9 +90,9 @@ public class SpectatorHistogramPercentilesPostAggregator implements PostAggregat } @Override - public Comparator getComparator() + public Comparator getComparator() { - return Doubles::compare; + return ColumnType.DOUBLE_ARRAY.getStrategy(); } @Override diff --git a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/PassthroughAggregatorFactory.java b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/PassthroughAggregatorFactory.java index f590a2edd80..9d76f8eb895 100644 --- a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/PassthroughAggregatorFactory.java +++ b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/PassthroughAggregatorFactory.java @@ -72,13 +72,6 @@ public class PassthroughAggregatorFactory extends AggregatorFactory return columnName; } - @Override - @JsonProperty - public String getComplexTypeName() - { - return complexTypeName; - } - @Override public byte[] getCacheKey() {