Search in sources :

Example 1 with TestFloatColumnSelector

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);
}
Also used : TestFloatColumnSelector(org.apache.druid.query.aggregation.TestFloatColumnSelector) ColumnSelectorFactory(org.apache.druid.segment.ColumnSelectorFactory) Before(org.junit.Before)

Example 2 with TestFloatColumnSelector

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);
}
Also used : TestFloatColumnSelector(org.apache.druid.query.aggregation.TestFloatColumnSelector) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 3 with TestFloatColumnSelector

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);
}
Also used : TestFloatColumnSelector(org.apache.druid.query.aggregation.TestFloatColumnSelector) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) Test(org.junit.Test)

Example 4 with TestFloatColumnSelector

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);
}
Also used : TestFloatColumnSelector(org.apache.druid.query.aggregation.TestFloatColumnSelector) ColumnSelectorFactory(org.apache.druid.segment.ColumnSelectorFactory) TestLongColumnSelector(org.apache.druid.query.aggregation.TestLongColumnSelector) Before(org.junit.Before)

Example 5 with TestFloatColumnSelector

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);
}
Also used : TestFloatColumnSelector(org.apache.druid.query.aggregation.TestFloatColumnSelector) ColumnSelectorFactory(org.apache.druid.segment.ColumnSelectorFactory) TestLongColumnSelector(org.apache.druid.query.aggregation.TestLongColumnSelector) Before(org.junit.Before)

Aggregations

TestFloatColumnSelector (org.apache.druid.query.aggregation.TestFloatColumnSelector)9 Test (org.junit.Test)5 ColumnSelectorFactory (org.apache.druid.segment.ColumnSelectorFactory)4 Before (org.junit.Before)4 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)3 ByteBuffer (java.nio.ByteBuffer)2 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)2 TestLongColumnSelector (org.apache.druid.query.aggregation.TestLongColumnSelector)2 HashMap (java.util.HashMap)1