Class DataTypeConversionFunctions
- java.lang.Object
-
- org.apache.pinot.common.function.scalar.DataTypeConversionFunctions
-
public class DataTypeConversionFunctions extends Object
Contains function to convert a datatype to another datatype.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]base64Decode(String input)decode base64 encoded string to bytes usingBase64static byte[]base64Encode(byte[] input)encode byte array to base64 usingBase64static byte[]bigDecimalToBytes(String number)Converts big decimal string representation to bytes.static StringbytesToBigDecimal(byte[] bytes)Converts bytes value representation generated bybigDecimalToBytes(String)back to string big decimalstatic StringbytesToHex(byte[] bytes)convert simple bytes array to hex stringstatic Objectcast(Object value, String targetTypeLiteral)static byte[]hexToBytes(String hex)convert simple hex string to byte array
-
-
-
Method Detail
-
bigDecimalToBytes
public static byte[] bigDecimalToBytes(String number)
Converts big decimal string representation to bytes. Only scale of upto 2 bytes is supported by the function- Parameters:
number- big decimal number in plain string. e.g. '1234.12121'- Returns:
- The result byte array contains the bytes of the unscaled value appended to bytes of the scale in BIG ENDIAN order.
-
bytesToBigDecimal
public static String bytesToBigDecimal(byte[] bytes)
Converts bytes value representation generated bybigDecimalToBytes(String)back to string big decimal- Parameters:
bytes- array that contains the bytes of the unscaled value appended to 2 bytes of the scale in BIG ENDIAN order.- Returns:
- plain string representation of big decimal
-
hexToBytes
public static byte[] hexToBytes(String hex)
convert simple hex string to byte array- Parameters:
hex- a plain hex string e.g. 'f0e1a3b2'- Returns:
- byte array representation of hex string
-
bytesToHex
public static String bytesToHex(byte[] bytes)
convert simple bytes array to hex string- Parameters:
bytes- any byte array- Returns:
- plain hex string e.g. 'f012be3c'
-
base64Encode
public static byte[] base64Encode(byte[] input)
encode byte array to base64 usingBase64- Parameters:
input- original byte array- Returns:
- base64 encoded byte array
-
-