Package org.apache.flink.table.data
Class DecimalDataUtils
- java.lang.Object
-
- org.apache.flink.table.data.DecimalDataUtils
-
public final class DecimalDataUtils extends Object
Utilities forDecimalData
.Note: we have to put this class under the same package with
DecimalData
to make it possible to access package-accessing member variables.
-
-
Field Summary
Fields Modifier and Type Field Description static DecimalType
DECIMAL_SYSTEM_DEFAULT
-
Constructor Summary
Constructors Constructor Description DecimalDataUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DecimalData
abs(DecimalData decimal)
static DecimalData
add(DecimalData v1, DecimalData v2, int precision, int scale)
static DecimalData
castFrom(double val, int p, int s)
static DecimalData
castFrom(long val, int p, int s)
static DecimalData
castFrom(String string, int precision, int scale)
static DecimalData
castFrom(DecimalData dec, int precision, int scale)
static boolean
castToBoolean(DecimalData dec)
static DecimalData
castToDecimal(DecimalData dec, int precision, int scale)
static long
castToIntegral(DecimalData dec)
static DecimalData
ceil(DecimalData decimal)
static int
compare(double n1, DecimalData b2)
static int
compare(long n1, DecimalData b2)
static int
compare(DecimalData b1, double n2)
static int
compare(DecimalData b1, long n2)
static int
compare(DecimalData b1, DecimalData b2)
static DecimalData
divide(DecimalData v1, DecimalData v2, int precision, int scale)
static DecimalData
divideToIntegralValue(DecimalData value, DecimalData divisor, int precision, int scale)
Returns aDecimalData
whose value is the integer part of the quotient(this / divisor)
rounded down.static double
doubleValue(DecimalData decimal)
static DecimalData
floor(DecimalData decimal)
static boolean
is32BitDecimal(int precision)
static boolean
is64BitDecimal(int precision)
static boolean
isByteArrayDecimal(int precision)
static DecimalData
mod(DecimalData v1, DecimalData v2, int precision, int scale)
static DecimalData
multiply(DecimalData v1, DecimalData v2, int precision, int scale)
static DecimalData
negate(DecimalData decimal)
static long
power10(int n)
static DecimalData
sign(DecimalData b0)
SQLSIGN
operator applied to BigDecimal values. preserve precision and scale.static int
signum(DecimalData decimal)
Returns the signum function of this decimal.static DecimalData
sround(DecimalData b0, int r)
SQLROUND
operator applied to BigDecimal values.static DecimalData
subtract(DecimalData v1, DecimalData v2, int precision, int scale)
-
-
-
Field Detail
-
DECIMAL_SYSTEM_DEFAULT
public static final DecimalType DECIMAL_SYSTEM_DEFAULT
-
-
Method Detail
-
doubleValue
public static double doubleValue(DecimalData decimal)
-
signum
public static int signum(DecimalData decimal)
Returns the signum function of this decimal. (The return value is -1 if this decimal is negative; 0 if this decimal is zero; and 1 if this decimal is positive.)- Returns:
- the signum function of this decimal.
-
negate
public static DecimalData negate(DecimalData decimal)
-
abs
public static DecimalData abs(DecimalData decimal)
-
floor
public static DecimalData floor(DecimalData decimal)
-
ceil
public static DecimalData ceil(DecimalData decimal)
-
add
public static DecimalData add(DecimalData v1, DecimalData v2, int precision, int scale)
-
subtract
public static DecimalData subtract(DecimalData v1, DecimalData v2, int precision, int scale)
-
multiply
public static DecimalData multiply(DecimalData v1, DecimalData v2, int precision, int scale)
-
divide
public static DecimalData divide(DecimalData v1, DecimalData v2, int precision, int scale)
-
mod
public static DecimalData mod(DecimalData v1, DecimalData v2, int precision, int scale)
-
divideToIntegralValue
public static DecimalData divideToIntegralValue(DecimalData value, DecimalData divisor, int precision, int scale)
Returns aDecimalData
whose value is the integer part of the quotient(this / divisor)
rounded down.- Parameters:
value
- value by which thisDecimalData
is to be divided.divisor
- value by which thisDecimalData
is to be divided.- Returns:
- The integer part of
this / divisor
. - Throws:
ArithmeticException
- ifdivisor==0
-
castToIntegral
public static long castToIntegral(DecimalData dec)
-
castToDecimal
public static DecimalData castToDecimal(DecimalData dec, int precision, int scale)
-
castFrom
public static DecimalData castFrom(DecimalData dec, int precision, int scale)
-
castFrom
public static DecimalData castFrom(String string, int precision, int scale)
-
castFrom
public static DecimalData castFrom(double val, int p, int s)
-
castFrom
public static DecimalData castFrom(long val, int p, int s)
-
castToBoolean
public static boolean castToBoolean(DecimalData dec)
-
sign
public static DecimalData sign(DecimalData b0)
SQLSIGN
operator applied to BigDecimal values. preserve precision and scale.
-
compare
public static int compare(DecimalData b1, DecimalData b2)
-
compare
public static int compare(DecimalData b1, long n2)
-
compare
public static int compare(DecimalData b1, double n2)
-
compare
public static int compare(long n1, DecimalData b2)
-
compare
public static int compare(double n1, DecimalData b2)
-
sround
public static DecimalData sround(DecimalData b0, int r)
SQLROUND
operator applied to BigDecimal values.
-
power10
public static long power10(int n)
-
is32BitDecimal
public static boolean is32BitDecimal(int precision)
-
is64BitDecimal
public static boolean is64BitDecimal(int precision)
-
isByteArrayDecimal
public static boolean isByteArrayDecimal(int precision)
-
-