mirror of
https://github.com/apache/druid.git
synced 2025-02-09 11:34:54 +00:00
Refactors (#17498)
Follow-up PR to #17493 to address pending unaddressed comments.
This commit is contained in:
parent
bd93d0046d
commit
df649c0bbd
@ -55,21 +55,21 @@ public class ScalarDoubleColumn implements NestedCommonFormatColumn
|
|||||||
private final FixedIndexed<Double> doubleDictionary;
|
private final FixedIndexed<Double> doubleDictionary;
|
||||||
private final Supplier<ColumnarInts> encodedValuesSupplier;
|
private final Supplier<ColumnarInts> encodedValuesSupplier;
|
||||||
private final ColumnarDoubles valueColumn;
|
private final ColumnarDoubles valueColumn;
|
||||||
private final ImmutableBitmap nullValueBitmap;
|
private final ImmutableBitmap nullValueIndex;
|
||||||
private final BitmapFactory bitmapFactory;
|
private final BitmapFactory bitmapFactory;
|
||||||
|
|
||||||
public ScalarDoubleColumn(
|
public ScalarDoubleColumn(
|
||||||
FixedIndexed<Double> doubleDictionary,
|
FixedIndexed<Double> doubleDictionary,
|
||||||
Supplier<ColumnarInts> encodedValuesSupplier,
|
Supplier<ColumnarInts> encodedValuesSupplier,
|
||||||
ColumnarDoubles valueColumn,
|
ColumnarDoubles valueColumn,
|
||||||
ImmutableBitmap nullValueBitmap,
|
ImmutableBitmap nullValueIndex,
|
||||||
BitmapFactory bitmapFactory
|
BitmapFactory bitmapFactory
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.doubleDictionary = doubleDictionary;
|
this.doubleDictionary = doubleDictionary;
|
||||||
this.encodedValuesSupplier = encodedValuesSupplier;
|
this.encodedValuesSupplier = encodedValuesSupplier;
|
||||||
this.valueColumn = valueColumn;
|
this.valueColumn = valueColumn;
|
||||||
this.nullValueBitmap = nullValueBitmap;
|
this.nullValueIndex = nullValueIndex;
|
||||||
this.bitmapFactory = bitmapFactory;
|
this.bitmapFactory = bitmapFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ public class ScalarDoubleColumn implements NestedCommonFormatColumn
|
|||||||
{
|
{
|
||||||
return new DoubleColumnSelector()
|
return new DoubleColumnSelector()
|
||||||
{
|
{
|
||||||
private PeekableIntIterator nullIterator = nullValueBitmap.peekableIterator();
|
private PeekableIntIterator nullIterator = nullValueIndex.peekableIterator();
|
||||||
private int nullMark = -1;
|
private int nullMark = -1;
|
||||||
private int offsetMark = -1;
|
private int offsetMark = -1;
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ public class ScalarDoubleColumn implements NestedCommonFormatColumn
|
|||||||
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
|
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
|
||||||
{
|
{
|
||||||
inspector.visit("doubleColumn", valueColumn);
|
inspector.visit("doubleColumn", valueColumn);
|
||||||
inspector.visit("nullBitmap", nullValueBitmap);
|
inspector.visit("nullBitmap", nullValueIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -117,7 +117,7 @@ public class ScalarDoubleColumn implements NestedCommonFormatColumn
|
|||||||
if (i < offsetMark) {
|
if (i < offsetMark) {
|
||||||
// offset was reset, reset iterator state
|
// offset was reset, reset iterator state
|
||||||
nullMark = -1;
|
nullMark = -1;
|
||||||
nullIterator = nullValueBitmap.peekableIterator();
|
nullIterator = nullValueIndex.peekableIterator();
|
||||||
}
|
}
|
||||||
offsetMark = i;
|
offsetMark = i;
|
||||||
if (nullMark < i) {
|
if (nullMark < i) {
|
||||||
@ -142,7 +142,7 @@ public class ScalarDoubleColumn implements NestedCommonFormatColumn
|
|||||||
private int id = ReadableVectorInspector.NULL_ID;
|
private int id = ReadableVectorInspector.NULL_ID;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private PeekableIntIterator nullIterator = nullValueBitmap != null ? nullValueBitmap.peekableIterator() : null;
|
private PeekableIntIterator nullIterator = nullValueIndex != null ? nullValueIndex.peekableIterator() : null;
|
||||||
private int offsetMark = -1;
|
private int offsetMark = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -171,14 +171,14 @@ public class ScalarDoubleColumn implements NestedCommonFormatColumn
|
|||||||
|
|
||||||
if (offset.isContiguous()) {
|
if (offset.isContiguous()) {
|
||||||
if (offset.getStartOffset() < offsetMark) {
|
if (offset.getStartOffset() < offsetMark) {
|
||||||
nullIterator = nullValueBitmap.peekableIterator();
|
nullIterator = nullValueIndex.peekableIterator();
|
||||||
}
|
}
|
||||||
offsetMark = offset.getStartOffset() + offset.getCurrentVectorSize();
|
offsetMark = offset.getStartOffset() + offset.getCurrentVectorSize();
|
||||||
valueColumn.get(valueVector, offset.getStartOffset(), offset.getCurrentVectorSize());
|
valueColumn.get(valueVector, offset.getStartOffset(), offset.getCurrentVectorSize());
|
||||||
} else {
|
} else {
|
||||||
final int[] offsets = offset.getOffsets();
|
final int[] offsets = offset.getOffsets();
|
||||||
if (offsets[offsets.length - 1] < offsetMark) {
|
if (offsets[offsets.length - 1] < offsetMark) {
|
||||||
nullIterator = nullValueBitmap.peekableIterator();
|
nullIterator = nullValueIndex.peekableIterator();
|
||||||
}
|
}
|
||||||
offsetMark = offsets[offsets.length - 1];
|
offsetMark = offsets[offsets.length - 1];
|
||||||
valueColumn.get(valueVector, offsets, offset.getCurrentVectorSize());
|
valueColumn.get(valueVector, offsets, offset.getCurrentVectorSize());
|
||||||
|
@ -55,21 +55,21 @@ public class ScalarLongColumn implements NestedCommonFormatColumn
|
|||||||
private final FixedIndexed<Long> longDictionary;
|
private final FixedIndexed<Long> longDictionary;
|
||||||
private final Supplier<ColumnarInts> encodedValuesSupplier;
|
private final Supplier<ColumnarInts> encodedValuesSupplier;
|
||||||
private final ColumnarLongs valueColumn;
|
private final ColumnarLongs valueColumn;
|
||||||
private final ImmutableBitmap nullValueBitmap;
|
private final ImmutableBitmap nullValueIndex;
|
||||||
private final BitmapFactory bitmapFactory;
|
private final BitmapFactory bitmapFactory;
|
||||||
|
|
||||||
public ScalarLongColumn(
|
public ScalarLongColumn(
|
||||||
FixedIndexed<Long> longDictionary,
|
FixedIndexed<Long> longDictionary,
|
||||||
Supplier<ColumnarInts> encodedValuesSupplier,
|
Supplier<ColumnarInts> encodedValuesSupplier,
|
||||||
ColumnarLongs valueColumn,
|
ColumnarLongs valueColumn,
|
||||||
ImmutableBitmap nullValueBitmap,
|
ImmutableBitmap nullValueIndex,
|
||||||
BitmapFactory bitmapFactory
|
BitmapFactory bitmapFactory
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.longDictionary = longDictionary;
|
this.longDictionary = longDictionary;
|
||||||
this.encodedValuesSupplier = encodedValuesSupplier;
|
this.encodedValuesSupplier = encodedValuesSupplier;
|
||||||
this.valueColumn = valueColumn;
|
this.valueColumn = valueColumn;
|
||||||
this.nullValueBitmap = nullValueBitmap;
|
this.nullValueIndex = nullValueIndex;
|
||||||
this.bitmapFactory = bitmapFactory;
|
this.bitmapFactory = bitmapFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ public class ScalarLongColumn implements NestedCommonFormatColumn
|
|||||||
{
|
{
|
||||||
return new LongColumnSelector()
|
return new LongColumnSelector()
|
||||||
{
|
{
|
||||||
private PeekableIntIterator nullIterator = nullValueBitmap.peekableIterator();
|
private PeekableIntIterator nullIterator = nullValueIndex.peekableIterator();
|
||||||
private int nullMark = -1;
|
private int nullMark = -1;
|
||||||
private int offsetMark = -1;
|
private int offsetMark = -1;
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ public class ScalarLongColumn implements NestedCommonFormatColumn
|
|||||||
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
|
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
|
||||||
{
|
{
|
||||||
inspector.visit("longColumn", valueColumn);
|
inspector.visit("longColumn", valueColumn);
|
||||||
inspector.visit("nullBitmap", nullValueBitmap);
|
inspector.visit("nullBitmap", nullValueIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -118,7 +118,7 @@ public class ScalarLongColumn implements NestedCommonFormatColumn
|
|||||||
if (i < offsetMark) {
|
if (i < offsetMark) {
|
||||||
// offset was reset, reset iterator state
|
// offset was reset, reset iterator state
|
||||||
nullMark = -1;
|
nullMark = -1;
|
||||||
nullIterator = nullValueBitmap.peekableIterator();
|
nullIterator = nullValueIndex.peekableIterator();
|
||||||
}
|
}
|
||||||
offsetMark = i;
|
offsetMark = i;
|
||||||
if (nullMark < i) {
|
if (nullMark < i) {
|
||||||
@ -143,7 +143,7 @@ public class ScalarLongColumn implements NestedCommonFormatColumn
|
|||||||
private int id = ReadableVectorInspector.NULL_ID;
|
private int id = ReadableVectorInspector.NULL_ID;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private PeekableIntIterator nullIterator = nullValueBitmap.peekableIterator();
|
private PeekableIntIterator nullIterator = nullValueIndex.peekableIterator();
|
||||||
private int offsetMark = -1;
|
private int offsetMark = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -172,14 +172,14 @@ public class ScalarLongColumn implements NestedCommonFormatColumn
|
|||||||
|
|
||||||
if (offset.isContiguous()) {
|
if (offset.isContiguous()) {
|
||||||
if (offset.getStartOffset() < offsetMark) {
|
if (offset.getStartOffset() < offsetMark) {
|
||||||
nullIterator = nullValueBitmap.peekableIterator();
|
nullIterator = nullValueIndex.peekableIterator();
|
||||||
}
|
}
|
||||||
offsetMark = offset.getStartOffset() + offset.getCurrentVectorSize();
|
offsetMark = offset.getStartOffset() + offset.getCurrentVectorSize();
|
||||||
valueColumn.get(valueVector, offset.getStartOffset(), offset.getCurrentVectorSize());
|
valueColumn.get(valueVector, offset.getStartOffset(), offset.getCurrentVectorSize());
|
||||||
} else {
|
} else {
|
||||||
final int[] offsets = offset.getOffsets();
|
final int[] offsets = offset.getOffsets();
|
||||||
if (offsets[offsets.length - 1] < offsetMark) {
|
if (offsets[offsets.length - 1] < offsetMark) {
|
||||||
nullIterator = nullValueBitmap.peekableIterator();
|
nullIterator = nullValueIndex.peekableIterator();
|
||||||
}
|
}
|
||||||
offsetMark = offsets[offsets.length - 1];
|
offsetMark = offsets[offsets.length - 1];
|
||||||
valueColumn.get(valueVector, offsets, offset.getCurrentVectorSize());
|
valueColumn.get(valueVector, offsets, offset.getCurrentVectorSize());
|
||||||
|
@ -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
|
* Internal serializer used to serialize a {@link VariantColumn}. Encapsulates just the logic to write out the column
|
||||||
* {@link FileSmoosher}. Created by {@link VariantColumnSerializer} once it is closed for writes.
|
* 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
|
public static class InternalSerializer implements Serializer
|
||||||
{
|
{
|
||||||
@ -475,6 +476,7 @@ public class VariantColumnSerializer extends NestedCommonFormatColumnSerializer
|
|||||||
this.writeDictionary = writeDictionary;
|
this.writeDictionary = writeDictionary;
|
||||||
this.dictionaryIdLookup = dictionaryIdLookup;
|
this.dictionaryIdLookup = dictionaryIdLookup;
|
||||||
|
|
||||||
|
if (writeDictionary) {
|
||||||
boolean[] dictionariesSorted = new boolean[]{
|
boolean[] dictionariesSorted = new boolean[]{
|
||||||
dictionaryWriter.isSorted(),
|
dictionaryWriter.isSorted(),
|
||||||
longDictionaryWriter.isSorted(),
|
longDictionaryWriter.isSorted(),
|
||||||
@ -482,7 +484,7 @@ public class VariantColumnSerializer extends NestedCommonFormatColumnSerializer
|
|||||||
arrayDictionaryWriter.isSorted()
|
arrayDictionaryWriter.isSorted()
|
||||||
};
|
};
|
||||||
for (boolean sorted : dictionariesSorted) {
|
for (boolean sorted : dictionariesSorted) {
|
||||||
if (writeDictionary && !sorted) {
|
if (!sorted) {
|
||||||
throw DruidException.defensive(
|
throw DruidException.defensive(
|
||||||
"Dictionary is not sorted? [%s] Should always be sorted",
|
"Dictionary is not sorted? [%s] Should always be sorted",
|
||||||
Arrays.toString(dictionariesSorted)
|
Arrays.toString(dictionariesSorted)
|
||||||
@ -490,6 +492,7 @@ public class VariantColumnSerializer extends NestedCommonFormatColumnSerializer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSerializedSize()
|
public long getSerializedSize()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user