use of org.apache.druid.segment.vector.VectorValueSelector in project druid by druid-io.
the class DoubleMaxAggregationTest method testDoubleMaxVectorAggregator.
@Test
public void testDoubleMaxVectorAggregator() {
// Some sanity.
Assert.assertTrue(doubleMaxVectorAggFactory.canVectorize(vectorColumnSelectorFactory));
VectorValueSelector vectorValueSelector = doubleMaxVectorAggFactory.vectorSelector(vectorColumnSelectorFactory);
Assert.assertEquals(doubleValues1, vectorValueSelector.getDoubleVector());
VectorAggregator vectorAggregator = doubleMaxVectorAggFactory.factorizeVector(vectorColumnSelectorFactory);
final ByteBuffer buf = ByteBuffer.allocate(doubleMaxVectorAggFactory.getMaxIntermediateSizeWithNulls() * 3);
vectorAggregator.init(buf, 0);
vectorAggregator.aggregate(buf, 0, 0, 3);
Assert.assertEquals(doubleValues1[0], vectorAggregator.get(buf, 0));
vectorAggregator.init(buf, 8);
vectorAggregator.aggregate(buf, 8, 0, 3);
Assert.assertEquals(doubleValues1[0], vectorAggregator.get(buf, 8));
vectorAggregator.init(buf, 16);
vectorAggregator.aggregate(buf, 16, 4, 7);
Assert.assertEquals(doubleValues1[5], vectorAggregator.get(buf, 16));
vectorAggregator.init(buf, 0);
vectorAggregator.aggregate(buf, 0, 0, 10);
Assert.assertEquals(doubleValues1[3], vectorAggregator.get(buf, 0));
}
use of org.apache.druid.segment.vector.VectorValueSelector in project druid by druid-io.
the class FloatMaxAggregationTest method testFloatMaxVectorAggregator.
@Test
public void testFloatMaxVectorAggregator() {
// Some sanity.
Assert.assertTrue(floatMaxAggregatorFactory.canVectorize(vectorColumnSelectorFactory));
VectorValueSelector vectorValueSelector = floatMaxAggregatorFactory.vectorSelector(vectorColumnSelectorFactory);
Assert.assertEquals(floatValues1, vectorValueSelector.getFloatVector());
VectorAggregator vectorAggregator = floatMaxAggregatorFactory.factorizeVector(vectorColumnSelectorFactory);
final ByteBuffer buf = ByteBuffer.allocate(floatMaxAggregatorFactory.getMaxIntermediateSizeWithNulls() * 3);
vectorAggregator.init(buf, 0);
vectorAggregator.aggregate(buf, 0, 0, 3);
Assert.assertEquals(floatValues1[0], vectorAggregator.get(buf, 0));
vectorAggregator.init(buf, 4);
vectorAggregator.aggregate(buf, 4, 0, 3);
Assert.assertEquals(floatValues1[0], vectorAggregator.get(buf, 4));
vectorAggregator.init(buf, 8);
vectorAggregator.aggregate(buf, 8, 4, 7);
Assert.assertEquals(floatValues1[5], vectorAggregator.get(buf, 8));
vectorAggregator.init(buf, 0);
vectorAggregator.aggregate(buf, 0, 0, 10);
Assert.assertEquals(floatValues1[3], vectorAggregator.get(buf, 0));
}
use of org.apache.druid.segment.vector.VectorValueSelector in project druid by druid-io.
the class DoubleMinAggregationTest method setup.
@Before
public void setup() {
NullHandling.initializeForTests();
selector = new TestDoubleColumnSelectorImpl(values);
colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(selector);
EasyMock.expect(colSelectorFactory.getColumnCapabilities("nilly")).andReturn(null);
EasyMock.replay(colSelectorFactory);
VectorValueSelector vectorValueSelector = EasyMock.createMock(VectorValueSelector.class);
EasyMock.expect(vectorValueSelector.getDoubleVector()).andReturn(doubleValues1).anyTimes();
EasyMock.expect(vectorValueSelector.getNullVector()).andReturn(null).anyTimes();
EasyMock.replay(vectorValueSelector);
vectorColumnSelectorFactory = EasyMock.createMock(VectorColumnSelectorFactory.class);
EasyMock.expect(vectorColumnSelectorFactory.getColumnCapabilities("dblFld")).andReturn(new ColumnCapabilitiesImpl().setType(ColumnType.DOUBLE).setDictionaryEncoded(true)).anyTimes();
EasyMock.expect(vectorColumnSelectorFactory.makeValueSelector("dblFld")).andReturn(vectorValueSelector).anyTimes();
EasyMock.replay(vectorColumnSelectorFactory);
}
use of org.apache.druid.segment.vector.VectorValueSelector in project druid by druid-io.
the class FloatMinAggregationTest method setup.
@Before
public void setup() {
NullHandling.initializeForTests();
VectorValueSelector vectorValueSelector = EasyMock.createMock(VectorValueSelector.class);
EasyMock.expect(vectorValueSelector.getFloatVector()).andReturn(floatValues1).anyTimes();
EasyMock.expect(vectorValueSelector.getNullVector()).andReturn(null).anyTimes();
EasyMock.replay(vectorValueSelector);
vectorColumnSelectorFactory = EasyMock.createMock(VectorColumnSelectorFactory.class);
EasyMock.expect(vectorColumnSelectorFactory.getColumnCapabilities("fltFld")).andReturn(new ColumnCapabilitiesImpl().setType(ColumnType.FLOAT).setDictionaryEncoded(true)).anyTimes();
EasyMock.expect(vectorColumnSelectorFactory.makeValueSelector("fltFld")).andReturn(vectorValueSelector).anyTimes();
EasyMock.replay(vectorColumnSelectorFactory);
}
use of org.apache.druid.segment.vector.VectorValueSelector in project druid by druid-io.
the class FloatMinAggregationTest method testFloatMinVectorAggregator.
@Test
public void testFloatMinVectorAggregator() {
// Some sanity.
Assert.assertTrue(floatMinAggregatorFactory.canVectorize(vectorColumnSelectorFactory));
VectorValueSelector vectorValueSelector = floatMinAggregatorFactory.vectorSelector(vectorColumnSelectorFactory);
Assert.assertEquals(floatValues1, vectorValueSelector.getFloatVector());
VectorAggregator vectorAggregator = floatMinAggregatorFactory.factorizeVector(vectorColumnSelectorFactory);
final ByteBuffer buf = ByteBuffer.allocate(floatMinAggregatorFactory.getMaxIntermediateSizeWithNulls() * 3);
vectorAggregator.init(buf, 0);
vectorAggregator.aggregate(buf, 0, 0, 3);
Assert.assertEquals(floatValues1[1], vectorAggregator.get(buf, 0));
vectorAggregator.init(buf, 4);
vectorAggregator.aggregate(buf, 4, 0, 3);
Assert.assertEquals(floatValues1[1], vectorAggregator.get(buf, 4));
vectorAggregator.init(buf, 8);
vectorAggregator.aggregate(buf, 8, 3, 7);
Assert.assertEquals(floatValues1[6], vectorAggregator.get(buf, 8));
vectorAggregator.init(buf, 0);
vectorAggregator.aggregate(buf, 0, 0, 10);
Assert.assertEquals(floatValues1[7], vectorAggregator.get(buf, 0));
}
Aggregations