Fix equals for ArrayOfDoublesSketchAggregatorFactory (#8326)

This commit is contained in:
Jihoon Son 2019-08-16 14:47:37 -07:00 committed by GitHub
parent 399b3ad7de
commit b654096194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -323,7 +323,7 @@ public class ArrayOfDoublesSketchAggregatorFactory extends AggregatorFactory
if (!Objects.equals(metricColumns, that.metricColumns)) { if (!Objects.equals(metricColumns, that.metricColumns)) {
return false; return false;
} }
return numberOfValues != that.numberOfValues; return numberOfValues == that.numberOfValues;
} }
@Override @Override

View File

@ -19,6 +19,7 @@
package org.apache.druid.query.aggregation.datasketches.tuple; package org.apache.druid.query.aggregation.datasketches.tuple;
import com.google.common.collect.ImmutableList;
import com.yahoo.sketches.tuple.ArrayOfDoublesSketch; import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;
import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketch; import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketch;
import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder; import com.yahoo.sketches.tuple.ArrayOfDoublesUpdatableSketchBuilder;
@ -55,4 +56,24 @@ public class ArrayOfDoublesSketchAggregatorFactoryTest
Assert.assertEquals(3, combiner.getObject().getEstimate(), 0); Assert.assertEquals(3, combiner.getObject().getEstimate(), 0);
} }
@Test
public void testEquals()
{
final ArrayOfDoublesSketchAggregatorFactory a1 = new ArrayOfDoublesSketchAggregatorFactory(
"name",
"field",
1,
ImmutableList.of("met"),
1
);
final ArrayOfDoublesSketchAggregatorFactory a2 = new ArrayOfDoublesSketchAggregatorFactory(
"name",
"field",
1,
ImmutableList.of("met"),
1
);
Assert.assertEquals(a1, a2);
}
} }