@HiveDecimalWritableVersionV1
  public byte[] getInternalStorage() {
    if (!isSet()) {
      // don't break old callers that are trying to reuse storages
      return EMPTY_ARRAY;
    }

    if (internalScratchLongs == null) {
      internalScratchLongs = new long[FastHiveDecimal.FAST_SCRATCH_LONGS_LEN];
      internalScratchBuffer = new byte[FastHiveDecimal.FAST_SCRATCH_BUFFER_LEN_BIG_INTEGER_BYTES];
    }

    return bigIntegerBytesCopy(
        internalScratchLongs, internalScratchBuffer);
  }
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