Search in sources :

Example 26 with ColumnCapabilities

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

the class RowBasedStorageAdapterTest method test_getColumnCapabilities_string.

@Test
public void test_getColumnCapabilities_string() {
    final RowBasedStorageAdapter<Integer> adapter = createIntAdapter(0, 1, 2);
    final ColumnCapabilities capabilities = adapter.getColumnCapabilities(ValueType.STRING.name());
    Assert.assertEquals(ValueType.STRING, capabilities.getType());
    // Note: unlike numeric types, STRING-typed columns might have multiple values, so they report as incomplete. It
    // would be good in the future to support some way of changing this, when it is known ahead of time that
    // multi-valuedness is definitely happening or is definitely impossible.
    Assert.assertTrue(capabilities.hasMultipleValues().isUnknown());
}
Also used : ColumnCapabilities(org.apache.druid.segment.column.ColumnCapabilities) Test(org.junit.Test)

Example 27 with ColumnCapabilities

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

the class QueryableIndexColumnCapabilitiesTest method testStringColumn.

@Test
public void testStringColumn() {
    ColumnCapabilities caps = INC_INDEX.getColumnCapabilities("d1");
    Assert.assertEquals(ValueType.STRING, caps.getType());
    Assert.assertTrue(caps.hasBitmapIndexes());
    Assert.assertTrue(caps.isDictionaryEncoded().isMaybeTrue());
    Assert.assertTrue(caps.isDictionaryEncoded().isTrue());
    Assert.assertFalse(caps.areDictionaryValuesSorted().isTrue());
    Assert.assertTrue(caps.areDictionaryValuesUnique().isTrue());
    // multi-value is unknown unless explicitly set to 'true'
    Assert.assertTrue(caps.hasMultipleValues().isUnknown());
    // at index merge or query time we 'complete' the capabilities to take a snapshot of the current state,
    // coercing any 'UNKNOWN' values to false
    Assert.assertFalse(ColumnCapabilitiesImpl.snapshot(caps, IndexMergerV9.DIMENSION_CAPABILITY_MERGE_LOGIC).hasMultipleValues().isMaybeTrue());
    Assert.assertFalse(caps.hasSpatialIndexes());
    Assert.assertTrue(caps.hasNulls().isUnknown());
    caps = MMAP_INDEX.getColumnHolder("d1").getCapabilities();
    Assert.assertEquals(ValueType.STRING, caps.getType());
    Assert.assertTrue(caps.hasBitmapIndexes());
    Assert.assertTrue(caps.isDictionaryEncoded().isTrue());
    Assert.assertTrue(caps.areDictionaryValuesSorted().isTrue());
    Assert.assertTrue(caps.areDictionaryValuesUnique().isTrue());
    Assert.assertFalse(caps.hasMultipleValues().isMaybeTrue());
    Assert.assertFalse(caps.hasSpatialIndexes());
    Assert.assertFalse(caps.hasNulls().isMaybeTrue());
}
Also used : ColumnCapabilities(org.apache.druid.segment.column.ColumnCapabilities) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 28 with ColumnCapabilities

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

the class QueryableIndexColumnCapabilitiesTest method testMultiStringColumn.

@Test
public void testMultiStringColumn() {
    ColumnCapabilities caps = INC_INDEX.getColumnCapabilities("d2");
    Assert.assertEquals(ValueType.STRING, caps.getType());
    Assert.assertTrue(caps.hasBitmapIndexes());
    Assert.assertTrue(caps.isDictionaryEncoded().isTrue());
    Assert.assertFalse(caps.areDictionaryValuesSorted().isTrue());
    Assert.assertTrue(caps.areDictionaryValuesUnique().isTrue());
    Assert.assertTrue(caps.hasMultipleValues().isTrue());
    Assert.assertFalse(caps.hasSpatialIndexes());
    Assert.assertTrue(caps.hasNulls().isUnknown());
    caps = MMAP_INDEX.getColumnHolder("d2").getCapabilities();
    Assert.assertEquals(ValueType.STRING, caps.getType());
    Assert.assertTrue(caps.hasBitmapIndexes());
    Assert.assertTrue(caps.isDictionaryEncoded().isTrue());
    Assert.assertTrue(caps.areDictionaryValuesSorted().isTrue());
    Assert.assertTrue(caps.areDictionaryValuesUnique().isTrue());
    Assert.assertTrue(caps.hasMultipleValues().isTrue());
    Assert.assertFalse(caps.hasSpatialIndexes());
    Assert.assertFalse(caps.hasNulls().isMaybeTrue());
}
Also used : ColumnCapabilities(org.apache.druid.segment.column.ColumnCapabilities) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 29 with ColumnCapabilities

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

the class QueryableIndexColumnCapabilitiesTest method testMultiStringColumnWithNulls.

@Test
public void testMultiStringColumnWithNulls() {
    ColumnCapabilities caps = INC_INDEX_WITH_NULLS.getColumnCapabilities("d2");
    Assert.assertEquals(ValueType.STRING, caps.getType());
    Assert.assertTrue(caps.hasBitmapIndexes());
    Assert.assertTrue(caps.isDictionaryEncoded().isTrue());
    Assert.assertFalse(caps.areDictionaryValuesSorted().isTrue());
    Assert.assertTrue(caps.areDictionaryValuesUnique().isTrue());
    Assert.assertTrue(caps.hasMultipleValues().isTrue());
    Assert.assertFalse(caps.hasSpatialIndexes());
    Assert.assertTrue(caps.hasNulls().isTrue());
    caps = MMAP_INDEX_WITH_NULLS.getColumnHolder("d2").getCapabilities();
    Assert.assertEquals(ValueType.STRING, caps.getType());
    Assert.assertTrue(caps.hasBitmapIndexes());
    Assert.assertTrue(caps.isDictionaryEncoded().isTrue());
    Assert.assertTrue(caps.areDictionaryValuesSorted().isTrue());
    Assert.assertTrue(caps.areDictionaryValuesUnique().isTrue());
    Assert.assertTrue(caps.hasMultipleValues().isTrue());
    Assert.assertFalse(caps.hasSpatialIndexes());
    Assert.assertTrue(caps.hasNulls().isTrue());
}
Also used : ColumnCapabilities(org.apache.druid.segment.column.ColumnCapabilities) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 30 with ColumnCapabilities

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

the class RowBasedColumnSelectorFactoryTest method testCapabilitiesUnknownColumn.

@Test
public void testCapabilitiesUnknownColumn() {
    ColumnCapabilities caps = RowBasedColumnSelectorFactory.getColumnCapabilities(ROW_SIGNATURE, "wat");
    Assert.assertNull(caps);
}
Also used : ColumnCapabilities(org.apache.druid.segment.column.ColumnCapabilities) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

ColumnCapabilities (org.apache.druid.segment.column.ColumnCapabilities)78 Test (org.junit.Test)52 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)29 ColumnCapabilitiesImpl (org.apache.druid.segment.column.ColumnCapabilitiesImpl)9 ArrayList (java.util.ArrayList)4 Nullable (javax.annotation.Nullable)4 AggregatorFactory (org.apache.druid.query.aggregation.AggregatorFactory)4 DimensionSpec (org.apache.druid.query.dimension.DimensionSpec)4 ColumnValueSelector (org.apache.druid.segment.ColumnValueSelector)4 QueryableIndex (org.apache.druid.segment.QueryableIndex)4 ColumnHolder (org.apache.druid.segment.column.ColumnHolder)4 ColumnType (org.apache.druid.segment.column.ColumnType)4 RowSignature (org.apache.druid.segment.column.RowSignature)4 ValueType (org.apache.druid.segment.column.ValueType)4 List (java.util.List)3 NullHandlingTest (org.apache.druid.common.config.NullHandlingTest)3 ISE (org.apache.druid.java.util.common.ISE)3 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)3 VectorValueSelector (org.apache.druid.segment.vector.VectorValueSelector)3 Before (org.junit.Before)3