public class BinaryStringUtils extends Object
BinaryString
.Modifier and Type | Field and Description |
---|---|
static BinaryString[] |
EMPTY_STRING_ARRAY |
static BinaryString |
FALSE_STRING |
static BinaryString |
NULL_STRING |
static BinaryString |
TRUE_STRING |
Constructor and Description |
---|
BinaryStringUtils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
toBinaryString(byte[] byteArrayTerm,
DataType type) |
static boolean |
toBoolean(BinaryString str)
Parse a
BinaryString to boolean. |
static byte |
toByte(BinaryString str) |
static BinaryString |
toCharacterString(BinaryString strData,
DataType type) |
static int |
toDate(BinaryString input) |
static double |
toDouble(BinaryString str) |
static float |
toFloat(BinaryString str) |
static int |
toInt(BinaryString str)
Parses this BinaryString to Int.
|
static long |
toLong(BinaryString str)
Parses this BinaryString to Long.
|
static short |
toShort(BinaryString str) |
static int |
toTime(BinaryString input) |
static Timestamp |
toTimestamp(BinaryString input,
int precision)
Used by
CAST(x as TIMESTAMP) . |
static Timestamp |
toTimestamp(BinaryString input,
int precision,
TimeZone timeZone)
Used by
CAST(x as TIMESTAMP_LTZ) . |
public static final BinaryString NULL_STRING
public static final BinaryString TRUE_STRING
public static final BinaryString FALSE_STRING
public static final BinaryString[] EMPTY_STRING_ARRAY
public static boolean toBoolean(BinaryString str)
BinaryString
to boolean.public static long toLong(BinaryString str) throws NumberFormatException
Note that, in this method we accumulate the result in negative format, and convert it to positive format at the end, if this string is not started with '-'. This is because min value is bigger than max value in digits, e.g. Long.MAX_VALUE is '9223372036854775807' and Long.MIN_VALUE is '-9223372036854775808'.
This code is mostly copied from LazyLong.parseLong in Hive.
NumberFormatException
public static int toInt(BinaryString str) throws NumberFormatException
Note that, in this method we accumulate the result in negative format, and convert it to positive format at the end, if this string is not started with '-'. This is because min value is bigger than max value in digits, e.g. Integer.MAX_VALUE is '2147483647' and Integer.MIN_VALUE is '-2147483648'.
This code is mostly copied from LazyInt.parseInt in Hive.
Note that, this method is almost same as `toLong`, but we leave it duplicated for performance reasons, like Hive does.
NumberFormatException
public static short toShort(BinaryString str) throws NumberFormatException
NumberFormatException
public static byte toByte(BinaryString str) throws NumberFormatException
NumberFormatException
public static double toDouble(BinaryString str) throws NumberFormatException
NumberFormatException
public static float toFloat(BinaryString str) throws NumberFormatException
NumberFormatException
public static int toDate(BinaryString input) throws java.time.DateTimeException
java.time.DateTimeException
public static int toTime(BinaryString input) throws java.time.DateTimeException
java.time.DateTimeException
public static Timestamp toTimestamp(BinaryString input, int precision) throws java.time.DateTimeException
CAST(x as TIMESTAMP)
.java.time.DateTimeException
public static Timestamp toTimestamp(BinaryString input, int precision, TimeZone timeZone) throws java.time.DateTimeException
CAST(x as TIMESTAMP_LTZ)
.java.time.DateTimeException
public static BinaryString toCharacterString(BinaryString strData, DataType type)
public static byte[] toBinaryString(byte[] byteArrayTerm, DataType type)
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.