use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class DoublesSketchToStringPostAggregatorTest method testComparator.
@Test
public void testComparator() {
expectedException.expect(IAE.class);
expectedException.expectMessage("Comparing sketch summaries is not supported");
final PostAggregator postAgg = new DoublesSketchToStringPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"));
postAgg.getComparator();
}
use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class DoublesSketchToStringPostAggregatorTest method testSerde.
@Test
public void testSerde() throws JsonProcessingException {
final PostAggregator there = new DoublesSketchToStringPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"));
DefaultObjectMapper mapper = new DefaultObjectMapper();
DoublesSketchToStringPostAggregator andBackAgain = mapper.readValue(mapper.writeValueAsString(there), DoublesSketchToStringPostAggregator.class);
Assert.assertEquals(there, andBackAgain);
Assert.assertArrayEquals(there.getCacheKey(), andBackAgain.getCacheKey());
}
use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class ThetaSketchSetBaseOperatorConversion method toPostAggregator.
@Nullable
@Override
public PostAggregator toPostAggregator(PlannerContext plannerContext, RowSignature rowSignature, RexNode rexNode, PostAggregatorVisitor postAggregatorVisitor) {
final List<RexNode> operands = ((RexCall) rexNode).getOperands();
final List<PostAggregator> inputPostAggs = new ArrayList<>();
Integer size = null;
int operandCounter = 0;
for (RexNode operand : operands) {
final PostAggregator convertedPostAgg = OperatorConversions.toPostAggregator(plannerContext, rowSignature, operand, postAggregatorVisitor);
if (convertedPostAgg == null) {
if (operandCounter == 0) {
try {
if (!operand.isA(SqlKind.LITERAL)) {
return null;
}
size = RexLiteral.intValue(operand);
} catch (ClassCastException cce) {
return null;
}
} else {
return null;
}
} else {
inputPostAggs.add(convertedPostAgg);
operandCounter++;
}
}
return new SketchSetPostAggregator(postAggregatorVisitor.getOutputNamePrefix() + postAggregatorVisitor.getAndIncrementCounter(), getSetOperationName(), size, inputPostAggs);
}
use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class HllSketchToEstimateWithBoundsPostAggregatorTest method testSerde.
@Test
public void testSerde() throws JsonProcessingException {
final PostAggregator there = new HllSketchToEstimateWithBoundsPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"), 2);
DefaultObjectMapper mapper = new DefaultObjectMapper();
HllSketchToEstimateWithBoundsPostAggregator andBackAgain = mapper.readValue(mapper.writeValueAsString(there), HllSketchToEstimateWithBoundsPostAggregator.class);
Assert.assertEquals(there, andBackAgain);
Assert.assertArrayEquals(there.getCacheKey(), andBackAgain.getCacheKey());
}
use of org.apache.druid.query.aggregation.PostAggregator in project druid by druid-io.
the class DoublesSketchToCDFPostAggregatorTest method testComparator.
@Test
public void testComparator() {
expectedException.expect(IAE.class);
expectedException.expectMessage("Comparing histograms is not supported");
final PostAggregator postAgg = new DoublesSketchToCDFPostAggregator("post", new FieldAccessPostAggregator("field1", "sketch"), new double[] { 0.25, 0.75 });
postAgg.getComparator();
}
Aggregations