public class BinaryStringUtils extends Object
BinaryString.| 限定符和类型 | 字段和说明 |
|---|---|
static BinaryString[] |
EMPTY_STRING_ARRAY |
static BinaryString |
FALSE_STRING |
static BinaryString |
NULL_STRING |
static BinaryString |
TRUE_STRING |
| 构造器和说明 |
|---|
BinaryStringUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
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.
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.
public static short toShort(BinaryString str) throws NumberFormatException
public static byte toByte(BinaryString str) throws NumberFormatException
public static double toDouble(BinaryString str) throws NumberFormatException
public static float toFloat(BinaryString str) throws NumberFormatException
public static int toDate(BinaryString input) throws java.time.DateTimeException
java.time.DateTimeExceptionpublic static int toTime(BinaryString input) throws java.time.DateTimeException
java.time.DateTimeExceptionpublic static Timestamp toTimestamp(BinaryString input, int precision) throws java.time.DateTimeException
CAST(x as TIMESTAMP).java.time.DateTimeExceptionpublic static Timestamp toTimestamp(BinaryString input, int precision, TimeZone timeZone) throws java.time.DateTimeException
CAST(x as TIMESTAMP_LTZ).java.time.DateTimeExceptionpublic 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.