|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.hadoop.hive.common.type.SqlMathUtil
public final class SqlMathUtil
This code was originally written for Microsoft PolyBase. Misc utilities used in this package.
| Field Summary | |
|---|---|
static int |
FULLBITS_31
Mask to convert an int to an unsigned int. |
static int |
FULLBITS_32
Max unsigned integer. |
static long |
FULLBITS_63
Mask to convert a long to an unsigned long. |
static UnsignedInt128[] |
INVERSE_POWER_FIVES_INT128
1/5^x, scaled to 128bits (in other words, 2^128/5^x). |
static UnsignedInt128[] |
INVERSE_POWER_TENS_INT128
1/10^x, scaled to 128bits, also word-shifted for better accuracy. |
static int[] |
INVERSE_POWER_TENS_INT128_WORD_SHIFTS
number of words shifted up in each INVERSE_POWER_TENS_INT128. |
static long |
LONG_MASK
Mask to convert signed integer to unsigned long. |
static int |
MAX_POWER_FIVE_INT128
5^55 fits in 2^128. |
static int |
MAX_POWER_FIVE_INT31
5^13 fits in 2^31. |
static int |
MAX_POWER_FIVE_INT63
5^27 fits in 2^63. |
static int |
MAX_POWER_TEN_INT128
10^38 fits in UnsignedInt128. |
static int |
MAX_POWER_TEN_INT31
10^9 fits in 2^31. |
static int |
NEGATIVE_INT_MASK
Mask to convert an int to a negative int. |
static long |
NEGATIVE_LONG_MASK
Mask to convert a long to a negative long. |
static UnsignedInt128[] |
POWER_FIVES_INT128
5^x. |
static int[] |
POWER_FIVES_INT31
5^x. |
static long[] |
POWER_FIVES_INT63
5^x. |
static UnsignedInt128[] |
POWER_TENS_INT128
10^x. |
static int[] |
POWER_TENS_INT31
10^x. |
static UnsignedInt128[] |
ROUND_POWER_TENS_INT128
5 * 10^(x-1). |
static int[] |
ROUND_POWER_TENS_INT31
5 * 10^(x-1). |
| Method Summary | |
|---|---|
static short |
bitLength(int v0,
int v1,
int v2,
int v3)
Returns the minimal number of bits to represent the words. |
static short |
bitLengthInWord(int word)
Returns the minimal number of bits to represent the given integer value. |
static long |
combineInts(int lo,
int hi)
|
static int |
compareUnsignedInt(int x,
int y)
If we can assume JDK 1.8, this should use java.lang.Integer.compareUnsigned(), which will be replaced with intrinsics in JVM. |
static int |
compareUnsignedLong(long x,
long y)
If we can assume JDK 1.8, this should use java.lang.Long.compareUnsigned(), which will be replaced with intrinsics in JVM. |
static int[] |
divideMultiPrecision(int[] dividend,
int[] divisor,
int[] quotient)
Multi-precision divide. |
static long |
divideUnsignedLong(long dividend,
long divisor)
If we can assume JDK 1.8, this should use java.lang.Long.divideUnsigned(), which will be replaced with intrinsics in JVM. |
static int |
extractHiInt(long val)
|
static int |
extractLowInt(long val)
|
static long |
remainderUnsignedLong(long dividend,
long divisor)
If we can assume JDK 1.8, this should use java.lang.Long.remainderUnsigned(), which will be replaced with intrinsics in JVM. |
static int |
setSignBitInt(int val,
boolean positive)
Turn on or off the highest bit of an int value. |
static long |
setSignBitLong(long val,
boolean positive)
Turn on or off the highest bit of a long value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final long NEGATIVE_LONG_MASK
public static final long FULLBITS_63
public static final int NEGATIVE_INT_MASK
public static final long LONG_MASK
public static final int FULLBITS_31
public static final int FULLBITS_32
public static final int MAX_POWER_FIVE_INT31
public static final int[] POWER_FIVES_INT31
public static final int MAX_POWER_FIVE_INT63
public static final long[] POWER_FIVES_INT63
public static final int MAX_POWER_FIVE_INT128
public static final UnsignedInt128[] POWER_FIVES_INT128
public static final UnsignedInt128[] INVERSE_POWER_FIVES_INT128
public static final int MAX_POWER_TEN_INT31
public static final int[] POWER_TENS_INT31
public static final int[] ROUND_POWER_TENS_INT31
public static final int MAX_POWER_TEN_INT128
public static final UnsignedInt128[] POWER_TENS_INT128
public static final UnsignedInt128[] ROUND_POWER_TENS_INT128
public static final UnsignedInt128[] INVERSE_POWER_TENS_INT128
public static final int[] INVERSE_POWER_TENS_INT128_WORD_SHIFTS
| Method Detail |
|---|
public static int setSignBitInt(int val,
boolean positive)
val - the value to modifypositive - whether to turn off (positive) or on (negative).
public static long setSignBitLong(long val,
boolean positive)
val - the value to modifypositive - whether to turn off (positive) or on (negative).
public static short bitLengthInWord(int word)
word - int32 value
public static short bitLength(int v0,
int v1,
int v2,
int v3)
v0 - v0v1 - v1v2 - v2v3 - v3
public static int compareUnsignedInt(int x,
int y)
x - the first int to comparey - the second int to compare
0 if x == y; a value less than 0
if x < y as unsigned values; and a value greater than
0 if x > y as unsigned values
public static int compareUnsignedLong(long x,
long y)
x - the first int to comparey - the second int to compare
0 if x == y; a value less than 0
if x < y as unsigned values; and a value greater than
0 if x > y as unsigned values
public static long divideUnsignedLong(long dividend,
long divisor)
dividend - the value to be divideddivisor - the value doing the dividing
public static long remainderUnsignedLong(long dividend,
long divisor)
dividend - the value to be divideddivisor - the value doing the dividing
public static long combineInts(int lo,
int hi)
lo - low 32bithi - high 32bit
public static int extractHiInt(long val)
val - long value
public static int extractLowInt(long val)
val - long value
public static int[] divideMultiPrecision(int[] dividend,
int[] divisor,
int[] quotient)
dividend - dividend. in.divisor - divisor. in.quotient - quotient. out.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||