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
Modifier and Type Method Description static byte[]base64Decode(byte[] input)DecodesBase64encoded bytes.static byte[]base64Encode(byte[] input)Encodes bytes usingBase64.static byte[]bigDecimalToBytes(BigDecimal bigDecimal)ConvertsBigDecimalto bytes.static BigDecimalbytesToBigDecimal(byte[] bytes)Converts serializedBigDecimalbytes to value.static 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(BigDecimal bigDecimal)
ConvertsBigDecimalto bytes. Only scale of upto 2 bytes is supported by the function- Parameters:
bigDecimal- big decimal number- 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 BigDecimal bytesToBigDecimal(byte[] bytes)
Converts serializedBigDecimalbytes to value.- Parameters:
bytes- array that contains the bytes of the unscaled value appended to 2 bytes of the scale in BIG ENDIAN order.- Returns:
- big decimal number
-
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)
Encodes bytes usingBase64.- Parameters:
input- original bytes- Returns:
- base64 encoded bytes
-
base64Decode
public static byte[] base64Decode(byte[] input)
DecodesBase64encoded bytes.- Parameters:
input- base64 encoded bytes- Returns:
- decoded bytes
-
-