Package org.apache.druid.frame.write
Class FrameWriterUtils
java.lang.Object
org.apache.druid.frame.write.FrameWriterUtils
Utility methods used by
FrameWriter implementations.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyByteBufferToMemoryAllowingNullBytes(ByteBuffer src, org.apache.datasketches.memory.WritableMemory dst, long dstPosition, int len) Copiessrctodstwithout making any modification to the source data.static intcopyByteBufferToMemoryDisallowingNullBytes(ByteBuffer src, org.apache.datasketches.memory.WritableMemory dst, long dstPosition, int len, boolean removeNullBytes) Copiessrctodst, disallowing null bytes to be written to the destination.findDisallowedFieldNames(RowSignature signature) Checks the provided signature for any disallowed field names.static List<ByteBuffer> Retrieves UTF-8 byte buffers from aColumnValueSelector, which is expected to be the kind of selector you get for anARRAY<STRING>column.static List<ByteBuffer> getUtf8ByteBuffersFromStringSelector(DimensionSelector selector, boolean multiValue) Retrieves UTF-8 byte buffers from aDimensionSelector, which is expected to be the kind of selector you get for anSTRINGcolumn.static RowSignaturereplaceUnknownTypesWithNestedColumns(RowSignature rowSignature) static voidverifySortColumns(List<KeyColumn> keyColumns, RowSignature signature) Verifies whether the provided sortColumns are all sortable, and are a prefix of the signature.static longwriteFrameHeader(org.apache.datasketches.memory.WritableMemory memory, long startPosition, FrameType frameType, long totalSize, int numRows, int numRegions, boolean permuted) Writes a frame header to a memory locations.
-
Field Details
-
NULL_STRING_MARKER
public static final byte NULL_STRING_MARKER- See Also:
-
NULL_STRING_MARKER_ARRAY
public static final byte[] NULL_STRING_MARKER_ARRAY -
RESERVED_FIELD_PREFIX
- See Also:
-
-
Constructor Details
-
FrameWriterUtils
public FrameWriterUtils()
-
-
Method Details
-
writeFrameHeader
public static long writeFrameHeader(org.apache.datasketches.memory.WritableMemory memory, long startPosition, FrameType frameType, long totalSize, int numRows, int numRegions, boolean permuted) Writes a frame header to a memory locations. -
getUtf8ByteBuffersFromStringSelector
public static List<ByteBuffer> getUtf8ByteBuffersFromStringSelector(DimensionSelector selector, boolean multiValue) Retrieves UTF-8 byte buffers from aDimensionSelector, which is expected to be the kind of selector you get for anSTRINGcolumn. Null strings are returned asNULL_STRING_MARKER_ARRAY.- Parameters:
selector- the selectormultiValue- if true, return an array that corresponds exactly toDimensionSelector.getRow(). if false, always return a single-valued array. In particular, this means [] is returned as [NULL_STRING_MARKER_ARRAY].- Returns:
- UTF-8 strings. The list itself is never null.
-
getUtf8ByteBuffersFromStringArraySelector
@Nullable public static List<ByteBuffer> getUtf8ByteBuffersFromStringArraySelector(BaseObjectColumnValueSelector selector) Retrieves UTF-8 byte buffers from aColumnValueSelector, which is expected to be the kind of selector you get for anARRAY<STRING>column. Null strings are returned asnull. If the entire array returned byBaseObjectColumnValueSelector.getObject()is null, returns either null orNULL_STRING_MARKER_ARRAYdepending on the value of "useNullArrays".- Parameters:
selector- array selector- Returns:
- UTF-8 strings. The list itself may be null.
-
findDisallowedFieldNames
Checks the provided signature for any disallowed field names. Returns any that are found. -
verifySortColumns
Verifies whether the provided sortColumns are all sortable, and are a prefix of the signature. This is required because it allows us to treat the sort key as a chunk of bytes. Exits quietly if the sort columns are OK. Throws an exception if there is a problem.- Throws:
IllegalArgumentException- if there is a problem
-
copyByteBufferToMemoryAllowingNullBytes
public static void copyByteBufferToMemoryAllowingNullBytes(ByteBuffer src, org.apache.datasketches.memory.WritableMemory dst, long dstPosition, int len) Copiessrctodstwithout making any modification to the source data. -
copyByteBufferToMemoryDisallowingNullBytes
public static int copyByteBufferToMemoryDisallowingNullBytes(ByteBuffer src, org.apache.datasketches.memory.WritableMemory dst, long dstPosition, int len, boolean removeNullBytes) Copiessrctodst, disallowing null bytes to be written to the destination. IfremoveNullBytesis true, the method will drop the null bytes, and if it is false, the method will throw an exception. The written bytes can be less than "len" if the null bytes are dropped, and the callers must evaluate the return value to see the actual length of the buffer that is copied -
replaceUnknownTypesWithNestedColumns
-