@HiveDecimalWritableVersionV2
  public static int compareTo(HiveDecimal dec, HiveDecimalWritable writable) {
    if (dec == null || !writable.isSet()) {
      throw new RuntimeException("Invalid comparision operand(s)");
    }
    return FastHiveDecimal.fastCompareTo(dec, writable);
  }
Allocate scratchLongs with HiveDecimal.SCRATCH_LONGS_LEN longs.
And, allocate scratch scratchBuffer with HiveDecimal.SCRATCH_BUFFER_LEN_BIG_INTEGER_BYTES bytes.
storage-api/src/java/org/apache/hadoop/hive/serde2/io/HiveDecimalWritable.java