Update SketchAggregator.java for removing duplicated parentheses (#11021)

* Update SketchAggregator.java

* Add test for sketches aggregator update unoin with double
This commit is contained in:
Makdon 2021-04-10 08:11:25 +08:00 committed by GitHub
parent e7b2ecd0fd
commit d939420f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -112,7 +112,7 @@ public class SketchAggregator implements Aggregator
} else if (update instanceof byte[]) {
union.update((byte[]) update);
} else if (update instanceof Double) {
union.update(((Double) update));
union.update((Double) update);
} else if (update instanceof Integer || update instanceof Long) {
union.update(((Number) update).longValue());
} else if (update instanceof int[]) {

View File

@ -529,6 +529,21 @@ public class SketchAggregationTest
Assert.assertEquals(2, ((SketchHolder) agg.get()).getSketch().getEstimate(), 0);
}
@Test
public void testUpdateUnionWithDouble()
{
Double[] columnValues = new Double[]{2.0};
final TestObjectColumnSelector selector = new TestObjectColumnSelector(columnValues);
final Aggregator agg = new SketchAggregator(selector, 4096);
agg.aggregate();
Assert.assertFalse(agg.isNull());
Assert.assertNotNull(agg.get());
Assert.assertTrue(agg.get() instanceof SketchHolder);
Assert.assertEquals(1, ((SketchHolder) agg.get()).getEstimate(), 0);
Assert.assertNotNull(((SketchHolder) agg.get()).getSketch());
Assert.assertEquals(1, ((SketchHolder) agg.get()).getSketch().getEstimate(), 0);
}
private void assertPostAggregatorSerde(PostAggregator agg) throws Exception
{
Assert.assertEquals(