From d0ec94512909dc883081267967fac9fb0b4f8d70 Mon Sep 17 00:00:00 2001 From: Himanshu Gupta Date: Tue, 12 May 2015 13:13:16 -0500 Subject: [PATCH] adding aliases doubleMax and doubleMin for max and min respectively renamed all [Max/Min]*.java to [DoubleMax/DoubleMin]*.java and created [Max/Min]AggregatorFactory.java which can be removed when we dont need the min/max aggregator type backward compatibility --- .../ApproximateHistogramTopNQueryTest.java | 8 +- .../io/druid/jackson/AggregatorsModule.java | 10 +- ...gregator.java => DoubleMaxAggregator.java} | 6 +- .../DoubleMaxAggregatorFactory.java | 181 +++++++++++++++++ ...or.java => DoubleMaxBufferAggregator.java} | 4 +- ...gregator.java => DoubleMinAggregator.java} | 6 +- .../DoubleMinAggregatorFactory.java | 181 +++++++++++++++++ ...or.java => DoubleMinBufferAggregator.java} | 4 +- .../aggregation/MaxAggregatorFactory.java | 187 ++--------------- .../aggregation/MinAggregatorFactory.java | 189 ++---------------- .../query/aggregation/AggregatorUtilTest.java | 4 +- ...Test.java => DoubleMaxAggregatorTest.java} | 6 +- ...Test.java => DoubleMinAggregatorTest.java} | 6 +- .../query/groupby/GroupByQueryRunnerTest.java | 8 +- .../timeseries/TimeseriesQueryRunnerTest.java | 8 +- .../query/topn/TopNQueryRunnerBenchmark.java | 8 +- .../druid/query/topn/TopNQueryRunnerTest.java | 36 ++-- .../io/druid/query/topn/TopNQueryTest.java | 8 +- .../druid/query/topn/TopNUnionQueryTest.java | 8 +- .../java/io/druid/segment/AppendTest.java | 24 +-- .../io/druid/segment/SchemalessTestFull.java | 20 +- .../druid/segment/SchemalessTestSimple.java | 12 +- .../antlr4/io/druid/sql/antlr4/DruidSQL.g4 | 8 +- 23 files changed, 503 insertions(+), 429 deletions(-) rename processing/src/main/java/io/druid/query/aggregation/{MaxAggregator.java => DoubleMaxAggregator.java} (90%) create mode 100644 processing/src/main/java/io/druid/query/aggregation/DoubleMaxAggregatorFactory.java rename processing/src/main/java/io/druid/query/aggregation/{MaxBufferAggregator.java => DoubleMaxBufferAggregator.java} (92%) rename processing/src/main/java/io/druid/query/aggregation/{MinAggregator.java => DoubleMinAggregator.java} (90%) create mode 100644 processing/src/main/java/io/druid/query/aggregation/DoubleMinAggregatorFactory.java rename processing/src/main/java/io/druid/query/aggregation/{MinBufferAggregator.java => DoubleMinBufferAggregator.java} (92%) rename processing/src/test/java/io/druid/query/aggregation/{MaxAggregatorTest.java => DoubleMaxAggregatorTest.java} (86%) rename processing/src/test/java/io/druid/query/aggregation/{MinAggregatorTest.java => DoubleMinAggregatorTest.java} (86%) diff --git a/extensions/histogram/src/test/java/io/druid/query/aggregation/histogram/ApproximateHistogramTopNQueryTest.java b/extensions/histogram/src/test/java/io/druid/query/aggregation/histogram/ApproximateHistogramTopNQueryTest.java index b4f5c212aa6..1d9a35da86e 100644 --- a/extensions/histogram/src/test/java/io/druid/query/aggregation/histogram/ApproximateHistogramTopNQueryTest.java +++ b/extensions/histogram/src/test/java/io/druid/query/aggregation/histogram/ApproximateHistogramTopNQueryTest.java @@ -27,8 +27,8 @@ import io.druid.query.QueryRunnerTestHelper; import io.druid.query.Result; import io.druid.query.TestQueryRunners; import io.druid.query.aggregation.AggregatorFactory; -import io.druid.query.aggregation.MaxAggregatorFactory; -import io.druid.query.aggregation.MinAggregatorFactory; +import io.druid.query.aggregation.DoubleMinAggregatorFactory; +import io.druid.query.aggregation.DoubleMaxAggregatorFactory; import io.druid.query.aggregation.PostAggregator; import io.druid.query.topn.TopNQuery; import io.druid.query.topn.TopNQueryBuilder; @@ -121,8 +121,8 @@ public class ApproximateHistogramTopNQueryTest Iterables.concat( QueryRunnerTestHelper.commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index"), + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index"), factory ) ) diff --git a/processing/src/main/java/io/druid/jackson/AggregatorsModule.java b/processing/src/main/java/io/druid/jackson/AggregatorsModule.java index 6fce1c3d437..e28c0cf71b6 100644 --- a/processing/src/main/java/io/druid/jackson/AggregatorsModule.java +++ b/processing/src/main/java/io/druid/jackson/AggregatorsModule.java @@ -23,6 +23,10 @@ import com.fasterxml.jackson.databind.module.SimpleModule; import com.google.common.hash.Hashing; import io.druid.query.aggregation.AggregatorFactory; import io.druid.query.aggregation.CountAggregatorFactory; +import io.druid.query.aggregation.DoubleMaxAggregatorFactory; +import io.druid.query.aggregation.DoubleMinAggregatorFactory; +import io.druid.query.aggregation.MinAggregatorFactory; +import io.druid.query.aggregation.MaxAggregatorFactory; import io.druid.query.aggregation.DoubleSumAggregatorFactory; import io.druid.query.aggregation.FilteredAggregatorFactory; import io.druid.query.aggregation.HistogramAggregatorFactory; @@ -30,8 +34,6 @@ import io.druid.query.aggregation.JavaScriptAggregatorFactory; import io.druid.query.aggregation.LongMaxAggregatorFactory; import io.druid.query.aggregation.LongMinAggregatorFactory; import io.druid.query.aggregation.LongSumAggregatorFactory; -import io.druid.query.aggregation.MaxAggregatorFactory; -import io.druid.query.aggregation.MinAggregatorFactory; import io.druid.query.aggregation.PostAggregator; import io.druid.query.aggregation.cardinality.CardinalityAggregatorFactory; import io.druid.query.aggregation.hyperloglog.HyperUniqueFinalizingPostAggregator; @@ -64,6 +66,10 @@ public class AggregatorsModule extends SimpleModule @JsonSubTypes.Type(name = "count", value = CountAggregatorFactory.class), @JsonSubTypes.Type(name = "longSum", value = LongSumAggregatorFactory.class), @JsonSubTypes.Type(name = "doubleSum", value = DoubleSumAggregatorFactory.class), + @JsonSubTypes.Type(name = "doubleMax", value = DoubleMaxAggregatorFactory.class), + @JsonSubTypes.Type(name = "doubleMin", value = DoubleMinAggregatorFactory.class), + //Note: max/min are exactly same as doubleMax/doubleMin, max/min are still here only + //to be backward compatible with 0.7.2 and before @JsonSubTypes.Type(name = "max", value = MaxAggregatorFactory.class), @JsonSubTypes.Type(name = "min", value = MinAggregatorFactory.class), @JsonSubTypes.Type(name = "longMax", value = LongMaxAggregatorFactory.class), diff --git a/processing/src/main/java/io/druid/query/aggregation/MaxAggregator.java b/processing/src/main/java/io/druid/query/aggregation/DoubleMaxAggregator.java similarity index 90% rename from processing/src/main/java/io/druid/query/aggregation/MaxAggregator.java rename to processing/src/main/java/io/druid/query/aggregation/DoubleMaxAggregator.java index 15faa0f8463..8735ac061e2 100644 --- a/processing/src/main/java/io/druid/query/aggregation/MaxAggregator.java +++ b/processing/src/main/java/io/druid/query/aggregation/DoubleMaxAggregator.java @@ -23,7 +23,7 @@ import java.util.Comparator; /** */ -public class MaxAggregator implements Aggregator +public class DoubleMaxAggregator implements Aggregator { static final Comparator COMPARATOR = DoubleSumAggregator.COMPARATOR; @@ -37,7 +37,7 @@ public class MaxAggregator implements Aggregator private double max; - public MaxAggregator(String name, FloatColumnSelector selector) + public DoubleMaxAggregator(String name, FloatColumnSelector selector) { this.name = name; this.selector = selector; @@ -84,7 +84,7 @@ public class MaxAggregator implements Aggregator @Override public Aggregator clone() { - return new MaxAggregator(name, selector); + return new DoubleMaxAggregator(name, selector); } @Override diff --git a/processing/src/main/java/io/druid/query/aggregation/DoubleMaxAggregatorFactory.java b/processing/src/main/java/io/druid/query/aggregation/DoubleMaxAggregatorFactory.java new file mode 100644 index 00000000000..74acf283b74 --- /dev/null +++ b/processing/src/main/java/io/druid/query/aggregation/DoubleMaxAggregatorFactory.java @@ -0,0 +1,181 @@ +/* + * Druid - a distributed column store. + * Copyright 2012 - 2015 Metamarkets Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.druid.query.aggregation; + +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 com.metamx.common.StringUtils; +import io.druid.segment.ColumnSelectorFactory; + +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +/** + */ +public class DoubleMaxAggregatorFactory implements AggregatorFactory +{ + private static final byte CACHE_TYPE_ID = 0x3; + + private final String fieldName; + private final String name; + + @JsonCreator + public DoubleMaxAggregatorFactory( + @JsonProperty("name") String name, + @JsonProperty("fieldName") final String fieldName + ) + { + Preconditions.checkNotNull(name, "Must have a valid, non-null aggregator name"); + Preconditions.checkNotNull(fieldName, "Must have a valid, non-null fieldName"); + + this.name = name; + this.fieldName = fieldName; + } + + @Override + public Aggregator factorize(ColumnSelectorFactory metricFactory) + { + return new DoubleMaxAggregator(name, metricFactory.makeFloatColumnSelector(fieldName)); + } + + @Override + public BufferAggregator factorizeBuffered(ColumnSelectorFactory metricFactory) + { + return new DoubleMaxBufferAggregator(metricFactory.makeFloatColumnSelector(fieldName)); + } + + @Override + public Comparator getComparator() + { + return DoubleMaxAggregator.COMPARATOR; + } + + @Override + public Object combine(Object lhs, Object rhs) + { + return DoubleMaxAggregator.combineValues(lhs, rhs); + } + + @Override + public AggregatorFactory getCombiningFactory() + { + return new DoubleMaxAggregatorFactory(name, name); + } + + @Override + public List getRequiredColumns() + { + return Arrays.asList(new DoubleMaxAggregatorFactory(fieldName, fieldName)); + } + + @Override + public Object deserialize(Object object) + { + // handle "NaN" / "Infinity" values serialized as strings in JSON + if (object instanceof String) { + return Double.parseDouble((String) object); + } + return object; + } + + @Override + public Object finalizeComputation(Object object) + { + return object; + } + + @JsonProperty + public String getFieldName() + { + return fieldName; + } + + @Override + @JsonProperty + public String getName() + { + return name; + } + + @Override + public List requiredFields() + { + return Arrays.asList(fieldName); + } + + @Override + public byte[] getCacheKey() + { + byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); + + return ByteBuffer.allocate(1 + fieldNameBytes.length).put(CACHE_TYPE_ID).put(fieldNameBytes).array(); + } + + @Override + public String getTypeName() + { + return "float"; + } + + @Override + public int getMaxIntermediateSize() + { + return Doubles.BYTES; + } + + @Override + public Object getAggregatorStartValue() + { + return Double.NEGATIVE_INFINITY; + } + + @Override + public String toString() + { + return "DoubleMaxAggregatorFactory{" + + "fieldName='" + fieldName + '\'' + + ", name='" + name + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + DoubleMaxAggregatorFactory that = (DoubleMaxAggregatorFactory) o; + + if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) return false; + if (name != null ? !name.equals(that.name) : that.name != null) return false; + + return true; + } + + @Override + public int hashCode() + { + int result = fieldName != null ? fieldName.hashCode() : 0; + result = 31 * result + (name != null ? name.hashCode() : 0); + return result; + } +} diff --git a/processing/src/main/java/io/druid/query/aggregation/MaxBufferAggregator.java b/processing/src/main/java/io/druid/query/aggregation/DoubleMaxBufferAggregator.java similarity index 92% rename from processing/src/main/java/io/druid/query/aggregation/MaxBufferAggregator.java rename to processing/src/main/java/io/druid/query/aggregation/DoubleMaxBufferAggregator.java index 22a13ff0e45..bd3fbe4e86e 100644 --- a/processing/src/main/java/io/druid/query/aggregation/MaxBufferAggregator.java +++ b/processing/src/main/java/io/druid/query/aggregation/DoubleMaxBufferAggregator.java @@ -23,11 +23,11 @@ import java.nio.ByteBuffer; /** */ -public class MaxBufferAggregator implements BufferAggregator +public class DoubleMaxBufferAggregator implements BufferAggregator { private final FloatColumnSelector selector; - public MaxBufferAggregator(FloatColumnSelector selector) + public DoubleMaxBufferAggregator(FloatColumnSelector selector) { this.selector = selector; } diff --git a/processing/src/main/java/io/druid/query/aggregation/MinAggregator.java b/processing/src/main/java/io/druid/query/aggregation/DoubleMinAggregator.java similarity index 90% rename from processing/src/main/java/io/druid/query/aggregation/MinAggregator.java rename to processing/src/main/java/io/druid/query/aggregation/DoubleMinAggregator.java index 30ef02240a6..c1e71b9eddc 100644 --- a/processing/src/main/java/io/druid/query/aggregation/MinAggregator.java +++ b/processing/src/main/java/io/druid/query/aggregation/DoubleMinAggregator.java @@ -23,7 +23,7 @@ import java.util.Comparator; /** */ -public class MinAggregator implements Aggregator +public class DoubleMinAggregator implements Aggregator { static final Comparator COMPARATOR = DoubleSumAggregator.COMPARATOR; @@ -37,7 +37,7 @@ public class MinAggregator implements Aggregator private double min; - public MinAggregator(String name, FloatColumnSelector selector) + public DoubleMinAggregator(String name, FloatColumnSelector selector) { this.name = name; this.selector = selector; @@ -84,7 +84,7 @@ public class MinAggregator implements Aggregator @Override public Aggregator clone() { - return new MinAggregator(name, selector); + return new DoubleMinAggregator(name, selector); } @Override diff --git a/processing/src/main/java/io/druid/query/aggregation/DoubleMinAggregatorFactory.java b/processing/src/main/java/io/druid/query/aggregation/DoubleMinAggregatorFactory.java new file mode 100644 index 00000000000..a246a4ccfc8 --- /dev/null +++ b/processing/src/main/java/io/druid/query/aggregation/DoubleMinAggregatorFactory.java @@ -0,0 +1,181 @@ +/* + * Druid - a distributed column store. + * Copyright 2012 - 2015 Metamarkets Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.druid.query.aggregation; + +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 com.metamx.common.StringUtils; +import io.druid.segment.ColumnSelectorFactory; + +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +/** + */ +public class DoubleMinAggregatorFactory implements AggregatorFactory +{ + private static final byte CACHE_TYPE_ID = 0x4; + + private final String fieldName; + private final String name; + + @JsonCreator + public DoubleMinAggregatorFactory( + @JsonProperty("name") String name, + @JsonProperty("fieldName") final String fieldName + ) + { + Preconditions.checkNotNull(name, "Must have a valid, non-null aggregator name"); + Preconditions.checkNotNull(fieldName, "Must have a valid, non-null fieldName"); + + this.name = name; + this.fieldName = fieldName; + } + + @Override + public Aggregator factorize(ColumnSelectorFactory metricFactory) + { + return new DoubleMinAggregator(name, metricFactory.makeFloatColumnSelector(fieldName)); + } + + @Override + public BufferAggregator factorizeBuffered(ColumnSelectorFactory metricFactory) + { + return new DoubleMinBufferAggregator(metricFactory.makeFloatColumnSelector(fieldName)); + } + + @Override + public Comparator getComparator() + { + return DoubleMinAggregator.COMPARATOR; + } + + @Override + public Object combine(Object lhs, Object rhs) + { + return DoubleMinAggregator.combineValues(lhs, rhs); + } + + @Override + public AggregatorFactory getCombiningFactory() + { + return new DoubleMinAggregatorFactory(name, name); + } + + @Override + public List getRequiredColumns() + { + return Arrays.asList(new DoubleMinAggregatorFactory(fieldName, fieldName)); + } + + @Override + public Object deserialize(Object object) + { + // handle "NaN" / "Infinity" values serialized as strings in JSON + if (object instanceof String) { + return Double.parseDouble((String) object); + } + return object; + } + + @Override + public Object finalizeComputation(Object object) + { + return object; + } + + @JsonProperty + public String getFieldName() + { + return fieldName; + } + + @Override + @JsonProperty + public String getName() + { + return name; + } + + @Override + public List requiredFields() + { + return Arrays.asList(fieldName); + } + + @Override + public byte[] getCacheKey() + { + byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); + + return ByteBuffer.allocate(1 + fieldNameBytes.length).put(CACHE_TYPE_ID).put(fieldNameBytes).array(); + } + + @Override + public String getTypeName() + { + return "float"; + } + + @Override + public int getMaxIntermediateSize() + { + return Doubles.BYTES; + } + + @Override + public Object getAggregatorStartValue() + { + return Double.POSITIVE_INFINITY; + } + + @Override + public String toString() + { + return "DoubleMinAggregatorFactory{" + + "fieldName='" + fieldName + '\'' + + ", name='" + name + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + DoubleMinAggregatorFactory that = (DoubleMinAggregatorFactory) o; + + if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) return false; + if (name != null ? !name.equals(that.name) : that.name != null) return false; + + return true; + } + + @Override + public int hashCode() + { + int result = fieldName != null ? fieldName.hashCode() : 0; + result = 31 * result + (name != null ? name.hashCode() : 0); + return result; + } +} diff --git a/processing/src/main/java/io/druid/query/aggregation/MinBufferAggregator.java b/processing/src/main/java/io/druid/query/aggregation/DoubleMinBufferAggregator.java similarity index 92% rename from processing/src/main/java/io/druid/query/aggregation/MinBufferAggregator.java rename to processing/src/main/java/io/druid/query/aggregation/DoubleMinBufferAggregator.java index d70434ba29d..18e1cb64e59 100644 --- a/processing/src/main/java/io/druid/query/aggregation/MinBufferAggregator.java +++ b/processing/src/main/java/io/druid/query/aggregation/DoubleMinBufferAggregator.java @@ -23,11 +23,11 @@ import java.nio.ByteBuffer; /** */ -public class MinBufferAggregator implements BufferAggregator +public class DoubleMinBufferAggregator implements BufferAggregator { private final FloatColumnSelector selector; - public MinBufferAggregator(FloatColumnSelector selector) + public DoubleMinBufferAggregator(FloatColumnSelector selector) { this.selector = selector; } diff --git a/processing/src/main/java/io/druid/query/aggregation/MaxAggregatorFactory.java b/processing/src/main/java/io/druid/query/aggregation/MaxAggregatorFactory.java index e02fc04fc02..00fc80ef020 100644 --- a/processing/src/main/java/io/druid/query/aggregation/MaxAggregatorFactory.java +++ b/processing/src/main/java/io/druid/query/aggregation/MaxAggregatorFactory.java @@ -1,181 +1,36 @@ /* - * Druid - a distributed column store. - * Copyright 2012 - 2015 Metamarkets Group Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Licensed to Metamarkets Group Inc. (Metamarkets) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. Metamarkets licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ package io.druid.query.aggregation; -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 com.metamx.common.StringUtils; -import io.druid.segment.ColumnSelectorFactory; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; /** + * This class can be removed when we dont need "max" aggregator backward compatibility */ -public class MaxAggregatorFactory implements AggregatorFactory +public class MaxAggregatorFactory extends DoubleMaxAggregatorFactory { - private static final byte CACHE_TYPE_ID = 0x3; - - private final String fieldName; - private final String name; - - @JsonCreator public MaxAggregatorFactory( @JsonProperty("name") String name, - @JsonProperty("fieldName") final String fieldName + @JsonProperty("fieldName") String fieldName ) { - Preconditions.checkNotNull(name, "Must have a valid, non-null aggregator name"); - Preconditions.checkNotNull(fieldName, "Must have a valid, non-null fieldName"); - - this.name = name; - this.fieldName = fieldName; - } - - @Override - public Aggregator factorize(ColumnSelectorFactory metricFactory) - { - return new MaxAggregator(name, metricFactory.makeFloatColumnSelector(fieldName)); - } - - @Override - public BufferAggregator factorizeBuffered(ColumnSelectorFactory metricFactory) - { - return new MaxBufferAggregator(metricFactory.makeFloatColumnSelector(fieldName)); - } - - @Override - public Comparator getComparator() - { - return MaxAggregator.COMPARATOR; - } - - @Override - public Object combine(Object lhs, Object rhs) - { - return MaxAggregator.combineValues(lhs, rhs); - } - - @Override - public AggregatorFactory getCombiningFactory() - { - return new MaxAggregatorFactory(name, name); - } - - @Override - public List getRequiredColumns() - { - return Arrays.asList(new MaxAggregatorFactory(fieldName, fieldName)); - } - - @Override - public Object deserialize(Object object) - { - // handle "NaN" / "Infinity" values serialized as strings in JSON - if (object instanceof String) { - return Double.parseDouble((String) object); - } - return object; - } - - @Override - public Object finalizeComputation(Object object) - { - return object; - } - - @JsonProperty - public String getFieldName() - { - return fieldName; - } - - @Override - @JsonProperty - public String getName() - { - return name; - } - - @Override - public List requiredFields() - { - return Arrays.asList(fieldName); - } - - @Override - public byte[] getCacheKey() - { - byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); - - return ByteBuffer.allocate(1 + fieldNameBytes.length).put(CACHE_TYPE_ID).put(fieldNameBytes).array(); - } - - @Override - public String getTypeName() - { - return "float"; - } - - @Override - public int getMaxIntermediateSize() - { - return Doubles.BYTES; - } - - @Override - public Object getAggregatorStartValue() - { - return Double.NEGATIVE_INFINITY; - } - - @Override - public String toString() - { - return "MaxAggregatorFactory{" + - "fieldName='" + fieldName + '\'' + - ", name='" + name + '\'' + - '}'; - } - - @Override - public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MaxAggregatorFactory that = (MaxAggregatorFactory) o; - - if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - - return true; - } - - @Override - public int hashCode() - { - int result = fieldName != null ? fieldName.hashCode() : 0; - result = 31 * result + (name != null ? name.hashCode() : 0); - return result; + super(name, fieldName); } } diff --git a/processing/src/main/java/io/druid/query/aggregation/MinAggregatorFactory.java b/processing/src/main/java/io/druid/query/aggregation/MinAggregatorFactory.java index 53239b591e3..b10f800da89 100644 --- a/processing/src/main/java/io/druid/query/aggregation/MinAggregatorFactory.java +++ b/processing/src/main/java/io/druid/query/aggregation/MinAggregatorFactory.java @@ -1,181 +1,36 @@ /* - * Druid - a distributed column store. - * Copyright 2012 - 2015 Metamarkets Group Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Licensed to Metamarkets Group Inc. (Metamarkets) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. Metamarkets licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ package io.druid.query.aggregation; -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 com.metamx.common.StringUtils; -import io.druid.segment.ColumnSelectorFactory; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; /** - */ -public class MinAggregatorFactory implements AggregatorFactory + * This class can be removed when we dont need "min" aggregator backward compatibility + */ +public class MinAggregatorFactory extends DoubleMinAggregatorFactory { - private static final byte CACHE_TYPE_ID = 0x4; - - private final String fieldName; - private final String name; - - @JsonCreator public MinAggregatorFactory( @JsonProperty("name") String name, - @JsonProperty("fieldName") final String fieldName + @JsonProperty("fieldName") String fieldName ) { - Preconditions.checkNotNull(name, "Must have a valid, non-null aggregator name"); - Preconditions.checkNotNull(fieldName, "Must have a valid, non-null fieldName"); - - this.name = name; - this.fieldName = fieldName; - } - - @Override - public Aggregator factorize(ColumnSelectorFactory metricFactory) - { - return new MinAggregator(name, metricFactory.makeFloatColumnSelector(fieldName)); - } - - @Override - public BufferAggregator factorizeBuffered(ColumnSelectorFactory metricFactory) - { - return new MinBufferAggregator(metricFactory.makeFloatColumnSelector(fieldName)); - } - - @Override - public Comparator getComparator() - { - return MinAggregator.COMPARATOR; - } - - @Override - public Object combine(Object lhs, Object rhs) - { - return MinAggregator.combineValues(lhs, rhs); - } - - @Override - public AggregatorFactory getCombiningFactory() - { - return new MinAggregatorFactory(name, name); - } - - @Override - public List getRequiredColumns() - { - return Arrays.asList(new MinAggregatorFactory(fieldName, fieldName)); - } - - @Override - public Object deserialize(Object object) - { - // handle "NaN" / "Infinity" values serialized as strings in JSON - if (object instanceof String) { - return Double.parseDouble((String) object); - } - return object; - } - - @Override - public Object finalizeComputation(Object object) - { - return object; - } - - @JsonProperty - public String getFieldName() - { - return fieldName; - } - - @Override - @JsonProperty - public String getName() - { - return name; - } - - @Override - public List requiredFields() - { - return Arrays.asList(fieldName); - } - - @Override - public byte[] getCacheKey() - { - byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); - - return ByteBuffer.allocate(1 + fieldNameBytes.length).put(CACHE_TYPE_ID).put(fieldNameBytes).array(); - } - - @Override - public String getTypeName() - { - return "float"; - } - - @Override - public int getMaxIntermediateSize() - { - return Doubles.BYTES; - } - - @Override - public Object getAggregatorStartValue() - { - return Double.POSITIVE_INFINITY; - } - - @Override - public String toString() - { - return "MinAggregatorFactory{" + - "fieldName='" + fieldName + '\'' + - ", name='" + name + '\'' + - '}'; - } - - @Override - public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MinAggregatorFactory that = (MinAggregatorFactory) o; - - if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - - return true; - } - - @Override - public int hashCode() - { - int result = fieldName != null ? fieldName.hashCode() : 0; - result = 31 * result + (name != null ? name.hashCode() : 0); - return result; + super(name, fieldName); } } diff --git a/processing/src/test/java/io/druid/query/aggregation/AggregatorUtilTest.java b/processing/src/test/java/io/druid/query/aggregation/AggregatorUtilTest.java index e779193789e..93a0c63e1c2 100644 --- a/processing/src/test/java/io/druid/query/aggregation/AggregatorUtilTest.java +++ b/processing/src/test/java/io/druid/query/aggregation/AggregatorUtilTest.java @@ -114,8 +114,8 @@ public class AggregatorUtilTest Iterables.concat( QueryRunnerTestHelper.commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ); diff --git a/processing/src/test/java/io/druid/query/aggregation/MaxAggregatorTest.java b/processing/src/test/java/io/druid/query/aggregation/DoubleMaxAggregatorTest.java similarity index 86% rename from processing/src/test/java/io/druid/query/aggregation/MaxAggregatorTest.java rename to processing/src/test/java/io/druid/query/aggregation/DoubleMaxAggregatorTest.java index 093bf387eb5..b2dc4406957 100644 --- a/processing/src/test/java/io/druid/query/aggregation/MaxAggregatorTest.java +++ b/processing/src/test/java/io/druid/query/aggregation/DoubleMaxAggregatorTest.java @@ -22,9 +22,9 @@ import org.junit.Test; /** */ -public class MaxAggregatorTest +public class DoubleMaxAggregatorTest { - private void aggregate(TestFloatColumnSelector selector, MaxAggregator agg) + private void aggregate(TestFloatColumnSelector selector, DoubleMaxAggregator agg) { agg.aggregate(); selector.increment(); @@ -35,7 +35,7 @@ public class MaxAggregatorTest { final float[] values = {0.15f, 0.27f, 0.0f, 0.93f}; final TestFloatColumnSelector selector = new TestFloatColumnSelector(values); - MaxAggregator agg = new MaxAggregator("billy", selector); + DoubleMaxAggregator agg = new DoubleMaxAggregator("billy", selector); Assert.assertEquals("billy", agg.getName()); diff --git a/processing/src/test/java/io/druid/query/aggregation/MinAggregatorTest.java b/processing/src/test/java/io/druid/query/aggregation/DoubleMinAggregatorTest.java similarity index 86% rename from processing/src/test/java/io/druid/query/aggregation/MinAggregatorTest.java rename to processing/src/test/java/io/druid/query/aggregation/DoubleMinAggregatorTest.java index 74e1f74cab4..4f74baf8c5d 100644 --- a/processing/src/test/java/io/druid/query/aggregation/MinAggregatorTest.java +++ b/processing/src/test/java/io/druid/query/aggregation/DoubleMinAggregatorTest.java @@ -22,9 +22,9 @@ import org.junit.Test; /** */ -public class MinAggregatorTest +public class DoubleMinAggregatorTest { - private void aggregate(TestFloatColumnSelector selector, MinAggregator agg) + private void aggregate(TestFloatColumnSelector selector, DoubleMinAggregator agg) { agg.aggregate(); selector.increment(); @@ -35,7 +35,7 @@ public class MinAggregatorTest { final float[] values = {0.15f, 0.27f, 0.0f, 0.93f}; final TestFloatColumnSelector selector = new TestFloatColumnSelector(values); - MinAggregator agg = new MinAggregator("billy", selector); + DoubleMinAggregator agg = new DoubleMinAggregator("billy", selector); Assert.assertEquals("billy", agg.getName()); diff --git a/processing/src/test/java/io/druid/query/groupby/GroupByQueryRunnerTest.java b/processing/src/test/java/io/druid/query/groupby/GroupByQueryRunnerTest.java index 70dbaa273d0..aae346c48cb 100644 --- a/processing/src/test/java/io/druid/query/groupby/GroupByQueryRunnerTest.java +++ b/processing/src/test/java/io/druid/query/groupby/GroupByQueryRunnerTest.java @@ -44,10 +44,10 @@ import io.druid.query.QueryToolChest; import io.druid.query.Result; import io.druid.query.TestQueryRunners; import io.druid.query.aggregation.AggregatorFactory; +import io.druid.query.aggregation.DoubleMaxAggregatorFactory; import io.druid.query.aggregation.DoubleSumAggregatorFactory; import io.druid.query.aggregation.JavaScriptAggregatorFactory; import io.druid.query.aggregation.LongSumAggregatorFactory; -import io.druid.query.aggregation.MaxAggregatorFactory; import io.druid.query.aggregation.PostAggregator; import io.druid.query.aggregation.hyperloglog.HyperUniqueFinalizingPostAggregator; import io.druid.query.aggregation.hyperloglog.HyperUniquesAggregatorFactory; @@ -1964,7 +1964,7 @@ public class GroupByQueryRunnerTest .setQuerySegmentSpec(QueryRunnerTestHelper.firstToThird) .setAggregatorSpecs( Arrays.asList( - new MaxAggregatorFactory("idx", "idx") + new DoubleMaxAggregatorFactory("idx", "idx") ) ) .setGranularity(QueryRunnerTestHelper.dayGran) @@ -2002,7 +2002,7 @@ public class GroupByQueryRunnerTest .setQuerySegmentSpec(QueryRunnerTestHelper.secondOnly) .setAggregatorSpecs( Arrays.asList( - new MaxAggregatorFactory("idx", "idx") + new DoubleMaxAggregatorFactory("idx", "idx") ) ) .setGranularity(QueryRunnerTestHelper.dayGran) @@ -2039,7 +2039,7 @@ public class GroupByQueryRunnerTest .setQuerySegmentSpec(QueryRunnerTestHelper.firstToThird) .setAggregatorSpecs( Arrays.asList( - new MaxAggregatorFactory("idx", "idx") + new DoubleMaxAggregatorFactory("idx", "idx") ) ) .setGranularity(QueryRunnerTestHelper.dayGran) diff --git a/processing/src/test/java/io/druid/query/timeseries/TimeseriesQueryRunnerTest.java b/processing/src/test/java/io/druid/query/timeseries/TimeseriesQueryRunnerTest.java index 023476c155d..6d6e148f4fd 100644 --- a/processing/src/test/java/io/druid/query/timeseries/TimeseriesQueryRunnerTest.java +++ b/processing/src/test/java/io/druid/query/timeseries/TimeseriesQueryRunnerTest.java @@ -32,8 +32,8 @@ import io.druid.query.aggregation.AggregatorFactory; import io.druid.query.aggregation.CountAggregatorFactory; import io.druid.query.aggregation.FilteredAggregatorFactory; import io.druid.query.aggregation.LongSumAggregatorFactory; -import io.druid.query.aggregation.MaxAggregatorFactory; -import io.druid.query.aggregation.MinAggregatorFactory; +import io.druid.query.aggregation.DoubleMaxAggregatorFactory; +import io.druid.query.aggregation.DoubleMinAggregatorFactory; import io.druid.query.aggregation.PostAggregator; import io.druid.query.filter.AndDimFilter; import io.druid.query.filter.DimFilter; @@ -165,8 +165,8 @@ public class TimeseriesQueryRunnerTest .intervals(QueryRunnerTestHelper.fullOnInterval) .aggregators( Arrays.asList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) .build(); diff --git a/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerBenchmark.java b/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerBenchmark.java index 93ebb9da6ed..d9697d3b6dd 100644 --- a/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerBenchmark.java +++ b/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerBenchmark.java @@ -28,8 +28,8 @@ import io.druid.query.QueryRunner; import io.druid.query.QueryRunnerFactory; import io.druid.query.QueryRunnerTestHelper; import io.druid.query.aggregation.AggregatorFactory; -import io.druid.query.aggregation.MaxAggregatorFactory; -import io.druid.query.aggregation.MinAggregatorFactory; +import io.druid.query.aggregation.DoubleMaxAggregatorFactory; +import io.druid.query.aggregation.DoubleMinAggregatorFactory; import io.druid.query.aggregation.PostAggregator; import io.druid.segment.IncrementalIndexSegment; import io.druid.segment.QueryableIndexSegment; @@ -71,8 +71,8 @@ public class TopNQueryRunnerBenchmark extends AbstractBenchmark Iterables.concat( QueryRunnerTestHelper.commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) diff --git a/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java b/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java index c88301158e5..68a14aa8fee 100644 --- a/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java +++ b/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java @@ -35,9 +35,8 @@ import io.druid.query.QueryRunnerTestHelper; import io.druid.query.Result; import io.druid.query.TestQueryRunners; import io.druid.query.aggregation.AggregatorFactory; -import io.druid.query.aggregation.LongSumAggregatorFactory; -import io.druid.query.aggregation.MaxAggregatorFactory; -import io.druid.query.aggregation.MinAggregatorFactory; +import io.druid.query.aggregation.DoubleMaxAggregatorFactory; +import io.druid.query.aggregation.DoubleMinAggregatorFactory; import io.druid.query.aggregation.PostAggregator; import io.druid.query.aggregation.cardinality.CardinalityAggregatorFactory; import io.druid.query.aggregation.hyperloglog.HyperUniquesAggregatorFactory; @@ -54,7 +53,6 @@ import io.druid.segment.TestHelper; import io.druid.segment.column.Column; import org.joda.time.DateTime; import org.joda.time.Interval; -import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -66,11 +64,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; /** */ @@ -139,8 +135,8 @@ public class TopNQueryRunnerTest Iterables.concat( QueryRunnerTestHelper.commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -203,8 +199,8 @@ public class TopNQueryRunnerTest Iterables.concat( QueryRunnerTestHelper.commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -268,8 +264,8 @@ public class TopNQueryRunnerTest Iterables.concat( QueryRunnerTestHelper.commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -2069,8 +2065,8 @@ public class TopNQueryRunnerTest Iterables.concat( QueryRunnerTestHelper.commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -2154,8 +2150,8 @@ public class TopNQueryRunnerTest Iterables.concat( QueryRunnerTestHelper.commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -2347,8 +2343,8 @@ public class TopNQueryRunnerTest Iterables.concat( QueryRunnerTestHelper.commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -2396,8 +2392,8 @@ public class TopNQueryRunnerTest Iterables.concat( QueryRunnerTestHelper.commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) diff --git a/processing/src/test/java/io/druid/query/topn/TopNQueryTest.java b/processing/src/test/java/io/druid/query/topn/TopNQueryTest.java index 9cfa6be0aa3..dc073ea7381 100644 --- a/processing/src/test/java/io/druid/query/topn/TopNQueryTest.java +++ b/processing/src/test/java/io/druid/query/topn/TopNQueryTest.java @@ -23,8 +23,8 @@ import com.google.common.collect.Lists; import io.druid.jackson.DefaultObjectMapper; import io.druid.query.Query; import io.druid.query.aggregation.AggregatorFactory; -import io.druid.query.aggregation.MaxAggregatorFactory; -import io.druid.query.aggregation.MinAggregatorFactory; +import io.druid.query.aggregation.DoubleMaxAggregatorFactory; +import io.druid.query.aggregation.DoubleMinAggregatorFactory; import io.druid.query.aggregation.PostAggregator; import org.junit.Assert; import org.junit.Test; @@ -59,8 +59,8 @@ public class TopNQueryTest Iterables.concat( commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) diff --git a/processing/src/test/java/io/druid/query/topn/TopNUnionQueryTest.java b/processing/src/test/java/io/druid/query/topn/TopNUnionQueryTest.java index 7dcd16313b4..4daa9efd119 100644 --- a/processing/src/test/java/io/druid/query/topn/TopNUnionQueryTest.java +++ b/processing/src/test/java/io/druid/query/topn/TopNUnionQueryTest.java @@ -27,8 +27,8 @@ import io.druid.query.QueryRunnerTestHelper; import io.druid.query.Result; import io.druid.query.TestQueryRunners; import io.druid.query.aggregation.AggregatorFactory; -import io.druid.query.aggregation.MaxAggregatorFactory; -import io.druid.query.aggregation.MinAggregatorFactory; +import io.druid.query.aggregation.DoubleMinAggregatorFactory; +import io.druid.query.aggregation.DoubleMaxAggregatorFactory; import io.druid.query.aggregation.PostAggregator; import io.druid.segment.TestHelper; import org.joda.time.DateTime; @@ -108,8 +108,8 @@ public class TopNUnionQueryTest Iterables.concat( QueryRunnerTestHelper.commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) diff --git a/processing/src/test/java/io/druid/segment/AppendTest.java b/processing/src/test/java/io/druid/segment/AppendTest.java index f0387df2702..d604b3fcd94 100644 --- a/processing/src/test/java/io/druid/segment/AppendTest.java +++ b/processing/src/test/java/io/druid/segment/AppendTest.java @@ -28,9 +28,9 @@ import io.druid.query.Result; import io.druid.query.TestQueryRunners; import io.druid.query.aggregation.AggregatorFactory; import io.druid.query.aggregation.CountAggregatorFactory; +import io.druid.query.aggregation.DoubleMaxAggregatorFactory; import io.druid.query.aggregation.DoubleSumAggregatorFactory; -import io.druid.query.aggregation.MaxAggregatorFactory; -import io.druid.query.aggregation.MinAggregatorFactory; +import io.druid.query.aggregation.DoubleMinAggregatorFactory; import io.druid.query.aggregation.PostAggregator; import io.druid.query.aggregation.hyperloglog.HyperUniquesAggregatorFactory; import io.druid.query.aggregation.post.ArithmeticPostAggregator; @@ -563,8 +563,8 @@ public class AppendTest Iterables.concat( commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -587,8 +587,8 @@ public class AppendTest Iterables.concat( commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -623,8 +623,8 @@ public class AppendTest Iterables.concat( commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -647,8 +647,8 @@ public class AppendTest Iterables.concat( commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -686,8 +686,8 @@ public class AppendTest Iterables.concat( commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) diff --git a/processing/src/test/java/io/druid/segment/SchemalessTestFull.java b/processing/src/test/java/io/druid/segment/SchemalessTestFull.java index fac3b7c5bdb..70a38ddbcab 100644 --- a/processing/src/test/java/io/druid/segment/SchemalessTestFull.java +++ b/processing/src/test/java/io/druid/segment/SchemalessTestFull.java @@ -29,9 +29,9 @@ import io.druid.query.Result; import io.druid.query.TestQueryRunners; import io.druid.query.aggregation.AggregatorFactory; import io.druid.query.aggregation.CountAggregatorFactory; +import io.druid.query.aggregation.DoubleMinAggregatorFactory; import io.druid.query.aggregation.DoubleSumAggregatorFactory; -import io.druid.query.aggregation.MaxAggregatorFactory; -import io.druid.query.aggregation.MinAggregatorFactory; +import io.druid.query.aggregation.DoubleMaxAggregatorFactory; import io.druid.query.aggregation.PostAggregator; import io.druid.query.aggregation.hyperloglog.HyperUniquesAggregatorFactory; import io.druid.query.aggregation.post.ArithmeticPostAggregator; @@ -1438,8 +1438,8 @@ public class SchemalessTestFull Iterables.concat( commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -1472,8 +1472,8 @@ public class SchemalessTestFull Iterables.concat( commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -1505,8 +1505,8 @@ public class SchemalessTestFull Iterables.concat( commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -1539,8 +1539,8 @@ public class SchemalessTestFull Iterables.concat( commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) diff --git a/processing/src/test/java/io/druid/segment/SchemalessTestSimple.java b/processing/src/test/java/io/druid/segment/SchemalessTestSimple.java index 43c1519344f..77fb21fa1d9 100644 --- a/processing/src/test/java/io/druid/segment/SchemalessTestSimple.java +++ b/processing/src/test/java/io/druid/segment/SchemalessTestSimple.java @@ -27,9 +27,9 @@ import io.druid.query.Result; import io.druid.query.TestQueryRunners; import io.druid.query.aggregation.AggregatorFactory; import io.druid.query.aggregation.CountAggregatorFactory; +import io.druid.query.aggregation.DoubleMaxAggregatorFactory; +import io.druid.query.aggregation.DoubleMinAggregatorFactory; import io.druid.query.aggregation.DoubleSumAggregatorFactory; -import io.druid.query.aggregation.MaxAggregatorFactory; -import io.druid.query.aggregation.MinAggregatorFactory; import io.druid.query.aggregation.PostAggregator; import io.druid.query.aggregation.hyperloglog.HyperUniquesAggregatorFactory; import io.druid.query.aggregation.post.ArithmeticPostAggregator; @@ -138,8 +138,8 @@ public class SchemalessTestSimple Iterables.concat( commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) @@ -184,8 +184,8 @@ public class SchemalessTestSimple Iterables.concat( commonAggregators, Lists.newArrayList( - new MaxAggregatorFactory("maxIndex", "index"), - new MinAggregatorFactory("minIndex", "index") + new DoubleMaxAggregatorFactory("maxIndex", "index"), + new DoubleMinAggregatorFactory("minIndex", "index") ) ) ) diff --git a/server/src/main/antlr4/io/druid/sql/antlr4/DruidSQL.g4 b/server/src/main/antlr4/io/druid/sql/antlr4/DruidSQL.g4 index 1cafead058d..f86a252fdb6 100644 --- a/server/src/main/antlr4/io/druid/sql/antlr4/DruidSQL.g4 +++ b/server/src/main/antlr4/io/druid/sql/antlr4/DruidSQL.g4 @@ -8,8 +8,8 @@ import io.druid.granularity.QueryGranularity; import io.druid.query.aggregation.AggregatorFactory; import io.druid.query.aggregation.CountAggregatorFactory; import io.druid.query.aggregation.DoubleSumAggregatorFactory; -import io.druid.query.aggregation.MaxAggregatorFactory; -import io.druid.query.aggregation.MinAggregatorFactory; +import io.druid.query.aggregation.DoubleMaxAggregatorFactory; +import io.druid.query.aggregation.DoubleMinAggregatorFactory; import io.druid.query.aggregation.PostAggregator; import io.druid.query.aggregation.post.ArithmeticPostAggregator; import io.druid.query.aggregation.post.ConstantPostAggregator; @@ -70,8 +70,8 @@ import java.util.Map; AggregatorFactory evalAgg(String name, int fn) { switch (fn) { case SUM: return new DoubleSumAggregatorFactory("sum("+name+")", name); - case MIN: return new MinAggregatorFactory("min("+name+")", name); - case MAX: return new MaxAggregatorFactory("max("+name+")", name); + case MIN: return new DoubleMinAggregatorFactory("min("+name+")", name); + case MAX: return new DoubleMaxAggregatorFactory("max("+name+")", name); case COUNT: return new CountAggregatorFactory(name); } throw new IllegalArgumentException("Unknown function [" + fn + "]");