@HiveDecimalWritableVersionV2
  public int bigIntegerBytesInternalScratch() {

    if (!isSet()) {
      throw new RuntimeException("no value set");
    }

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

    int byteLength =
        fastBigIntegerBytes(
            internalScratchLongs, internalScratchBuffer);
    if (byteLength == 0) {
      throw new RuntimeException("Couldn't convert decimal to binary");
    }
    return byteLength;
  }
Returns the length of the decimal converted to bytes.
Call bigIntegerBytesBuffer() to get a reference to the converted bytes.
storage-api/src/java/org/apache/hadoop/hive/serde2/io/HiveDecimalWritable.java