Follow-up PR to #17493 to address pending unaddressed comments.
This commit is contained in:
Adarsh Sanjeev 2024-11-22 09:22:38 +05:30 committed by GitHub
parent bd93d0046d
commit df649c0bbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 35 additions and 32 deletions

View File

@ -55,21 +55,21 @@ public class ScalarDoubleColumn implements NestedCommonFormatColumn
private final FixedIndexed<Double> doubleDictionary;
private final Supplier<ColumnarInts> encodedValuesSupplier;
private final ColumnarDoubles valueColumn;
private final ImmutableBitmap nullValueBitmap;
private final ImmutableBitmap nullValueIndex;
private final BitmapFactory bitmapFactory;
public ScalarDoubleColumn(
FixedIndexed<Double> doubleDictionary,
Supplier<ColumnarInts> encodedValuesSupplier,
ColumnarDoubles valueColumn,
ImmutableBitmap nullValueBitmap,
ImmutableBitmap nullValueIndex,
BitmapFactory bitmapFactory
)
{
this.doubleDictionary = doubleDictionary;
this.encodedValuesSupplier = encodedValuesSupplier;
this.valueColumn = valueColumn;
this.nullValueBitmap = nullValueBitmap;
this.nullValueIndex = nullValueIndex;
this.bitmapFactory = bitmapFactory;
}
@ -90,7 +90,7 @@ public class ScalarDoubleColumn implements NestedCommonFormatColumn
{
return new DoubleColumnSelector()
{
private PeekableIntIterator nullIterator = nullValueBitmap.peekableIterator();
private PeekableIntIterator nullIterator = nullValueIndex.peekableIterator();
private int nullMark = -1;
private int offsetMark = -1;
@ -104,7 +104,7 @@ public class ScalarDoubleColumn implements NestedCommonFormatColumn
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
inspector.visit("doubleColumn", valueColumn);
inspector.visit("nullBitmap", nullValueBitmap);
inspector.visit("nullBitmap", nullValueIndex);
}
@Override
@ -117,7 +117,7 @@ public class ScalarDoubleColumn implements NestedCommonFormatColumn
if (i < offsetMark) {
// offset was reset, reset iterator state
nullMark = -1;
nullIterator = nullValueBitmap.peekableIterator();
nullIterator = nullValueIndex.peekableIterator();
}
offsetMark = i;
if (nullMark < i) {
@ -142,7 +142,7 @@ public class ScalarDoubleColumn implements NestedCommonFormatColumn
private int id = ReadableVectorInspector.NULL_ID;
@Nullable
private PeekableIntIterator nullIterator = nullValueBitmap != null ? nullValueBitmap.peekableIterator() : null;
private PeekableIntIterator nullIterator = nullValueIndex != null ? nullValueIndex.peekableIterator() : null;
private int offsetMark = -1;
@Override
@ -171,14 +171,14 @@ public class ScalarDoubleColumn implements NestedCommonFormatColumn
if (offset.isContiguous()) {
if (offset.getStartOffset() < offsetMark) {
nullIterator = nullValueBitmap.peekableIterator();
nullIterator = nullValueIndex.peekableIterator();
}
offsetMark = offset.getStartOffset() + offset.getCurrentVectorSize();
valueColumn.get(valueVector, offset.getStartOffset(), offset.getCurrentVectorSize());
} else {
final int[] offsets = offset.getOffsets();
if (offsets[offsets.length - 1] < offsetMark) {
nullIterator = nullValueBitmap.peekableIterator();
nullIterator = nullValueIndex.peekableIterator();
}
offsetMark = offsets[offsets.length - 1];
valueColumn.get(valueVector, offsets, offset.getCurrentVectorSize());

View File

@ -55,21 +55,21 @@ public class ScalarLongColumn implements NestedCommonFormatColumn
private final FixedIndexed<Long> longDictionary;
private final Supplier<ColumnarInts> encodedValuesSupplier;
private final ColumnarLongs valueColumn;
private final ImmutableBitmap nullValueBitmap;
private final ImmutableBitmap nullValueIndex;
private final BitmapFactory bitmapFactory;
public ScalarLongColumn(
FixedIndexed<Long> longDictionary,
Supplier<ColumnarInts> encodedValuesSupplier,
ColumnarLongs valueColumn,
ImmutableBitmap nullValueBitmap,
ImmutableBitmap nullValueIndex,
BitmapFactory bitmapFactory
)
{
this.longDictionary = longDictionary;
this.encodedValuesSupplier = encodedValuesSupplier;
this.valueColumn = valueColumn;
this.nullValueBitmap = nullValueBitmap;
this.nullValueIndex = nullValueIndex;
this.bitmapFactory = bitmapFactory;
}
@ -91,7 +91,7 @@ public class ScalarLongColumn implements NestedCommonFormatColumn
{
return new LongColumnSelector()
{
private PeekableIntIterator nullIterator = nullValueBitmap.peekableIterator();
private PeekableIntIterator nullIterator = nullValueIndex.peekableIterator();
private int nullMark = -1;
private int offsetMark = -1;
@ -105,7 +105,7 @@ public class ScalarLongColumn implements NestedCommonFormatColumn
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
inspector.visit("longColumn", valueColumn);
inspector.visit("nullBitmap", nullValueBitmap);
inspector.visit("nullBitmap", nullValueIndex);
}
@Override
@ -118,7 +118,7 @@ public class ScalarLongColumn implements NestedCommonFormatColumn
if (i < offsetMark) {
// offset was reset, reset iterator state
nullMark = -1;
nullIterator = nullValueBitmap.peekableIterator();
nullIterator = nullValueIndex.peekableIterator();
}
offsetMark = i;
if (nullMark < i) {
@ -143,7 +143,7 @@ public class ScalarLongColumn implements NestedCommonFormatColumn
private int id = ReadableVectorInspector.NULL_ID;
@Nullable
private PeekableIntIterator nullIterator = nullValueBitmap.peekableIterator();
private PeekableIntIterator nullIterator = nullValueIndex.peekableIterator();
private int offsetMark = -1;
@Override
@ -172,14 +172,14 @@ public class ScalarLongColumn implements NestedCommonFormatColumn
if (offset.isContiguous()) {
if (offset.getStartOffset() < offsetMark) {
nullIterator = nullValueBitmap.peekableIterator();
nullIterator = nullValueIndex.peekableIterator();
}
offsetMark = offset.getStartOffset() + offset.getCurrentVectorSize();
valueColumn.get(valueVector, offset.getStartOffset(), offset.getCurrentVectorSize());
} else {
final int[] offsets = offset.getOffsets();
if (offsets[offsets.length - 1] < offsetMark) {
nullIterator = nullValueBitmap.peekableIterator();
nullIterator = nullValueIndex.peekableIterator();
}
offsetMark = offsets[offsets.length - 1];
valueColumn.get(valueVector, offsets, offset.getCurrentVectorSize());

View File

@ -423,8 +423,9 @@ public class VariantColumnSerializer extends NestedCommonFormatColumnSerializer
}
/**
* Internal serializer used to serailize a {@link VariantColumn}. Contains the logic to write out the column to a
* {@link FileSmoosher}. Created by {@link VariantColumnSerializer} once it is closed for writes.
* Internal serializer used to serialize a {@link VariantColumn}. Encapsulates just the logic to write out the column
* to a {@link FileSmoosher} without the parts to update the dictionaries themselves, so that it can be reused.
* Created by {@link VariantColumnSerializer} once it is closed for writes.
*/
public static class InternalSerializer implements Serializer
{
@ -475,18 +476,20 @@ public class VariantColumnSerializer extends NestedCommonFormatColumnSerializer
this.writeDictionary = writeDictionary;
this.dictionaryIdLookup = dictionaryIdLookup;
boolean[] dictionariesSorted = new boolean[]{
dictionaryWriter.isSorted(),
longDictionaryWriter.isSorted(),
doubleDictionaryWriter.isSorted(),
arrayDictionaryWriter.isSorted()
};
for (boolean sorted : dictionariesSorted) {
if (writeDictionary && !sorted) {
throw DruidException.defensive(
"Dictionary is not sorted? [%s] Should always be sorted",
Arrays.toString(dictionariesSorted)
);
if (writeDictionary) {
boolean[] dictionariesSorted = new boolean[]{
dictionaryWriter.isSorted(),
longDictionaryWriter.isSorted(),
doubleDictionaryWriter.isSorted(),
arrayDictionaryWriter.isSorted()
};
for (boolean sorted : dictionariesSorted) {
if (!sorted) {
throw DruidException.defensive(
"Dictionary is not sorted? [%s] Should always be sorted",
Arrays.toString(dictionariesSorted)
);
}
}
}
}