public boolean fillNextBatch(VectorizedRowBatch batch) {
    if (nextRowIndex >= rowCount) {
      return false;
    }

    VectorBatchPattern vectorBatchPattern =
        vectorBatchPatterns.getTectorBatchPatternList().get(batchCount);

    // System.out.println("*DEBUG* vectorBatchPattern " + vectorBatchPattern.toString());

    final int batchSize = vectorBatchPattern.getBatchSize();

    for (int c = 0; c < columnCount; c++) {
      batch.cols[c].reset();
    }

    BitSet bitSet = vectorBatchPattern.getBitSet();
    if (bitSet != null) {
      for (int columnNum = bitSet.nextSetBit(0);
           columnNum >= 0;
           columnNum = bitSet.nextSetBit(columnNum + 1)) {
        batch.cols[columnNum].isRepeating = true;
      }
    }

    int[] selected = vectorBatchPattern.getSelected();
    boolean selectedInUse = (selected != null);
    batch.selectedInUse = selectedInUse;
    if (selectedInUse) {
      System.arraycopy(selected, 0, batch.selected, 0, batchSize);
    }

    int rowIndex = nextRowIndex;
    for (int logicalIndex = 0; logicalIndex < batchSize; logicalIndex++) {
      final int batchIndex = (selectedInUse ? selected[logicalIndex] : logicalIndex);
      for (int c = 0; c < columnCount; c++) {
        if (batch.cols[c].isRepeating) {
          if (logicalIndex > 0) {
            continue;
          }
          vectorAssignRow.assignRowColumn(batch, 0, c, randomRows[rowIndex][c]);
        } else {
          vectorAssignRow.assignRowColumn(batch, batchIndex, c, randomRows[rowIndex][c]);
        }
      }
      rowIndex++;
    }
    batch.size = batchSize;
    batchCount++;
    nextRowIndex += batchSize;
    return true;
  }
Generate random batch source from a random Object[] row source (VectorRandomRowSource).
ql/src/test/org/apache/hadoop/hive/ql/exec/vector/VectorRandomBatchSource.java