public void spillBatch(BufferedVectorizedRowBatch batch) throws HiveException {
      VectorRowBytesContainer rowBytesContainer = getSpillRowBytesContainer();
      VectorSerializeRow vectorSerializeRow = getVectorSerializeRow();

      final boolean selectedInUse = batch.selectedInUse;
      int[] selected = batch.selected;
      final int size = batch.size;

      try {
        for (int logicalIndex = 0; logicalIndex < size; logicalIndex++) {
          final int batchIndex = (selectedInUse ? selected[logicalIndex] : logicalIndex);

          Output output = rowBytesContainer.getOutputForRowBytes();
          vectorSerializeRow.setOutputAppend(output);
          vectorSerializeRow.serializeWrite(batch, batchIndex);
          rowBytesContainer.finishRow();
        }
      } catch (IOException e) {
        throw new HiveException(e);
      }
    }
<pre>
Deserializer needs to know which columns to put the deserialized values into. Basically,
deserialization can happen in 2 cases:
1. final read: deserialized values should go back into
the proper output columns in the overflow batch, the mapping is stored in
bufferedColumnMap.
2. "intermediate" read: deserialized values should be just put back into
columns in the same order as they arrived to the serializer (like: [0, 1, 2, 3, 4, 5]
</pre>
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorSpillBlockContainer.java