private void forwardSpilledBatches(VectorPTFOperator vecPTFOperator, Object[] partitionKey)
      throws HiveException {

    overflowBatch.reset();
    copyPartitionColumnToOverflow(partitionKey);

    try {
      for (int b = 0; b < blocks.size(); b++) {
        VectorSpillBlock block = blocks.get(b);
        if (blocks.isBlockInMemory(block)) {
          /*
           * Buffered blocks will be forwarded in forwardBufferedBatch. We can break instead of
           * continue, as we already called jumpToLastBlock() before starting to forward batches to
           * next operator, so the in-memory block should be the last block.
           */
          break;
        }
        block.setDoFinalRead(true);

        VectorRowBytesContainer rowBytesContainer = block.getSpillRowBytesContainer();
        rowBytesContainer.prepareForReading();
        int batchIndex = 0;
        long spillRowsRead = 0;

        while (rowBytesContainer.readNext()) {
          if (batchIndex < block.startRowIndex.length - 1
              && overflowBatch.size == block.startRowIndex[batchIndex + 1]
                  - block.startRowIndex[batchIndex]) {
            fillGroupResults(overflowBatch, block.isLastGroupBatch[batchIndex]);
            vecPTFOperator.forwardBatch(overflowBatch);

            overflowBatch.reset();
            copyPartitionColumnToOverflow(partitionKey);

            batchIndex += 1;
          }

          block.readSingleRowFromBytesContainer(overflowBatch);
          overflowBatch.size++;
          spillRowsRead++;
        }

        if (overflowBatch.size > 0){
          fillGroupResults(overflowBatch, block.isLastGroupBatch[batchIndex]);
          vecPTFOperator.forwardBatch(overflowBatch);

          overflowBatch.reset();
          copyPartitionColumnToOverflow(partitionKey);
        }

        Preconditions.checkState(spillRowsRead == block.spillRowCount,
            "error while checking forwardSpilledBatches state for spillRowsRead == block.spillRowCount, %s != %s (block %s/%s)",
            spillRowsRead, block.spillRowCount, b, blocks.size() - 1);
      }
    } catch (Exception e) {
      throw new HiveException(e);
    }
  }
Returns the values of ordering columns from a given batch and given row in an Object[].
@param vectorizedRowBatch
@param rowIndexInBatch
@return
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFGroupBatches.java