Package org.apache.druid.frame.write
Class FrameWriterUtils
- java.lang.Object
-
- org.apache.druid.frame.write.FrameWriterUtils
-
public class FrameWriterUtils extends Object
Utility methods used byFrameWriter
implementations.
-
-
Field Summary
Fields Modifier and Type Field Description static byte
NULL_STRING_MARKER
static byte[]
NULL_STRING_MARKER_ARRAY
static String
RESERVED_FIELD_PREFIX
-
Constructor Summary
Constructors Constructor Description FrameWriterUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
copyByteBufferToMemory(ByteBuffer src, org.apache.datasketches.memory.WritableMemory dst, long dstPosition, int len, boolean allowNullBytes)
Copies "len" bytes fromsrc.position()
to "dstPosition" in "memory".static Set<String>
findDisallowedFieldNames(RowSignature signature)
Checks the provided signature for any disallowed field names.static List<? extends Number>
getNumericArrayFromObject(Object row)
Retrieves a numeric list from a Java object, given that the object is an instance of something that can be returned fromBaseObjectColumnValueSelector.getObject()
of valid numeric array selectors representations WhileBaseObjectColumnValueSelector
specifies that only instances ofObject[]
can be returned from the numeric array selectors, this method also handles a few more cases which can be encountered if the selector is directly implemented on top of the group by stuffstatic 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.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 anSTRING
column.static RowSignature
replaceUnknownTypesWithNestedColumns(RowSignature rowSignature)
static void
verifySortColumns(List<KeyColumn> keyColumns, RowSignature signature)
Verifies whether the provided sortColumns are all sortable, and are a prefix of the signature.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.
-
-
-
Field Detail
-
NULL_STRING_MARKER
public static final byte NULL_STRING_MARKER
- See Also:
- Constant Field Values
-
NULL_STRING_MARKER_ARRAY
public static final byte[] NULL_STRING_MARKER_ARRAY
-
RESERVED_FIELD_PREFIX
public static final String RESERVED_FIELD_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
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 anSTRING
column. 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_ARRAY
depending on the value of "useNullArrays".- Parameters:
selector
- array selector- Returns:
- UTF-8 strings. The list itself may be null.
-
getNumericArrayFromObject
@Nullable public static List<? extends Number> getNumericArrayFromObject(Object row)
Retrieves a numeric list from a Java object, given that the object is an instance of something that can be returned fromBaseObjectColumnValueSelector.getObject()
of valid numeric array selectors representations WhileBaseObjectColumnValueSelector
specifies that only instances ofObject[]
can be returned from the numeric array selectors, this method also handles a few more cases which can be encountered if the selector is directly implemented on top of the group by stuff
-
findDisallowedFieldNames
public static Set<String> findDisallowedFieldNames(RowSignature signature)
Checks the provided signature for any disallowed field names. Returns any that are found.
-
verifySortColumns
public static void verifySortColumns(List<KeyColumn> keyColumns, RowSignature signature)
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
-
copyByteBufferToMemory
public static void copyByteBufferToMemory(ByteBuffer src, org.apache.datasketches.memory.WritableMemory dst, long dstPosition, int len, boolean allowNullBytes)
Copies "len" bytes fromsrc.position()
to "dstPosition" in "memory". Does not update the position of src.- Throws:
InvalidNullByteException
- if "allowNullBytes" is false and a null byte is encountered
-
replaceUnknownTypesWithNestedColumns
public static RowSignature replaceUnknownTypesWithNestedColumns(RowSignature rowSignature)
-
-