@HiveDecimalWritableVersionV1
  public static HiveDecimalWritable enforcePrecisionScale(HiveDecimalWritable writable, int precision, int scale) {
    if (!writable.isSet) {
      return null;
    }
    HiveDecimalWritable result = new HiveDecimalWritable(writable);
    result.mutateEnforcePrecisionScale(precision, scale);
    if (!result.isSet()) {
      return null;
    }
    return result;
  }
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