mirror of https://github.com/apache/druid.git
fix backwards compatibility for explicit null columns (#12585)
This commit is contained in:
parent
f7ce73eee7
commit
31f988ec76
|
@ -337,7 +337,7 @@ public class IndexMergerV9 implements IndexMerger
|
|||
ColumnDescriptor columnDesc = ColumnDescriptor
|
||||
.builder()
|
||||
.setValueType(dimCapabilities.get(i).getType())
|
||||
.addSerde(new NullColumnPartSerde(indexMergeResult.rowCount))
|
||||
.addSerde(new NullColumnPartSerde(indexMergeResult.rowCount, indexSpec.getBitmapSerdeFactory()))
|
||||
.build();
|
||||
makeColumn(v9Smoosher, mergedDimensions.get(i), columnDesc);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.druid.java.util.common.io.smoosh.FileSmoosher;
|
|||
import org.apache.druid.query.extraction.ExtractionFn;
|
||||
import org.apache.druid.segment.DimensionSelector;
|
||||
import org.apache.druid.segment.column.DictionaryEncodedColumn;
|
||||
import org.apache.druid.segment.data.BitmapSerdeFactory;
|
||||
import org.apache.druid.segment.data.IndexedInts;
|
||||
import org.apache.druid.segment.data.ReadableOffset;
|
||||
import org.apache.druid.segment.vector.MultiValueDimensionVectorSelector;
|
||||
|
@ -60,14 +61,18 @@ public class NullColumnPartSerde implements ColumnPartSerde
|
|||
};
|
||||
|
||||
private final int numRows;
|
||||
private final BitmapSerdeFactory bitmapSerdeFactory;
|
||||
|
||||
private final NullDictionaryEncodedColumn nullDictionaryEncodedColumn;
|
||||
|
||||
@JsonCreator
|
||||
public NullColumnPartSerde(
|
||||
@JsonProperty("numRows") int numRows
|
||||
@JsonProperty("numRows") int numRows,
|
||||
@JsonProperty("bitmapSerdeFactory") BitmapSerdeFactory bitmapSerdeFactory
|
||||
)
|
||||
{
|
||||
this.numRows = numRows;
|
||||
this.bitmapSerdeFactory = bitmapSerdeFactory;
|
||||
this.nullDictionaryEncodedColumn = new NullDictionaryEncodedColumn();
|
||||
}
|
||||
|
||||
|
@ -77,6 +82,17 @@ public class NullColumnPartSerde implements ColumnPartSerde
|
|||
return numRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is no longer used for anything, but is required for backwards compatibility, so that segments with
|
||||
* explicit null columns can be read with 0.23
|
||||
*/
|
||||
@Deprecated
|
||||
@JsonProperty
|
||||
public BitmapSerdeFactory getBitmapSerdeFactory()
|
||||
{
|
||||
return bitmapSerdeFactory;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Serializer getSerializer()
|
||||
|
@ -108,13 +124,13 @@ public class NullColumnPartSerde implements ColumnPartSerde
|
|||
return false;
|
||||
}
|
||||
NullColumnPartSerde partSerde = (NullColumnPartSerde) o;
|
||||
return numRows == partSerde.numRows;
|
||||
return numRows == partSerde.numRows && Objects.equals(bitmapSerdeFactory, partSerde.bitmapSerdeFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(numRows);
|
||||
return Objects.hash(numRows, bitmapSerdeFactory);
|
||||
}
|
||||
|
||||
private final class NullDictionaryEncodedColumn implements DictionaryEncodedColumn<String>
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.druid.segment.column.ColumnBuilder;
|
|||
import org.apache.druid.segment.column.ColumnCapabilities;
|
||||
import org.apache.druid.segment.column.ColumnConfig;
|
||||
import org.apache.druid.segment.column.ValueType;
|
||||
import org.apache.druid.segment.data.RoaringBitmapSerdeFactory;
|
||||
import org.apache.druid.testing.InitializedNullHandlingTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -40,7 +41,7 @@ public class NullColumnPartSerdeTest extends InitializedNullHandlingTest
|
|||
{
|
||||
final ObjectMapper mapper = new DefaultObjectMapper();
|
||||
|
||||
final NullColumnPartSerde partSerde = new NullColumnPartSerde(10);
|
||||
final NullColumnPartSerde partSerde = new NullColumnPartSerde(10, new RoaringBitmapSerdeFactory(null));
|
||||
final String json = mapper.writeValueAsString(partSerde);
|
||||
Assert.assertEquals(partSerde, mapper.readValue(json, ColumnPartSerde.class));
|
||||
}
|
||||
|
@ -48,7 +49,7 @@ public class NullColumnPartSerdeTest extends InitializedNullHandlingTest
|
|||
@Test
|
||||
public void testDeserializer()
|
||||
{
|
||||
final NullColumnPartSerde partSerde = new NullColumnPartSerde(10);
|
||||
final NullColumnPartSerde partSerde = new NullColumnPartSerde(10, new RoaringBitmapSerdeFactory(null));
|
||||
final ColumnBuilder builder = new ColumnBuilder().setType(ValueType.DOUBLE);
|
||||
partSerde.getDeserializer().read(Mockito.mock(ByteBuffer.class), builder, Mockito.mock(ColumnConfig.class));
|
||||
final ColumnCapabilities columnCapabilities = builder.build().getCapabilities();
|
||||
|
|
Loading…
Reference in New Issue