use of org.apache.druid.query.aggregation.TestFloatColumnSelector in project druid by druid-io.
the class VarianceAggregatorTest method setup.
@Before
public void setup() {
selector = new TestFloatColumnSelector(values);
colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(selector);
EasyMock.expect(colSelectorFactory.getColumnCapabilities("nilly")).andReturn(null);
EasyMock.replay(colSelectorFactory);
}
use of org.apache.druid.query.aggregation.TestFloatColumnSelector in project druid by druid-io.
the class ApproximateHistogramAggregatorTest method testFinalize.
@Test
public void testFinalize() throws Exception {
DefaultObjectMapper objectMapper = new DefaultObjectMapper();
final float[] values = { 23, 19, 10, 16, 36, 2, 9, 32, 30, 45 };
final int resolution = 5;
final int numBuckets = 5;
final TestFloatColumnSelector selector = new TestFloatColumnSelector(values);
ApproximateHistogramAggregatorFactory humanReadableFactory = new ApproximateHistogramAggregatorFactory("billy", "billy", resolution, numBuckets, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, false);
ApproximateHistogramAggregatorFactory binaryFactory = new ApproximateHistogramAggregatorFactory("billy", "billy", resolution, numBuckets, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, true);
ApproximateHistogramAggregator agg = new ApproximateHistogramAggregator(selector, resolution, 0, 100);
agg.aggregate();
Object finalizedObjectHumanReadable = humanReadableFactory.finalizeComputation(agg.get());
String finalStringHumanReadable = objectMapper.writeValueAsString(finalizedObjectHumanReadable);
Assert.assertEquals("{\"breaks\":[23.0,23.0,23.0,23.0,23.0,23.0],\"counts\":[0.0,0.0,0.0,0.0,0.0]}", finalStringHumanReadable);
Object finalizedObjectBinary = binaryFactory.finalizeComputation(agg.get());
String finalStringBinary = objectMapper.writeValueAsString(finalizedObjectBinary);
Assert.assertEquals("\"//sBQbgAAA==\"", finalStringBinary);
}
use of org.apache.druid.query.aggregation.TestFloatColumnSelector in project druid by druid-io.
the class FixedBucketsHistogramBufferAggregatorTest method testFinalize.
@Test
public void testFinalize() throws Exception {
DefaultObjectMapper objectMapper = new DefaultObjectMapper();
final float[] values = { 23, 19, 10, 16, 36, 2, 9, 32, 30, 45 };
final TestFloatColumnSelector selector = new TestFloatColumnSelector(values);
FixedBucketsHistogramAggregatorFactory humanReadableFactory = new FixedBucketsHistogramAggregatorFactory("billy", "billy", 5, 0, 50, FixedBucketsHistogram.OutlierHandlingMode.OVERFLOW, false);
FixedBucketsHistogramAggregatorFactory binaryFactory = new FixedBucketsHistogramAggregatorFactory("billy", "billy", 5, 0, 50, FixedBucketsHistogram.OutlierHandlingMode.OVERFLOW, true);
FixedBucketsHistogramAggregator agg = new FixedBucketsHistogramAggregator(selector, 0, 50, 5, FixedBucketsHistogram.OutlierHandlingMode.OVERFLOW);
agg.aggregate();
Object finalizedObjectHumanReadable = humanReadableFactory.finalizeComputation(agg.get());
String finalStringHumanReadable = objectMapper.writeValueAsString(finalizedObjectHumanReadable);
Assert.assertEquals("\"{lowerLimit=0.0, upperLimit=50.0, numBuckets=5, upperOutlierCount=0, lowerOutlierCount=0, missingValueCount=0, histogram=[0, 0, 1, 0, 0], outlierHandlingMode=overflow, count=1, max=23.0, min=23.0}\"", finalStringHumanReadable);
Object finalizedObjectBinary = binaryFactory.finalizeComputation(agg.get());
String finalStringBinary = objectMapper.writeValueAsString(finalizedObjectBinary);
Assert.assertEquals("\"AQIAAAAAAAAAAEBJAAAAAAAAAAAABQEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEA3AAAAAAAAQDcAAAAAAAAAAAABAAAAAgAAAAAAAAAB\"", finalStringBinary);
}
use of org.apache.druid.query.aggregation.TestFloatColumnSelector in project druid by druid-io.
the class FloatLastAggregationTest method setup.
@Before
public void setup() {
floatLastAggregatorFactory = new FloatLastAggregatorFactory("billy", "nilly", null);
combiningAggFactory = (FloatLastAggregatorFactory) floatLastAggregatorFactory.getCombiningFactory();
timeSelector = new TestLongColumnSelector(times);
customTimeSelector = new TestLongColumnSelector(customTimes);
valueSelector = new TestFloatColumnSelector(floats);
objectSelector = new TestObjectColumnSelector<>(pairs);
colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("customTime")).andReturn(customTimeSelector);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector);
EasyMock.replay(colSelectorFactory);
}
use of org.apache.druid.query.aggregation.TestFloatColumnSelector in project druid by druid-io.
the class FloatFirstAggregationTest method setup.
@Before
public void setup() {
floatFirstAggregatorFactory = new FloatFirstAggregatorFactory("billy", "nilly", null);
combiningAggFactory = (FloatFirstAggregatorFactory) floatFirstAggregatorFactory.getCombiningFactory();
timeSelector = new TestLongColumnSelector(times);
customTimeSelector = new TestLongColumnSelector(customTimes);
valueSelector = new TestFloatColumnSelector(floats);
objectSelector = new TestObjectColumnSelector<>(pairs);
colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("customTime")).andReturn(customTimeSelector);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector).atLeastOnce();
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector).atLeastOnce();
EasyMock.replay(colSelectorFactory);
}
Aggregations