Search in sources :

Example 16 with VectorValueSelector

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));
}
Also used : VectorValueSelector(org.apache.druid.segment.vector.VectorValueSelector) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 17 with VectorValueSelector

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));
}
Also used : VectorValueSelector(org.apache.druid.segment.vector.VectorValueSelector) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 18 with VectorValueSelector

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);
}
Also used : ColumnSelectorFactory(org.apache.druid.segment.ColumnSelectorFactory) VectorColumnSelectorFactory(org.apache.druid.segment.vector.VectorColumnSelectorFactory) VectorValueSelector(org.apache.druid.segment.vector.VectorValueSelector) VectorColumnSelectorFactory(org.apache.druid.segment.vector.VectorColumnSelectorFactory) ColumnCapabilitiesImpl(org.apache.druid.segment.column.ColumnCapabilitiesImpl) Before(org.junit.Before)

Example 19 with VectorValueSelector

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);
}
Also used : VectorValueSelector(org.apache.druid.segment.vector.VectorValueSelector) VectorColumnSelectorFactory(org.apache.druid.segment.vector.VectorColumnSelectorFactory) ColumnCapabilitiesImpl(org.apache.druid.segment.column.ColumnCapabilitiesImpl) Before(org.junit.Before)

Example 20 with VectorValueSelector

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));
}
Also used : VectorValueSelector(org.apache.druid.segment.vector.VectorValueSelector) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

VectorValueSelector (org.apache.druid.segment.vector.VectorValueSelector)23 Test (org.junit.Test)10 Before (org.junit.Before)9 VectorColumnSelectorFactory (org.apache.druid.segment.vector.VectorColumnSelectorFactory)8 ColumnCapabilitiesImpl (org.apache.druid.segment.column.ColumnCapabilitiesImpl)7 ByteBuffer (java.nio.ByteBuffer)6 ColumnSelectorFactory (org.apache.druid.segment.ColumnSelectorFactory)4 ColumnCapabilities (org.apache.druid.segment.column.ColumnCapabilities)4 Nullable (javax.annotation.Nullable)3 ImmutableBitmap (org.apache.druid.collections.bitmap.ImmutableBitmap)3 Expr (org.apache.druid.math.expr.Expr)3 ExpressionType (org.apache.druid.math.expr.ExpressionType)3 VectorCursor (org.apache.druid.segment.vector.VectorCursor)3 ImmutableList (com.google.common.collect.ImmutableList)2 ArrayList (java.util.ArrayList)2 Granularities (org.apache.druid.java.util.common.granularity.Granularities)2 Sequence (org.apache.druid.java.util.common.guava.Sequence)2 Closer (org.apache.druid.java.util.common.io.Closer)2 ExprMacroTable (org.apache.druid.math.expr.ExprMacroTable)2 Parser (org.apache.druid.math.expr.Parser)2