HiveDecimal (Hive Storage API 2.1.1-pre-orc API)
Date: 2016-10-19

org.apache.hadoop.hive.common.type

## Class HiveDecimal

- java.lang.Object
- - org.apache.hadoop.hive.common.type.HiveDecimal

- All Implemented Interfaces:
    Comparable<HiveDecimal>

      public class HiveDecimal
      extends Object
      implements Comparable<HiveDecimal>

  HiveDecimal. Simple wrapper for BigDecimal. Adds fixed max precision and non scientific string representation

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `MAX_PRECISION`
    `static int` | `MAX_SCALE`
    `static HiveDecimal` | `ONE`
    `static int` | `ROUND_CEILING`
    `static int` | `ROUND_FLOOR`
    `static int` | `ROUND_HALF_EVEN`
    `static int` | `ROUND_HALF_UP`
    `static int` | `SYSTEM_DEFAULT_PRECISION` Default precision/scale when system is not able to determine them, such as in case of a non-generic udf.
    `static int` | `SYSTEM_DEFAULT_SCALE`
    `static int` | `USER_DEFAULT_PRECISION` Default precision/scale when user doesn't specify in the column metadata, such as decimal and decimal(8).
    `static int` | `USER_DEFAULT_SCALE`
    `static HiveDecimal` | `ZERO`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `HiveDecimal` | `abs()`
    `HiveDecimal` | `add(HiveDecimal dec)`
    `BigDecimal` | `bigDecimalValue()`
    `byte` | `byteValue()`
    `int` | `compareTo(HiveDecimal dec)`
    `static HiveDecimal` | `create(BigDecimal b)`
    `static HiveDecimal` | `create(BigDecimal b, boolean allowRounding)`
    `static HiveDecimal` | `create(BigInteger bi)`
    `static HiveDecimal` | `create(BigInteger unscaled, int scale)`
    `static HiveDecimal` | `create(int i)`
    `static HiveDecimal` | `create(long l)`
    `static HiveDecimal` | `create(String dec)`
    `HiveDecimal` | `divide(HiveDecimal dec)`
    `double` | `doubleValue()`
    `static HiveDecimal` | `enforcePrecisionScale(HiveDecimal dec, int maxPrecision, int maxScale)`
    `boolean` | `equals(Object obj)`
    `float` | `floatValue()`
    `int` | `hashCode()`
    `int` | `intValue()`
    `long` | `longValue()`
    `HiveDecimal` | `multiply(HiveDecimal dec)`
    `HiveDecimal` | `negate()`
    `HiveDecimal` | `pow(int n)`
    `int` | `precision()` Returns the number of digits (integer and fractional) in the number, which is equivalent to SQL decimal precision.
    `HiveDecimal` | `remainder(HiveDecimal dec)`
    `int` | `scale()`
    `HiveDecimal` | `scaleByPowerOfTen(int n)`
    `HiveDecimal` | `setScale(int i)`
    `HiveDecimal` | `setScale(int adjustedScale, int rm)`
    `short` | `shortValue()`
    `int` | `signum()` Get the sign of the underlying decimal.
    `HiveDecimal` | `subtract(HiveDecimal dec)`
    `String` | `toFormatString(int scale)` Return a string representation of the number with the number of decimal digits as the given scale.
    `String` | `toString()`
    `BigInteger` | `unscaledValue()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### MAX_PRECISION

          public static final int MAX_PRECISION

      See Also:
        Constant Field Values

    - #### MAX_SCALE

          public static final int MAX_SCALE

      See Also:
        Constant Field Values

    - #### USER_DEFAULT_PRECISION

          public static final int USER_DEFAULT_PRECISION

      Default precision/scale when user doesn't specify in the column metadata, such as decimal and decimal(8).
      See Also:
        Constant Field Values

    - #### USER_DEFAULT_SCALE

          public static final int USER_DEFAULT_SCALE

      See Also:
        Constant Field Values

    - #### SYSTEM_DEFAULT_PRECISION

          public static final int SYSTEM_DEFAULT_PRECISION

      Default precision/scale when system is not able to determine them, such as in case of a non-generic udf.
      See Also:
        Constant Field Values

    - #### SYSTEM_DEFAULT_SCALE

          public static final int SYSTEM_DEFAULT_SCALE

      See Also:
        Constant Field Values

    - #### ZERO

          public static final HiveDecimal ZERO

    - #### ONE

          public static final HiveDecimal ONE

    - #### ROUND_FLOOR

          public static final int ROUND_FLOOR

      See Also:
        Constant Field Values

    - #### ROUND_CEILING

          public static final int ROUND_CEILING

      See Also:
        Constant Field Values

    - #### ROUND_HALF_UP

          public static final int ROUND_HALF_UP

      See Also:
        Constant Field Values

    - #### ROUND_HALF_EVEN

          public static final int ROUND_HALF_EVEN

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### create

          public static HiveDecimal create(BigDecimal b)

    - #### create

          public static HiveDecimal create(BigDecimal b,
                                           boolean allowRounding)

    - #### create

          public static HiveDecimal create(BigInteger unscaled,
                                           int scale)

    - #### create

          public static HiveDecimal create(String dec)

    - #### create

          public static HiveDecimal create(BigInteger bi)

    - #### create

          public static HiveDecimal create(int i)

    - #### create

          public static HiveDecimal create(long l)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### toFormatString

          public String toFormatString(int scale)

      Return a string representation of the number with the number of decimal digits as the given scale. Please note that this is different from toString().
      Parameters:
        `scale` - the number of digits after the decimal point
      Returns:
        the string representation of exact number of decimal digits

    - #### setScale

          public HiveDecimal setScale(int i)

    - #### compareTo

          public int compareTo(HiveDecimal dec)

      Specified by:
        `compareTo` in interface `Comparable<HiveDecimal>`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### scale

          public int scale()

    - #### precision

          public int precision()

      Returns the number of digits (integer and fractional) in the number, which is equivalent to SQL decimal precision. Note that this is different from BigDecimal.precision(), which returns the precision of the unscaled value (BigDecimal.valueOf(0.01).precision() = 1, whereas HiveDecimal.create("0.01").precision() = 2). If you want the BigDecimal precision, use HiveDecimal.bigDecimalValue().precision()
      Returns:

    - #### intValue

          public int intValue()

    - #### doubleValue

          public double doubleValue()

    - #### longValue

          public long longValue()

    - #### shortValue

          public short shortValue()

    - #### floatValue

          public float floatValue()

    - #### bigDecimalValue

          public BigDecimal bigDecimalValue()

    - #### byteValue

          public byte byteValue()

    - #### setScale

          public HiveDecimal setScale(int adjustedScale,
                                      int rm)

    - #### subtract

          public HiveDecimal subtract(HiveDecimal dec)

    - #### multiply

          public HiveDecimal multiply(HiveDecimal dec)

    - #### unscaledValue

          public BigInteger unscaledValue()

    - #### scaleByPowerOfTen

          public HiveDecimal scaleByPowerOfTen(int n)

    - #### abs

          public HiveDecimal abs()

    - #### negate

          public HiveDecimal negate()

    - #### add

          public HiveDecimal add(HiveDecimal dec)

    - #### pow

          public HiveDecimal pow(int n)

    - #### remainder

          public HiveDecimal remainder(HiveDecimal dec)

    - #### divide

          public HiveDecimal divide(HiveDecimal dec)

    - #### signum

          public int signum()

      Get the sign of the underlying decimal.
      Returns:
        0 if the decimal is equal to 0, -1 if less than zero, and 1 if greater than 0

    - #### enforcePrecisionScale

          public static HiveDecimal enforcePrecisionScale(HiveDecimal dec,
                                                          int maxPrecision,
                                                          int maxScale)

Copyright © 2016 The Apache Software Foundation. All rights reserved.