Search in sources :

Example 11 with VectorColumnSelectorFactory

use of org.apache.druid.segment.vector.VectorColumnSelectorFactory 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 12 with VectorColumnSelectorFactory

use of org.apache.druid.segment.vector.VectorColumnSelectorFactory in project druid by druid-io.

the class BaseFilterTest method selectColumnValuesMatchingFilterUsingVectorizedPostFiltering.

private List<String> selectColumnValuesMatchingFilterUsingVectorizedPostFiltering(final DimFilter filter, final String selectColumn) {
    final Filter theFilter = makeFilter(filter);
    final Filter postFilteringFilter = new Filter() {

        @Override
        public <T> T getBitmapResult(BitmapIndexSelector selector, BitmapResultFactory<T> bitmapResultFactory) {
            throw new UnsupportedOperationException();
        }

        @Override
        public ValueMatcher makeMatcher(ColumnSelectorFactory factory) {
            return theFilter.makeMatcher(factory);
        }

        @Override
        public boolean supportsBitmapIndex(BitmapIndexSelector selector) {
            return false;
        }

        @Override
        public boolean shouldUseBitmapIndex(BitmapIndexSelector selector) {
            return false;
        }

        @Override
        public VectorValueMatcher makeVectorMatcher(VectorColumnSelectorFactory factory) {
            return theFilter.makeVectorMatcher(factory);
        }

        @Override
        public boolean canVectorizeMatcher(ColumnInspector inspector) {
            return theFilter.canVectorizeMatcher(inspector);
        }

        @Override
        public Set<String> getRequiredColumns() {
            return null;
        }

        @Override
        public boolean supportsSelectivityEstimation(ColumnSelector columnSelector, BitmapIndexSelector indexSelector) {
            return false;
        }

        @Override
        public double estimateSelectivity(BitmapIndexSelector indexSelector) {
            return 1.0;
        }
    };
    try (final VectorCursor cursor = makeVectorCursor(postFilteringFilter)) {
        final SingleValueDimensionVectorSelector selector = cursor.getColumnSelectorFactory().makeSingleValueDimensionSelector(new DefaultDimensionSpec(selectColumn, selectColumn));
        final List<String> values = new ArrayList<>();
        while (!cursor.isDone()) {
            final int[] rowVector = selector.getRowVector();
            for (int i = 0; i < cursor.getCurrentVectorSize(); i++) {
                values.add(selector.lookupName(rowVector[i]));
            }
            cursor.advance();
        }
        return values;
    }
}
Also used : ColumnSelectorFactory(org.apache.druid.segment.ColumnSelectorFactory) RowBasedColumnSelectorFactory(org.apache.druid.segment.RowBasedColumnSelectorFactory) VectorColumnSelectorFactory(org.apache.druid.segment.vector.VectorColumnSelectorFactory) ArrayList(java.util.ArrayList) ColumnInspector(org.apache.druid.segment.ColumnInspector) VectorCursor(org.apache.druid.segment.vector.VectorCursor) VectorColumnSelectorFactory(org.apache.druid.segment.vector.VectorColumnSelectorFactory) DefaultDimensionSpec(org.apache.druid.query.dimension.DefaultDimensionSpec) DimFilter(org.apache.druid.query.filter.DimFilter) Filter(org.apache.druid.query.filter.Filter) ColumnSelector(org.apache.druid.segment.ColumnSelector) BitmapResultFactory(org.apache.druid.query.BitmapResultFactory) BitmapIndexSelector(org.apache.druid.query.filter.BitmapIndexSelector) SingleValueDimensionVectorSelector(org.apache.druid.segment.vector.SingleValueDimensionVectorSelector)

Aggregations

VectorColumnSelectorFactory (org.apache.druid.segment.vector.VectorColumnSelectorFactory)12 Before (org.junit.Before)9 ColumnCapabilitiesImpl (org.apache.druid.segment.column.ColumnCapabilitiesImpl)8 VectorValueSelector (org.apache.druid.segment.vector.VectorValueSelector)8 ColumnSelectorFactory (org.apache.druid.segment.ColumnSelectorFactory)5 Closer (org.apache.druid.java.util.common.io.Closer)2 ColumnCapabilities (org.apache.druid.segment.column.ColumnCapabilities)2 VectorCursor (org.apache.druid.segment.vector.VectorCursor)2 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ISE (org.apache.druid.java.util.common.ISE)1 BitmapResultFactory (org.apache.druid.query.BitmapResultFactory)1 AggregatorAdapters (org.apache.druid.query.aggregation.AggregatorAdapters)1 AggregatorFactory (org.apache.druid.query.aggregation.AggregatorFactory)1 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)1 BitmapIndexSelector (org.apache.druid.query.filter.BitmapIndexSelector)1 DimFilter (org.apache.druid.query.filter.DimFilter)1 Filter (org.apache.druid.query.filter.Filter)1 VectorCursorGranularizer (org.apache.druid.query.vector.VectorCursorGranularizer)1