use of org.apache.druid.query.aggregation.TestDoubleColumnSelectorImpl in project druid by druid-io.
the class DoublesSketchToQuantilesPostAggregatorTest method normalCase.
@Test
public void normalCase() {
final double[] values = new double[] { 1, 2, 3, 4, 5 };
final TestDoubleColumnSelectorImpl selector = new TestDoubleColumnSelectorImpl(values);
final Aggregator agg = new DoublesSketchBuildAggregator(selector, 8);
// noinspection ForLoopReplaceableByForEach
for (int i = 0; i < values.length; i++) {
agg.aggregate();
selector.increment();
}
final Map<String, Object> fields = new HashMap<>();
fields.put("sketch", agg.get());
final PostAggregator postAgg = new DoublesSketchToQuantilesPostAggregator("quantiles", new FieldAccessPostAggregator("field", "sketch"), new double[] { 0, 0.5, 1 });
final double[] quantiles = (double[]) postAgg.compute(fields);
Assert.assertNotNull(quantiles);
Assert.assertEquals(3, quantiles.length);
Assert.assertEquals(1.0, quantiles[0], 0);
Assert.assertEquals(3.0, quantiles[1], 0);
Assert.assertEquals(5.0, quantiles[2], 0);
}
use of org.apache.druid.query.aggregation.TestDoubleColumnSelectorImpl in project druid by druid-io.
the class DoubleAnyAggregationTest method setup.
@Before
public void setup() {
doubleAnyAggFactory = new DoubleAnyAggregatorFactory("billy", "nilly");
combiningAggFactory = (DoubleAnyAggregatorFactory) doubleAnyAggFactory.getCombiningFactory();
valueSelector = new TestDoubleColumnSelectorImpl(doubles);
objectSelector = new TestObjectColumnSelector<>(objects);
colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector);
EasyMock.replay(colSelectorFactory);
}
Aggregations