public void seal() {
    if (writePos.bufferIndex == -1) {
      return;
    }
    if (writePos.offset < (wbSize * 0.8)) { // arbitrary
      byte[] smallerBuffer = new byte[writePos.offset];
      System.arraycopy(writePos.buffer, 0, smallerBuffer, 0, writePos.offset);
      writeBuffers.set(writePos.bufferIndex, smallerBuffer);
    }
    if (writePos.bufferIndex + 1 < writeBuffers.size()) {
      writeBuffers.subList(writePos.bufferIndex + 1, writeBuffers.size()).clear();
    }
    // Make sure we don't reference any old buffer.
    clearState();
  }
Changes the byte segment reference from being a reference to global buffer to
the one with a self-contained byte array. The byte array will either be one of
the internal ones, or a copy of data if the original reference pointed to a data
spanning multiple internal buffers.
serde/src/java/org/apache/hadoop/hive/serde2/WriteBuffers.java