clintropolis commented on code in PR #12834:
URL: https://github.com/apache/druid/pull/12834#discussion_r932943344
##########
processing/src/test/java/org/apache/druid/segment/serde/NullColumnPartSerdeTest.java:
##########
@@ -61,4 +76,128 @@ public void testDeserializer()
Assert.assertTrue(columnCapabilities.areDictionaryValuesSorted().isTrue());
Assert.assertTrue(columnCapabilities.areDictionaryValuesUnique().isTrue());
}
+
+ @Test
+ public void testDimensionSelector()
+ {
+ final NullColumnPartSerde partSerde = new NullColumnPartSerde(10, new
RoaringBitmapSerdeFactory(null));
+ final ColumnBuilder builder = new
ColumnBuilder().setType(ValueType.STRING);
+ partSerde.getDeserializer().read(Mockito.mock(ByteBuffer.class), builder,
Mockito.mock(ColumnConfig.class));
+ ColumnHolder holder = builder.build();
+
+ BaseColumn theColumn = holder.getColumn();
+ Assert.assertTrue(theColumn instanceof DictionaryEncodedColumn);
+ DictionaryEncodedColumn dictionaryEncodedColumn =
(DictionaryEncodedColumn) theColumn;
+
+ ReadableOffset offset = new SimpleAscendingOffset(10);
+ DimensionSelector dimensionSelector =
dictionaryEncodedColumn.makeDimensionSelector(
+ offset,
+ null
+ );
+ Assert.assertNull(dimensionSelector.getObject());
+ Assert.assertEquals(1, dimensionSelector.getRow().size());
+ Assert.assertEquals(0, dimensionSelector.getRow().get(0));
+ }
+
+ @Test
+ public void testDimensionVectorSelector()
+ {
+ final NullColumnPartSerde partSerde = new NullColumnPartSerde(10, new
RoaringBitmapSerdeFactory(null));
+ final ColumnBuilder builder = new
ColumnBuilder().setType(ValueType.STRING);
+ partSerde.getDeserializer().read(Mockito.mock(ByteBuffer.class), builder,
Mockito.mock(ColumnConfig.class));
+ ColumnHolder holder = builder.build();
+
+ BaseColumn theColumn = holder.getColumn();
+ Assert.assertTrue(theColumn instanceof DictionaryEncodedColumn);
+ DictionaryEncodedColumn dictionaryEncodedColumn =
(DictionaryEncodedColumn) theColumn;
+
+ ReadableVectorOffset vectorOffset = new NoFilterVectorOffset(8, 0, 10);
+
+ SingleValueDimensionVectorSelector vectorSelector =
+
dictionaryEncodedColumn.makeSingleValueDimensionVectorSelector(vectorOffset);
+
+ int[] rowVector = vectorSelector.getRowVector();
+ for (int i = 0; i < vectorOffset.getCurrentVectorSize(); i++) {
+ Assert.assertEquals(0, rowVector[i]);
+ Assert.assertNull(vectorSelector.lookupName(rowVector[i]));
+ }
+
+ Assert.assertThrows(UnsupportedOperationException.class, () -> {
+
dictionaryEncodedColumn.makeMultiValueDimensionVectorSelector(vectorOffset);
Review Comment:
yeah, we shouldn't use this selector because they cannot be multi-valued
because there is only a null value for every row. The single value selectors
are more optimized, this is mimicking how actually missing columns behave
https://github.com/apache/druid/blob/master/processing/src/main/java/org/apache/druid/segment/ColumnProcessors.java#L329
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]