Package io.substrait.util
Class DecimalUtil
java.lang.Object
io.substrait.util.DecimalUtil
A set of utility methods to deal with convertion of decimal values. Part of code is adopted from
Apache Arrow /java/vector/src/main/java/org/apache/arrow/vector/util/DecimalUtility.java
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]encodeDecimalIntoBytes(BigDecimal decimal, int scale, int byteWidth) Given a big decimal and its scale, convert into a scaled big integer, and then convert the scaled big integer into little-endian twos-complement with byeWidth bytes.static BigDecimalgetBigDecimalFromBytes(byte[] value, int scale, int byteWidth) Given an input of little-endian twos-complement with byeWidth bytes of a scaled big integer, convert it back to BigDecimal.
-
Constructor Details
-
DecimalUtil
public DecimalUtil()
-
-
Method Details
-
getBigDecimalFromBytes
Given an input of little-endian twos-complement with byeWidth bytes of a scaled big integer, convert it back to BigDecimal. This method is the opposite of encodeDecimalIntoBytes()- Parameters:
value-scale-byteWidth-- Returns:
-
encodeDecimalIntoBytes
Given a big decimal and its scale, convert into a scaled big integer, and then convert the scaled big integer into little-endian twos-complement with byeWidth bytes.- Parameters:
decimal-scale-byteWidth-- Returns:
-