Search in sources :

Example 21 with ColumnCapabilitiesImpl

use of org.apache.druid.segment.column.ColumnCapabilitiesImpl in project druid by druid-io.

the class VectorValueMatcherColumnProcessorFactoryTest method testSingleValueStringOneCardinalityBooleanMatcherIfNullAndNameLookupPossible.

@Test
public void testSingleValueStringOneCardinalityBooleanMatcherIfNullAndNameLookupPossible() {
    // single value string column with cardinality 1 and name lookup possible in advance uses boolean matcher for
    // matches
    SingleValueDimensionVectorSelector selector = EasyMock.createMock(SingleValueDimensionVectorSelector.class);
    EasyMock.expect(selector.getCurrentVectorSize()).andReturn(CURRENT_SIZE).anyTimes();
    EasyMock.expect(selector.getMaxVectorSize()).andReturn(VECTOR_SIZE).anyTimes();
    EasyMock.expect(selector.getValueCardinality()).andReturn(1).anyTimes();
    EasyMock.expect(selector.nameLookupPossibleInAdvance()).andReturn(true).anyTimes();
    EasyMock.expect(selector.lookupName(0)).andReturn(null).anyTimes();
    EasyMock.replay(selector);
    VectorValueMatcherFactory matcherFactory = VectorValueMatcherColumnProcessorFactory.instance().makeSingleValueDimensionProcessor(new ColumnCapabilitiesImpl().setType(ColumnType.STRING).setHasMultipleValues(false).setHasBitmapIndexes(true).setDictionaryValuesUnique(true).setDictionaryValuesSorted(true).setDictionaryEncoded(true), selector);
    Assert.assertTrue(matcherFactory instanceof SingleValueStringVectorValueMatcher);
    // false matcher
    VectorValueMatcher booleanMatcher = matcherFactory.makeMatcher("any value");
    Assert.assertTrue(booleanMatcher instanceof BooleanVectorValueMatcher);
    Assert.assertEquals(VECTOR_SIZE, booleanMatcher.getMaxVectorSize());
    Assert.assertEquals(CURRENT_SIZE, booleanMatcher.getCurrentVectorSize());
    // true matcher
    VectorValueMatcher anotherBooleanMatcher = matcherFactory.makeMatcher((String) null);
    Assert.assertTrue(anotherBooleanMatcher instanceof BooleanVectorValueMatcher);
    Assert.assertEquals(VECTOR_SIZE, anotherBooleanMatcher.getMaxVectorSize());
    Assert.assertEquals(CURRENT_SIZE, anotherBooleanMatcher.getCurrentVectorSize());
    EasyMock.verify(selector);
}
Also used : SingleValueDimensionVectorSelector(org.apache.druid.segment.vector.SingleValueDimensionVectorSelector) ColumnCapabilitiesImpl(org.apache.druid.segment.column.ColumnCapabilitiesImpl) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 22 with ColumnCapabilitiesImpl

use of org.apache.druid.segment.column.ColumnCapabilitiesImpl in project druid by druid-io.

the class DimensionHandlerUtilsTest method testGetHandlerFromUnknownComplexCapabilities.

@Test
public void testGetHandlerFromUnknownComplexCapabilities() {
    expectedException.expect(ISE.class);
    expectedException.expectMessage("Can't find DimensionHandlerProvider for typeName [unknown]");
    ColumnCapabilities capabilities = new ColumnCapabilitiesImpl().setType(ColumnType.ofComplex("unknown"));
    DimensionHandlerUtils.getHandlerFromCapabilities(DIM_NAME, capabilities, null);
}
Also used : ColumnCapabilities(org.apache.druid.segment.column.ColumnCapabilities) ColumnCapabilitiesImpl(org.apache.druid.segment.column.ColumnCapabilitiesImpl) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 23 with ColumnCapabilitiesImpl

use of org.apache.druid.segment.column.ColumnCapabilitiesImpl in project druid by druid-io.

the class DimensionHandlerUtilsTest method testGetHandlerFromComplexCapabilities.

@Test
public void testGetHandlerFromComplexCapabilities() {
    ColumnCapabilities capabilities = new ColumnCapabilitiesImpl().setType(ColumnType.ofComplex(TYPE));
    DimensionHandler dimensionHandler = DimensionHandlerUtils.getHandlerFromCapabilities(DIM_NAME, capabilities, null);
    Assert.assertEquals(DIM_NAME, dimensionHandler.getDimensionName());
    Assert.assertTrue(dimensionHandler instanceof DoubleDimensionHandler);
    Assert.assertTrue(dimensionHandler.getDimensionSchema(capabilities) instanceof TestDimensionSchema);
}
Also used : ColumnCapabilities(org.apache.druid.segment.column.ColumnCapabilities) ColumnCapabilitiesImpl(org.apache.druid.segment.column.ColumnCapabilitiesImpl) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 24 with ColumnCapabilitiesImpl

use of org.apache.druid.segment.column.ColumnCapabilitiesImpl in project druid by druid-io.

the class VectorizedVirtualColumnTest method testGroupByForceVirtualContextCannotVectorize.

@Test
public void testGroupByForceVirtualContextCannotVectorize() {
    cannotVectorize();
    testGroupBy(new ColumnCapabilitiesImpl().setType(ColumnType.STRING).setDictionaryEncoded(true).setDictionaryValuesUnique(true).setHasMultipleValues(false), CONTEXT_VECTORIZE_TRUE_VIRTUAL_FORCE, false);
}
Also used : ColumnCapabilitiesImpl(org.apache.druid.segment.column.ColumnCapabilitiesImpl) Test(org.junit.Test)

Example 25 with ColumnCapabilitiesImpl

use of org.apache.druid.segment.column.ColumnCapabilitiesImpl in project druid by druid-io.

the class VectorizedVirtualColumnTest method testGroupByMultiValueStringNotDictionaryEncoded.

@Test
public void testGroupByMultiValueStringNotDictionaryEncoded() {
    // cannot currently group by string columns that might be multi valued
    cannotVectorize();
    testGroupBy(new ColumnCapabilitiesImpl().setType(ColumnType.STRING).setDictionaryEncoded(false).setDictionaryValuesUnique(false).setHasMultipleValues(true));
}
Also used : ColumnCapabilitiesImpl(org.apache.druid.segment.column.ColumnCapabilitiesImpl) Test(org.junit.Test)

Aggregations

ColumnCapabilitiesImpl (org.apache.druid.segment.column.ColumnCapabilitiesImpl)34 Test (org.junit.Test)20 ColumnSelectorFactory (org.apache.druid.segment.ColumnSelectorFactory)11 Before (org.junit.Before)10 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)9 ColumnCapabilities (org.apache.druid.segment.column.ColumnCapabilities)8 VectorColumnSelectorFactory (org.apache.druid.segment.vector.VectorColumnSelectorFactory)8 VectorValueSelector (org.apache.druid.segment.vector.VectorValueSelector)7 IdLookup (org.apache.druid.segment.IdLookup)5 SingleValueDimensionVectorSelector (org.apache.druid.segment.vector.SingleValueDimensionVectorSelector)4 Nullable (javax.annotation.Nullable)3 ColumnType (org.apache.druid.segment.column.ColumnType)3 ByteBuffer (java.nio.ByteBuffer)2 BufferAggregator (org.apache.druid.query.aggregation.BufferAggregator)2 TestLongColumnSelector (org.apache.druid.query.aggregation.TestLongColumnSelector)2 DimensionSpec (org.apache.druid.query.dimension.DimensionSpec)2 ValueMatcher (org.apache.druid.query.filter.ValueMatcher)2 RuntimeShapeInspector (org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector)2 IndexedInts (org.apache.druid.segment.data.IndexedInts)2 Predicate (com.google.common.base.Predicate)1