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
This commit is contained in:
Maytas Monsereenusorn 2024-01-17 21:59:53 -08:00 committed by GitHub
parent a26defd64b
commit a3b32fbd26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 58 deletions

View File

@ -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<AggregatorFactory> 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<AggregatorFactory> 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<AggregatorFactory> getRequiredColumns()
{
return Collections.singletonList(
new SpectatorHistogramAggregatorFactory.Distribution(
getFieldName(),
getFieldName()
)
);
}
}
}

View File

@ -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<Double> getComparator()
public Comparator<Object> getComparator()
{
return Doubles::compare;
return ColumnType.DOUBLE_ARRAY.getStrategy();
}
@Override

View File

@ -72,13 +72,6 @@ public class PassthroughAggregatorFactory extends AggregatorFactory
return columnName;
}
@Override
@JsonProperty
public String getComplexTypeName()
{
return complexTypeName;
}
@Override
public byte[] getCacheKey()
{