Class NumericArrayFrameColumnWriter
- java.lang.Object
-
- org.apache.druid.frame.write.columnar.NumericArrayFrameColumnWriter
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,FrameColumnWriter
- Direct Known Subclasses:
DoubleArrayFrameColumnWriter
,FloatArrayFrameColumnWriter
,LongArrayFrameColumnWriter
public abstract class NumericArrayFrameColumnWriter extends Object implements FrameColumnWriter
Parent class for the family of writers writing numeric arrays in columnar frames. Since the numeric primitives are fixed width, we don't need to store the width of each element. The memory layout of a column written by this writer is as follows: n : Total number of rows k : Total number of elements in all the rows, cumulative | Section | Length of the section | Denotion | |---------|-----------------------|--------------------------------------------------------------------------------------| | 0 | 1 | typeCode | | 1 | n * Integer.BYTES | n integers, where i-th integer represents the cumulative length of the array | | 2 | k * Byte.BYTES | k bytes, where i-th byte represent whether the i-th value from the start is null | | 3 | k * ELEMENT_SIZE | k values, each representing the element, or null equivalent value (e.g 0 for double) | Note on cumulative lengths stored in section 1: Cumulative lengths are stored so that its fast to offset into the elements of the array. We also use negative cumulative length to denote that the array itself is null (as opposed to individual elements being null, which we store in section 2)
-
-
Field Summary
Fields Modifier and Type Field Description static long
DATA_OFFSET
A byte required at the beginning for type codestatic byte
NON_NULL_ELEMENT_MARKER
static byte
NULL_ELEMENT_MARKER
-
Constructor Summary
Constructors Constructor Description NumericArrayFrameColumnWriter(ColumnValueSelector selector, MemoryAllocator allocator, byte typeCode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addSelection()
Adds the current value to the writervoid
close()
long
size()
Size (in bytes) of the column data that will get written whenFrameColumnWriter.writeTo(org.apache.datasketches.memory.WritableMemory, long)
will be calledvoid
undo()
Reverts the last added value.long
writeTo(org.apache.datasketches.memory.WritableMemory memory, long startPosition)
Writes the value of the column to the provided memory at the given position
-
-
-
Field Detail
-
NULL_ELEMENT_MARKER
public static final byte NULL_ELEMENT_MARKER
- See Also:
- Constant Field Values
-
NON_NULL_ELEMENT_MARKER
public static final byte NON_NULL_ELEMENT_MARKER
- See Also:
- Constant Field Values
-
DATA_OFFSET
public static final long DATA_OFFSET
A byte required at the beginning for type code- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NumericArrayFrameColumnWriter
public NumericArrayFrameColumnWriter(ColumnValueSelector selector, MemoryAllocator allocator, byte typeCode)
-
-
Method Detail
-
addSelection
public boolean addSelection()
Description copied from interface:FrameColumnWriter
Adds the current value to the writer- Specified by:
addSelection
in interfaceFrameColumnWriter
-
undo
public void undo()
Description copied from interface:FrameColumnWriter
Reverts the last added value. Undo calls cannot be called in successsion- Specified by:
undo
in interfaceFrameColumnWriter
-
size
public long size()
Description copied from interface:FrameColumnWriter
Size (in bytes) of the column data that will get written whenFrameColumnWriter.writeTo(org.apache.datasketches.memory.WritableMemory, long)
will be called- Specified by:
size
in interfaceFrameColumnWriter
-
writeTo
public long writeTo(org.apache.datasketches.memory.WritableMemory memory, long startPosition)
Description copied from interface:FrameColumnWriter
Writes the value of the column to the provided memory at the given position- Specified by:
writeTo
in interfaceFrameColumnWriter
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceFrameColumnWriter
-
-