public void bufferGroupBatch(VectorizedRowBatch batch, boolean isLastGroupBatch) throws HiveException {
    partitionMetrics.totalNumberOfBatches += 1;
    if (currentBufferedBatchCount >= spillLimitBufferedBatchCount) {
      spillAndResetCurrentBufferedBatches();
      // a new block spilled here, the latest block.startBatchIndex + spillLimitBufferedBatchCount
      // points to the first in-memory batch's index
      blocks.updateStartBatchIndexInMemory();
    }

    if (allocatedBufferedBatchCount <= currentBufferedBatchCount) {
      BufferedVectorizedRowBatch newBatch = newBufferedBatch(batch);
      bufferedBatches.add(newBatch);
      allocatedBufferedBatchCount++;
    }

    BufferedVectorizedRowBatch bufferedBatch = bufferedBatches.get(currentBufferedBatchCount++);
    copyBufferedColumns(batch, bufferedBatch);
    bufferedBatch.isLastGroupBatch = isLastGroupBatch;
    cachedSize = -1; // clear cached size as we added new batches
  }
Buffers a batch at the end of bufferedBatches, and if it's full, spills a block of batches to
the disk.

@param batch
@throws HiveException
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFGroupBatches.java