public class GenericVariantUtil extends Object
A variant is made up of 2 binaries: value and metadata. A variant value consists of a one-byte header and a number of content bytes (can be zero). The header byte is divided into upper 6 bits (called "type info") and lower 2 bits (called "basic type"). The content format is explained in the below constants for all possible basic type and type info values.
The variant metadata includes a version id and a dictionary of distinct strings (case-sensitive). Its binary format is: - Version: 1-byte unsigned integer. The only acceptable value is 1 currently. - Dictionary size: 4-byte little-endian unsigned integer. The number of keys in the dictionary. - Offsets: (size + 1) * 4-byte little-endian unsigned integers. `offsets[i]` represents the starting position of string i, counting starting from the address of `offsets[0]`. Strings must be stored contiguously, so we don’t need to store the string size, instead, we compute it with `offset[i + 1] - offset[i]`. - UTF-8 string data.
Modifier and Type | Class and Description |
---|---|
static interface |
GenericVariantUtil.ArrayHandler<T>
1.
|
static interface |
GenericVariantUtil.ObjectHandler<T>
1.
|
static class |
GenericVariantUtil.Type
The value type of variant value.
|
Modifier and Type | Field and Description |
---|---|
static int |
ARRAY |
static int |
BASIC_TYPE_BITS |
static int |
BASIC_TYPE_MASK |
static int |
BINARY |
static int |
BINARY_SEARCH_THRESHOLD |
static int |
DATE |
static int |
DECIMAL16 |
static int |
DECIMAL4 |
static int |
DECIMAL8 |
static int |
DOUBLE |
static int |
FALSE |
static int |
FLOAT |
static int |
INT1 |
static int |
INT2 |
static int |
INT4 |
static int |
INT8 |
static int |
LONG_STR |
static int |
MAX_DECIMAL16_PRECISION |
static int |
MAX_DECIMAL4_PRECISION |
static int |
MAX_DECIMAL8_PRECISION |
static int |
MAX_SHORT_STR_SIZE |
static int |
NULL |
static int |
OBJECT |
static int |
PRIMITIVE |
static int |
SHORT_STR |
static int |
SIZE_LIMIT |
static int |
TIMESTAMP |
static int |
TIMESTAMP_NTZ |
static int |
TRUE |
static int |
TYPE_INFO_MASK |
static int |
U16_MAX |
static int |
U24_MAX |
static int |
U24_SIZE |
static int |
U32_SIZE |
static int |
U8_MAX |
static byte |
VERSION |
static byte |
VERSION_MASK |
Constructor and Description |
---|
GenericVariantUtil() |
Modifier and Type | Method and Description |
---|---|
static byte |
arrayHeader(boolean largeSize,
int offsetSize) |
static byte[] |
getBinary(byte[] value,
int pos) |
static boolean |
getBoolean(byte[] value,
int pos) |
static BigDecimal |
getDecimal(byte[] value,
int pos) |
static BigDecimal |
getDecimalWithOriginalScale(byte[] value,
int pos) |
static double |
getDouble(byte[] value,
int pos) |
static float |
getFloat(byte[] value,
int pos) |
static long |
getLong(byte[] value,
int pos) |
static String |
getMetadataKey(byte[] metadata,
int id) |
static String |
getString(byte[] value,
int pos) |
static GenericVariantUtil.Type |
getType(byte[] value,
int pos) |
static int |
getTypeInfo(byte[] value,
int pos) |
static <T> T |
handleArray(byte[] value,
int pos,
GenericVariantUtil.ArrayHandler<T> handler) |
static <T> T |
handleObject(byte[] value,
int pos,
GenericVariantUtil.ObjectHandler<T> handler) |
static byte |
objectHeader(boolean largeSize,
int idSize,
int offsetSize) |
static byte |
primitiveHeader(int type) |
static byte |
shortStrHeader(int size) |
static int |
valueSize(byte[] value,
int pos) |
static void |
writeLong(byte[] bytes,
int pos,
long value,
int numBytes) |
public static final int BASIC_TYPE_BITS
public static final int BASIC_TYPE_MASK
public static final int TYPE_INFO_MASK
public static final int MAX_SHORT_STR_SIZE
public static final int PRIMITIVE
public static final int SHORT_STR
public static final int OBJECT
public static final int ARRAY
public static final int NULL
public static final int TRUE
public static final int FALSE
public static final int INT1
public static final int INT2
public static final int INT4
public static final int INT8
public static final int DOUBLE
public static final int DECIMAL4
public static final int DECIMAL8
public static final int DECIMAL16
public static final int DATE
public static final int TIMESTAMP
public static final int TIMESTAMP_NTZ
public static final int FLOAT
public static final int BINARY
public static final int LONG_STR
public static final byte VERSION
public static final byte VERSION_MASK
public static final int U8_MAX
public static final int U16_MAX
public static final int U24_MAX
public static final int U24_SIZE
public static final int U32_SIZE
public static final int SIZE_LIMIT
public static final int MAX_DECIMAL4_PRECISION
public static final int MAX_DECIMAL8_PRECISION
public static final int MAX_DECIMAL16_PRECISION
public static final int BINARY_SEARCH_THRESHOLD
public static void writeLong(byte[] bytes, int pos, long value, int numBytes)
public static byte primitiveHeader(int type)
public static byte shortStrHeader(int size)
public static byte objectHeader(boolean largeSize, int idSize, int offsetSize)
public static byte arrayHeader(boolean largeSize, int offsetSize)
public static int getTypeInfo(byte[] value, int pos)
public static GenericVariantUtil.Type getType(byte[] value, int pos)
public static int valueSize(byte[] value, int pos)
public static boolean getBoolean(byte[] value, int pos)
public static long getLong(byte[] value, int pos)
public static double getDouble(byte[] value, int pos)
public static BigDecimal getDecimalWithOriginalScale(byte[] value, int pos)
public static BigDecimal getDecimal(byte[] value, int pos)
public static float getFloat(byte[] value, int pos)
public static byte[] getBinary(byte[] value, int pos)
public static String getString(byte[] value, int pos)
public static <T> T handleObject(byte[] value, int pos, GenericVariantUtil.ObjectHandler<T> handler)
public static <T> T handleArray(byte[] value, int pos, GenericVariantUtil.ArrayHandler<T> handler)
public static String getMetadataKey(byte[] metadata, int id)
Copyright © 2023–2025 The Apache Software Foundation. All rights reserved.