Class NumericArrayFrameColumnWriter
java.lang.Object
org.apache.druid.frame.write.columnar.NumericArrayFrameColumnWriter
- All Implemented Interfaces:
Closeable,AutoCloseable,FrameColumnWriter
- Direct Known Subclasses:
DoubleArrayFrameColumnWriter,FloatArrayFrameColumnWriter,LongArrayFrameColumnWriter
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
FieldsModifier and TypeFieldDescriptionstatic final longA byte required at the beginning for type codestatic final bytestatic final byte -
Constructor Summary
ConstructorsConstructorDescriptionNumericArrayFrameColumnWriter(ColumnValueSelector selector, MemoryAllocator allocator, byte typeCode) -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the current value to the writervoidclose()longsize()Size (in bytes) of the column data that will get written whenFrameColumnWriter.writeTo(org.apache.datasketches.memory.WritableMemory, long)will be calledvoidundo()Reverts the last added value.longwriteTo(org.apache.datasketches.memory.WritableMemory memory, long startPosition) Writes the value of the column to the provided memory at the given position
-
Field Details
-
NULL_ELEMENT_MARKER
public static final byte NULL_ELEMENT_MARKER- See Also:
-
NON_NULL_ELEMENT_MARKER
public static final byte NON_NULL_ELEMENT_MARKER- See Also:
-
DATA_OFFSET
public static final long DATA_OFFSETA byte required at the beginning for type code- See Also:
-
-
Constructor Details
-
NumericArrayFrameColumnWriter
public NumericArrayFrameColumnWriter(ColumnValueSelector selector, MemoryAllocator allocator, byte typeCode)
-
-
Method Details
-
addSelection
public boolean addSelection()Description copied from interface:FrameColumnWriterAdds the current value to the writer- Specified by:
addSelectionin interfaceFrameColumnWriter
-
undo
public void undo()Description copied from interface:FrameColumnWriterReverts the last added value. Undo calls cannot be called in successsion- Specified by:
undoin interfaceFrameColumnWriter
-
size
public long size()Description copied from interface:FrameColumnWriterSize (in bytes) of the column data that will get written whenFrameColumnWriter.writeTo(org.apache.datasketches.memory.WritableMemory, long)will be called- Specified by:
sizein interfaceFrameColumnWriter
-
writeTo
public long writeTo(org.apache.datasketches.memory.WritableMemory memory, long startPosition) Description copied from interface:FrameColumnWriterWrites the value of the column to the provided memory at the given position- Specified by:
writeToin interfaceFrameColumnWriter
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceFrameColumnWriter
-