public class BinaryStringDataUtil extends Object
BinaryStringData
.Modifier and Type | Field and Description |
---|---|
static BinaryStringData[] |
EMPTY_STRING_ARRAY |
Constructor and Description |
---|
BinaryStringDataUtil() |
Modifier and Type | Method and Description |
---|---|
static BinaryStringData |
concat(BinaryStringData... inputs)
Concatenates input strings together into a single string.
|
static BinaryStringData |
concat(Iterable<BinaryStringData> inputs) |
static BinaryStringData |
concatWs(BinaryStringData separator,
BinaryStringData... inputs)
Concatenates input strings together into a single string using the separator.
|
static BinaryStringData |
concatWs(BinaryStringData separator,
Iterable<BinaryStringData> inputs) |
static BinaryStringData |
hash(BinaryStringData str,
MessageDigest md)
Calculate the hash value of a given string use
MessageDigest . |
static BinaryStringData |
hash(BinaryStringData str,
String algorithm) |
static BinaryStringData |
hash(byte[] bytes,
MessageDigest md)
Calculate the hash value of the given bytes use
MessageDigest . |
static boolean |
isSpaceString(BinaryStringData str) |
static BinaryStringData |
keyValue(BinaryStringData str,
byte split1,
byte split2,
BinaryStringData keyName)
Parse target string as key-value string and return the value matches key name.
|
static BinaryStringData |
reverse(BinaryStringData str)
Reverse each character in current string.
|
static String |
safeToString(BinaryStringData str) |
static BinaryStringData[] |
splitByWholeSeparatorPreserveAllTokens(BinaryStringData str,
BinaryStringData separator)
Splits the provided text into an array, separator string specified.
|
static BinaryStringData |
substringSQL(BinaryStringData str,
int pos) |
static BinaryStringData |
substringSQL(BinaryStringData str,
int pos,
int length) |
static Boolean |
toBooleanSQL(BinaryStringData str)
Decide boolean representation of a string.
|
static Byte |
toByte(BinaryStringData str) |
static DecimalData |
toDecimal(BinaryStringData str,
int precision,
int scale)
Parses this BinaryStringData to DecimalData.
|
static Double |
toDouble(BinaryStringData str) |
static Float |
toFloat(BinaryStringData str) |
static Integer |
toInt(BinaryStringData str)
Parses this BinaryStringData to Int.
|
static Long |
toLong(BinaryStringData str)
Parses this BinaryStringData to Long.
|
static Short |
toShort(BinaryStringData str) |
static BinaryStringData |
trim(BinaryStringData str,
BinaryStringData trimStr)
Walk each character of current string from both ends, remove the character if it is in trim
string.
|
static BinaryStringData |
trim(BinaryStringData str,
boolean leading,
boolean trailing,
BinaryStringData seek) |
static BinaryStringData |
trimLeft(BinaryStringData str) |
static BinaryStringData |
trimLeft(BinaryStringData str,
BinaryStringData trimStr)
Walk each character of current string from left end, remove the character if it is in trim
string.
|
static BinaryStringData |
trimRight(BinaryStringData str) |
static BinaryStringData |
trimRight(BinaryStringData str,
BinaryStringData trimStr)
Walk each character of current string from right end, remove the character if it is in trim
string.
|
public static final BinaryStringData[] EMPTY_STRING_ARRAY
public static BinaryStringData[] splitByWholeSeparatorPreserveAllTokens(BinaryStringData str, BinaryStringData separator)
The separator is not included in the returned String array. Adjacent separators are treated as separators for empty tokens.
A null
separator splits on whitespace.
"".splitByWholeSeparatorPreserveAllTokens(*) = [] "ab de fg".splitByWholeSeparatorPreserveAllTokens(null) = ["ab", "de", "fg"] "ab de fg".splitByWholeSeparatorPreserveAllTokens(null) = ["ab", "", "", "de", "fg"] "ab:cd:ef".splitByWholeSeparatorPreserveAllTokens(":") = ["ab", "cd", "ef"] "ab-!-cd-!-ef".splitByWholeSeparatorPreserveAllTokens("-!-") = ["ab", "cd", "ef"]
Note: returned binary strings reuse memory segments from the input str.
separator
- String containing the String to be used as a delimiter, null
splits
on whitespacenull
if null String was inputpublic static Boolean toBooleanSQL(BinaryStringData str)
public static BinaryStringData hash(byte[] bytes, MessageDigest md)
MessageDigest
.public static BinaryStringData hash(BinaryStringData str, MessageDigest md)
MessageDigest
.public static BinaryStringData hash(BinaryStringData str, String algorithm) throws NoSuchAlgorithmException
NoSuchAlgorithmException
public static DecimalData toDecimal(BinaryStringData str, int precision, int scale)
NumberFormatException
- if the parsing failed.public static Long toLong(BinaryStringData str)
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 Integer toInt(BinaryStringData str)
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(BinaryStringData str)
public static Byte toByte(BinaryStringData str)
public static Double toDouble(BinaryStringData str)
public static Float toFloat(BinaryStringData str)
public static BinaryStringData keyValue(BinaryStringData str, byte split1, byte split2, BinaryStringData keyName)
split1
- separator between key-value tuple.split2
- separator between key and value.keyName
- name of the key whose value you want return.public static BinaryStringData substringSQL(BinaryStringData str, int pos)
public static BinaryStringData substringSQL(BinaryStringData str, int pos, int length)
public static BinaryStringData concat(BinaryStringData... inputs)
public static BinaryStringData concat(Iterable<BinaryStringData> inputs)
public static BinaryStringData concatWs(BinaryStringData separator, BinaryStringData... inputs)
Note: CONCAT_WS() does not skip any empty strings, however it does skip any NULL values after the separator. For example, concat_ws(",", "a", null, "c") would yield "a,c".
public static BinaryStringData concatWs(BinaryStringData separator, Iterable<BinaryStringData> inputs)
public static BinaryStringData reverse(BinaryStringData str)
public static BinaryStringData trim(BinaryStringData str, BinaryStringData trimStr)
trimStr
- the trim stringpublic static BinaryStringData trimLeft(BinaryStringData str)
public static boolean isSpaceString(BinaryStringData str)
public static BinaryStringData trimLeft(BinaryStringData str, BinaryStringData trimStr)
trimStr
- the trim stringpublic static BinaryStringData trimRight(BinaryStringData str)
public static BinaryStringData trimRight(BinaryStringData str, BinaryStringData trimStr)
trimStr
- the trim stringpublic static BinaryStringData trim(BinaryStringData str, boolean leading, boolean trailing, BinaryStringData seek)
public static String safeToString(BinaryStringData str)
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.