public void copyGroupKey(VectorizedRowBatch inputBatch, VectorizedRowBatch outputBatch,
          DataOutputBuffer buffer) throws HiveException {

    for(int i = 0; i< longIndices.length; ++i) {
      final int outputColumnNum = longIndices[i];
      final int inputColumnNum = inputColumnNums[outputColumnNum];
      LongColumnVector inputColumnVector = (LongColumnVector) inputBatch.cols[inputColumnNum];
      LongColumnVector outputColumnVector = (LongColumnVector) outputBatch.cols[outputColumnNum];

      // This vectorized code pattern says:
      //    If the input batch has no nulls at all (noNulls is true) OR
      //    the input row is NOT NULL, copy the value.
      //
      //    Otherwise, we have a NULL input value.  The standard way to mark a NULL in the
      //    output batch is: turn off noNulls indicating there is at least one NULL in the batch
      //    and mark that row as NULL.
      //
      //    When a vectorized row batch is reset, noNulls is set to true and the isNull array
      //    is zeroed.
      //
      // We grab the key at index 0.  We don't care about selected or repeating since all keys
      // in the input batch are suppose to be the same.
      //
      if (inputColumnVector.noNulls || !inputColumnVector.isNull[0]) {
        outputColumnVector.vector[outputBatch.size] = inputColumnVector.vector[0];
      } else {
        outputColumnVector.noNulls = false;
        outputColumnVector.isNull[outputBatch.size] = true;
      }
    }
    for(int i=0;i<doubleIndices.length; ++i) {
      final int outputColumnNum = doubleIndices[i];
      final int inputColumnNum = inputColumnNums[outputColumnNum];
      DoubleColumnVector inputColumnVector = (DoubleColumnVector) inputBatch.cols[inputColumnNum];
      DoubleColumnVector outputColumnVector = (DoubleColumnVector) outputBatch.cols[outputColumnNum];
      if (inputColumnVector.noNulls || !inputColumnVector.isNull[0]) {
        outputColumnVector.vector[outputBatch.size] = inputColumnVector.vector[0];
      } else {
        outputColumnVector.noNulls = false;
        outputColumnVector.isNull[outputBatch.size] = true;
      }
    }
    for(int i=0;i<stringIndices.length; ++i) {
      final int outputColumnNum = stringIndices[i];
      final int inputColumnNum = inputColumnNums[outputColumnNum];
      BytesColumnVector inputColumnVector = (BytesColumnVector) inputBatch.cols[inputColumnNum];
      BytesColumnVector outputColumnVector = (BytesColumnVector) outputBatch.cols[outputColumnNum];
      if (inputColumnVector.noNulls || !inputColumnVector.isNull[0]) {
        // Copy bytes into scratch buffer.
        int start = buffer.getLength();
        int length = inputColumnVector.length[0];
        try {
          buffer.write(inputColumnVector.vector[0], inputColumnVector.start[0], length);
        } catch (IOException ioe) {
          throw new IllegalStateException("bad write", ioe);
        }
        outputColumnVector.setRef(outputBatch.size, buffer.getData(), start, length);
      } else {
        outputColumnVector.noNulls = false;
        outputColumnVector.isNull[outputBatch.size] = true;
      }
    }
    for(int i=0;i<decimalIndices.length; ++i) {
      final int outputColumnNum = decimalIndices[i];
      final int inputColumnNum = inputColumnNums[outputColumnNum];
      DecimalColumnVector inputColumnVector = (DecimalColumnVector) inputBatch.cols[inputColumnNum];
      DecimalColumnVector outputColumnVector = (DecimalColumnVector) outputBatch.cols[outputColumnNum];
      if (inputColumnVector.noNulls || !inputColumnVector.isNull[0]) {

        // Since we store references to HiveDecimalWritable instances, we must use the update method instead
        // of plain assignment.
        outputColumnVector.set(outputBatch.size, inputColumnVector.vector[0]);
      } else {
        outputColumnVector.noNulls = false;
        outputColumnVector.isNull[outputBatch.size] = true;
      }
    }
    for(int i=0;i<timestampIndices.length; ++i) {
      final int outputColumnNum = timestampIndices[i];
      final int inputColumnNum = inputColumnNums[outputColumnNum];
      TimestampColumnVector inputColumnVector = (TimestampColumnVector) inputBatch.cols[inputColumnNum];
      TimestampColumnVector outputColumnVector = (TimestampColumnVector) outputBatch.cols[outputColumnNum];
      if (inputColumnVector.noNulls || !inputColumnVector.isNull[0]) {
        outputColumnVector.isNull[outputBatch.size] = false;
        outputColumnVector.setElement(outputBatch.size, 0, inputColumnVector);
      } else {
        outputColumnVector.noNulls = false;
        outputColumnVector.isNull[outputBatch.size] = true;
      }
    }
    for(int i=0;i<intervalDayTimeIndices.length; ++i) {
      final int outputColumnNum = intervalDayTimeIndices[i];
      final int inputColumnNum = inputColumnNums[outputColumnNum];
      IntervalDayTimeColumnVector inputColumnVector = (IntervalDayTimeColumnVector) inputBatch.cols[inputColumnNum];
      IntervalDayTimeColumnVector outputColumnVector = (IntervalDayTimeColumnVector) outputBatch.cols[outputColumnNum];
      if (inputColumnVector.noNulls || !inputColumnVector.isNull[0]) {
        outputColumnVector.isNull[outputBatch.size] = false;
        outputColumnVector.setElement(outputBatch.size, 0, inputColumnVector);
      } else {
        outputColumnVector.noNulls = false;
        outputColumnVector.isNull[outputBatch.size] = true;
      }
    }
  }
Class for copying the group key from an input batch to an output batch.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorGroupKeyHelper.java