public static void writeToByteStream(
      RandomAccessOutput byteStream,
      HiveDecimalWritable decWritable,
      long[] scratchLongs, byte[] scratchBytes) {
    LazyBinaryUtils.writeVInt(byteStream, decWritable.scale());
    int byteLength =
        decWritable.bigIntegerBytes(
            scratchLongs, scratchBytes);
    LazyBinaryUtils.writeVInt(byteStream, byteLength);
    byteStream.write(scratchBytes, 0, byteLength);
  }
Allocate scratchLongs with HiveDecimal.SCRATCH_LONGS_LEN longs.
And, allocate scratch buffer with HiveDecimal.SCRATCH_BUFFER_LEN_BIG_INTEGER_BYTES bytes.

@param byteStream
@param decWritable
@param scratchLongs
@param scratchBytes
serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinarySerDe.java