mirror of https://github.com/apache/druid.git
Fix serde for ArrayOfDoublesSketchConstantPostAggregator. (#16550)
* Fix serde for ArrayOfDoublesSketchConstantPostAggregator. The version originally added in #13819 was missing an annotation for the "value" property. Fixes #16539. Line endings for ArrayOfDoublesSketchConstantPostAggregator.java are changed from \r\n to \n. Adds a serde test, and improves various other datasketches post-aggregator serde tests to deserialize into PostAggregator. This verifies that the type information is set up correctly. * Fix excessive imports. * Fix equals, hashCode.
This commit is contained in:
parent
b837ce565b
commit
2534a42539
|
@ -92,6 +92,7 @@ public class ArrayOfDoublesSketchConstantPostAggregator extends ArrayOfDoublesSk
|
||||||
return "ArrayOfDoublesSketchConstantPostAggregator{name='" + this.getName() + "', value='" + value + "'}";
|
return "ArrayOfDoublesSketchConstantPostAggregator{name='" + this.getName() + "', value='" + value + "'}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonProperty("value")
|
||||||
private String getRawSketchValue()
|
private String getRawSketchValue()
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
|
@ -106,18 +107,17 @@ public class ArrayOfDoublesSketchConstantPostAggregator extends ArrayOfDoublesSk
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ArrayOfDoublesSketchConstantPostAggregator that = (ArrayOfDoublesSketchConstantPostAggregator) o;
|
if (!super.equals(o)) {
|
||||||
if (!(Objects.equals(this.getName(), that.getName()) && Objects.equals(this.value, that.value)
|
|
||||||
&& Objects.equals(this.getSketchValue(), that.getSketchValue()))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
ArrayOfDoublesSketchConstantPostAggregator that = (ArrayOfDoublesSketchConstantPostAggregator) o;
|
||||||
|
return Objects.equals(value, that.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
return Objects.hash(super.hashCode(), value, sketchValue);
|
return Objects.hash(super.hashCode(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -45,9 +45,10 @@ public class HllSketchToEstimatePostAggregatorTest
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
HllSketchToEstimatePostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new HllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
HllSketchToEstimatePostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -38,9 +38,10 @@ public class HllSketchToEstimateWithBoundsPostAggregatorTest
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
HllSketchToEstimateWithBoundsPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new HllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
HllSketchToEstimateWithBoundsPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -37,9 +37,10 @@ public class HllSketchToStringPostAggregatorTest
|
||||||
new FieldAccessPostAggregator("field1", "sketch")
|
new FieldAccessPostAggregator("field1", "sketch")
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
HllSketchToStringPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new HllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
HllSketchToStringPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -45,9 +45,10 @@ public class HllSketchUnionPostAggregatorTest
|
||||||
TgtHllType.HLL_8.name()
|
TgtHllType.HLL_8.name()
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
HllSketchUnionPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new HllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
HllSketchUnionPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -55,9 +55,10 @@ public class KllDoublesSketchToCDFPostAggregatorTest
|
||||||
new double[]{0.25, 0.75}
|
new double[]{0.25, 0.75}
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
KllDoublesSketchToCDFPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new KllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
KllDoublesSketchToCDFPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -56,9 +56,10 @@ public class KllDoublesSketchToHistogramPostAggregatorTest
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
KllDoublesSketchToHistogramPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new KllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
KllDoublesSketchToHistogramPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -38,9 +38,10 @@ public class KllDoublesSketchToQuantilePostAggregatorTest
|
||||||
0.5
|
0.5
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
KllDoublesSketchToQuantilePostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new KllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
KllDoublesSketchToQuantilePostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -55,9 +55,10 @@ public class KllDoublesSketchToQuantilesPostAggregatorTest
|
||||||
new double[] {0, 0.5, 1}
|
new double[] {0, 0.5, 1}
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
KllDoublesSketchToQuantilesPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new KllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
KllDoublesSketchToQuantilesPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -49,9 +49,10 @@ public class KllDoublesSketchToRankPostAggregatorTest
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
KllDoublesSketchToRankPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new KllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
KllDoublesSketchToRankPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -43,9 +43,10 @@ public class KllDoublesSketchToStringPostAggregatorTest
|
||||||
new FieldAccessPostAggregator("field1", "sketch")
|
new FieldAccessPostAggregator("field1", "sketch")
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
KllDoublesSketchToStringPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new KllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
KllDoublesSketchToStringPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -55,9 +55,10 @@ public class KllFloatsSketchToCDFPostAggregatorTest
|
||||||
new float[]{0.25f, 0.75f}
|
new float[]{0.25f, 0.75f}
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
KllFloatsSketchToCDFPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new KllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
KllFloatsSketchToCDFPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -56,9 +56,10 @@ public class KllFloatsSketchToHistogramPostAggregatorTest
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
KllFloatsSketchToHistogramPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new KllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
KllFloatsSketchToHistogramPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -38,9 +38,10 @@ public class KllFloatsSketchToQuantilePostAggregatorTest
|
||||||
0.5
|
0.5
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
KllFloatsSketchToQuantilePostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new KllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
KllFloatsSketchToQuantilePostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -55,9 +55,10 @@ public class KllFloatsSketchToQuantilesPostAggregatorTest
|
||||||
new double[] {0, 0.5, 1}
|
new double[] {0, 0.5, 1}
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
KllFloatsSketchToQuantilesPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new KllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
KllFloatsSketchToQuantilesPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -49,9 +49,10 @@ public class KllFloatsSketchToRankPostAggregatorTest
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
KllFloatsSketchToRankPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new KllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
KllFloatsSketchToRankPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -43,9 +43,10 @@ public class KllFloatsSketchToStringPostAggregatorTest
|
||||||
new FieldAccessPostAggregator("field1", "sketch")
|
new FieldAccessPostAggregator("field1", "sketch")
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
KllFloatsSketchToStringPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new KllSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
KllFloatsSketchToStringPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -55,9 +55,10 @@ public class DoublesSketchToCDFPostAggregatorTest
|
||||||
new double[]{0.25, 0.75}
|
new double[]{0.25, 0.75}
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
DoublesSketchToCDFPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new DoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
DoublesSketchToCDFPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -56,9 +56,10 @@ public class DoublesSketchToHistogramPostAggregatorTest
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
DoublesSketchToHistogramPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new DoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
DoublesSketchToHistogramPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -38,9 +38,10 @@ public class DoublesSketchToQuantilePostAggregatorTest
|
||||||
0.5
|
0.5
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
DoublesSketchToQuantilePostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new DoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
DoublesSketchToQuantilePostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -55,9 +55,10 @@ public class DoublesSketchToQuantilesPostAggregatorTest
|
||||||
new double[] {0, 0.5, 1}
|
new double[] {0, 0.5, 1}
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
DoublesSketchToQuantilesPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new DoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
DoublesSketchToQuantilesPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -49,9 +49,10 @@ public class DoublesSketchToRankPostAggregatorTest
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
DoublesSketchToRankPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new DoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
DoublesSketchToRankPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -43,9 +43,10 @@ public class DoublesSketchToStringPostAggregatorTest
|
||||||
new FieldAccessPostAggregator("field1", "sketch")
|
new FieldAccessPostAggregator("field1", "sketch")
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
DoublesSketchToStringPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new DoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
DoublesSketchToStringPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -85,11 +85,13 @@ public class SketchSetPostAggregatorTest
|
||||||
);
|
);
|
||||||
List<PostAggregator> serdeTests = Arrays.asList(union, intersect, not);
|
List<PostAggregator> serdeTests = Arrays.asList(union, intersect, not);
|
||||||
|
|
||||||
for (PostAggregator there : serdeTests) {
|
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
SketchSetPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new SketchModule().getJacksonModules());
|
||||||
|
|
||||||
|
for (PostAggregator there : serdeTests) {
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
SketchSetPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -47,9 +47,10 @@ public class SketchToStringPostAggregatorTest
|
||||||
new FieldAccessPostAggregator("field", "sketch")
|
new FieldAccessPostAggregator("field", "sketch")
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
SketchToStringPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new SketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
SketchToStringPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
|
|
||||||
package org.apache.druid.query.aggregation.datasketches.tuple;
|
package org.apache.druid.query.aggregation.datasketches.tuple;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import nl.jqno.equalsverifier.EqualsVerifier;
|
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||||
|
import org.apache.druid.jackson.DefaultObjectMapper;
|
||||||
import org.apache.druid.java.util.common.guava.Comparators;
|
import org.apache.druid.java.util.common.guava.Comparators;
|
||||||
import org.apache.druid.query.aggregation.PostAggregator;
|
import org.apache.druid.query.aggregation.PostAggregator;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -28,7 +30,6 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class ArrayOfDoublesSketchConstantPostAggregatorTest
|
public class ArrayOfDoublesSketchConstantPostAggregatorTest
|
||||||
{
|
{
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSketchValue()
|
public void testSketchValue()
|
||||||
{
|
{
|
||||||
|
@ -66,11 +67,31 @@ public class ArrayOfDoublesSketchConstantPostAggregatorTest
|
||||||
Assert.assertEquals(Comparators.alwaysEqual(), postAgg.getComparator());
|
Assert.assertEquals(Comparators.alwaysEqual(), postAgg.getComparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSerde() throws JsonProcessingException
|
||||||
|
{
|
||||||
|
final PostAggregator there = new ArrayOfDoublesSketchConstantPostAggregator(
|
||||||
|
"p",
|
||||||
|
"AQEJAwgBzJP/////////fwIAAAAAAAAAzT6NGdX0aWUOJvS5EIhpLwAAAAAAAAAAAAAAAAAAAAA="
|
||||||
|
);
|
||||||
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
|
mapper.registerModules(new ArrayOfDoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
|
mapper.writeValueAsString(there),
|
||||||
|
PostAggregator.class
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
Assert.assertArrayEquals(there.getCacheKey(), andBackAgain.getCacheKey());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEqualsAndHashCode()
|
public void testEqualsAndHashCode()
|
||||||
{
|
{
|
||||||
EqualsVerifier.forClass(ArrayOfDoublesSketchConstantPostAggregator.class)
|
EqualsVerifier.forClass(ArrayOfDoublesSketchConstantPostAggregator.class)
|
||||||
.usingGetClass()
|
.usingGetClass()
|
||||||
|
.withNonnullFields("name")
|
||||||
|
.withIgnoredFields("sketchValue")
|
||||||
.verify();
|
.verify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,10 @@ public class ArrayOfDoublesSketchSetOpPostAggregatorTest
|
||||||
Arrays.asList(new ConstantPostAggregator("", 0), new ConstantPostAggregator("", 0))
|
Arrays.asList(new ConstantPostAggregator("", 0), new ConstantPostAggregator("", 0))
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
ArrayOfDoublesSketchSetOpPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new ArrayOfDoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
ArrayOfDoublesSketchSetOpPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -84,9 +84,10 @@ public class ArrayOfDoublesSketchTTestPostAggregatorTest
|
||||||
Arrays.asList(new ConstantPostAggregator("", 0), new ConstantPostAggregator("", 0))
|
Arrays.asList(new ConstantPostAggregator("", 0), new ConstantPostAggregator("", 0))
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
ArrayOfDoublesSketchTTestPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new ArrayOfDoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
ArrayOfDoublesSketchTTestPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -51,9 +51,10 @@ public class ArrayOfDoublesSketchToBase64StringPostAggregatorTest
|
||||||
new ConstantPostAggregator("", 0)
|
new ConstantPostAggregator("", 0)
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
ArrayOfDoublesSketchToBase64StringPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new ArrayOfDoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
ArrayOfDoublesSketchToBase64StringPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -44,9 +44,10 @@ public class ArrayOfDoublesSketchToEstimateAndBoundsPostAggregatorTest
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
ArrayOfDoublesSketchToEstimateAndBoundsPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new ArrayOfDoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
ArrayOfDoublesSketchToEstimateAndBoundsPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -50,9 +50,10 @@ public class ArrayOfDoublesSketchToEstimatePostAggregatorTest
|
||||||
new ConstantPostAggregator("", 0)
|
new ConstantPostAggregator("", 0)
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
ArrayOfDoublesSketchToEstimatePostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new ArrayOfDoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
ArrayOfDoublesSketchToEstimatePostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -50,9 +50,10 @@ public class ArrayOfDoublesSketchToMeansPostAggregatorTest
|
||||||
new ConstantPostAggregator("", 0)
|
new ConstantPostAggregator("", 0)
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
ArrayOfDoublesSketchToMeansPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new ArrayOfDoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
ArrayOfDoublesSketchToMeansPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -52,9 +52,10 @@ public class ArrayOfDoublesSketchToMetricsSumEstimatePostAggregatorTest
|
||||||
new ConstantPostAggregator("", 0)
|
new ConstantPostAggregator("", 0)
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
ArrayOfDoublesSketchToMetricsSumEstimatePostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new ArrayOfDoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
ArrayOfDoublesSketchToMetricsSumEstimatePostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -50,9 +50,10 @@ public class ArrayOfDoublesSketchToNumEntriesPostAggregatorTest
|
||||||
new ConstantPostAggregator("", 0)
|
new ConstantPostAggregator("", 0)
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
ArrayOfDoublesSketchToNumEntriesPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new ArrayOfDoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
ArrayOfDoublesSketchToNumEntriesPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -54,9 +54,10 @@ public class ArrayOfDoublesSketchToQuantilesSketchPostAggregatorTest
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
ArrayOfDoublesSketchToQuantilesSketchPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new ArrayOfDoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
ArrayOfDoublesSketchToQuantilesSketchPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -50,9 +50,10 @@ public class ArrayOfDoublesSketchToStringPostAggregatorTest
|
||||||
new ConstantPostAggregator("", 0)
|
new ConstantPostAggregator("", 0)
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
ArrayOfDoublesSketchToStringPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new ArrayOfDoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
ArrayOfDoublesSketchToStringPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
|
@ -50,9 +50,10 @@ public class ArrayOfDoublesSketchToVariancesPostAggregatorTest
|
||||||
new ConstantPostAggregator("", 0)
|
new ConstantPostAggregator("", 0)
|
||||||
);
|
);
|
||||||
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||||
ArrayOfDoublesSketchToVariancesPostAggregator andBackAgain = mapper.readValue(
|
mapper.registerModules(new ArrayOfDoublesSketchModule().getJacksonModules());
|
||||||
|
PostAggregator andBackAgain = mapper.readValue(
|
||||||
mapper.writeValueAsString(there),
|
mapper.writeValueAsString(there),
|
||||||
ArrayOfDoublesSketchToVariancesPostAggregator.class
|
PostAggregator.class
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.assertEquals(there, andBackAgain);
|
Assert.assertEquals(there, andBackAgain);
|
||||||
|
|
Loading…
Reference in New Issue