@Override
  public void processBatch(VectorizedRowBatch batch) throws IOException {

    currentBatchSize = batch.size;
    Preconditions.checkState(currentBatchSize > 0);

    BytesColumnVector bytesColVector = (BytesColumnVector) batch.cols[columnNum];

    byte[][] vectorBytesArrays = bytesColVector.vector;
    int[] vectorStarts = bytesColVector.start;
    int[] vectorLengths = bytesColVector.length;

    // The serialize routine uses this to build serializedKeyLengths.
    outputStartPosition = 0;
    output.reset();

    if (bytesColVector.isRepeating){
      duplicateCounts[0] = currentBatchSize;
      if (bytesColVector.noNulls || !bytesColVector.isNull[0]) {
        seriesIsAllNull[0] = false;
        serialize(0, vectorBytesArrays[0], vectorStarts[0], vectorLengths[0]);
        nonNullKeyCount = 1;
      } else {
        seriesIsAllNull[0] = true;
        nonNullKeyCount = 0;
      }
      seriesCount = 1;
      Preconditions.checkState(seriesCount <= currentBatchSize);
    } else {
      seriesCount = 0;
      nonNullKeyCount = 0;
      if (batch.selectedInUse) {
        int[] selected = batch.selected;
        if (bytesColVector.noNulls) {

          duplicateCounts[0] = 1;
          int index;
          index = selected[0];
          byte[] prevKeyBytes = vectorBytesArrays[index];
          int prevKeyStart = vectorStarts[index];
          int prevKeyLength = vectorLengths[index];
          serialize(0, prevKeyBytes, prevKeyStart, prevKeyLength);

          int currentKeyStart;
          int currentKeyLength;
          byte[] currentKeyBytes;
          for (int logical = 1; logical < currentBatchSize; logical++) {
            index = selected[logical];
            currentKeyBytes = vectorBytesArrays[index];
            currentKeyStart = vectorStarts[index];
            currentKeyLength = vectorLengths[index];
            if (StringExpr.equal(prevKeyBytes, prevKeyStart, prevKeyLength,
                                 currentKeyBytes, currentKeyStart, currentKeyLength)) {
              duplicateCounts[seriesCount]++;
            } else {
              duplicateCounts[++seriesCount] = 1;
              serialize(seriesCount, currentKeyBytes, currentKeyStart, currentKeyLength);
              prevKeyBytes = currentKeyBytes;
              prevKeyStart = currentKeyStart;
              prevKeyLength = currentKeyLength;
            }
          }
          Arrays.fill(seriesIsAllNull, 0, ++seriesCount, false);
          nonNullKeyCount = seriesCount;
          Preconditions.checkState(seriesCount <= currentBatchSize);
        } else {
          boolean[] isNull = bytesColVector.isNull;

          boolean prevKeyIsNull;
          byte[] prevKeyBytes = null;
          int prevKeyStart = 0;
          int prevKeyLength = 0;
          duplicateCounts[0] = 1;
          int index = selected[0];
          if (isNull[index]) {
            seriesIsAllNull[0] = true;
            prevKeyIsNull = true;
          } else {
            seriesIsAllNull[0] = false;
            prevKeyIsNull = false;
            prevKeyBytes = vectorBytesArrays[index];
            prevKeyStart = vectorStarts[index];
            prevKeyLength = vectorLengths[index];
            serialize(0, prevKeyBytes, prevKeyStart, prevKeyLength);
            nonNullKeyCount = 1;
          }

          int currentKeyStart;
          int currentKeyLength;
          byte[] currentKeyBytes;
          for (int logical = 1; logical < currentBatchSize; logical++) {
            index = selected[logical];
            if (isNull[index]) {
              if (prevKeyIsNull) {
                duplicateCounts[seriesCount]++;
              } else {
                duplicateCounts[++seriesCount] = 1;
                seriesIsAllNull[seriesCount] = true;
                prevKeyIsNull = true;
              }
            } else {
              currentKeyBytes = vectorBytesArrays[index];
              currentKeyStart = vectorStarts[index];
              currentKeyLength = vectorLengths[index];
              if (!prevKeyIsNull &&
                  StringExpr.equal(prevKeyBytes, prevKeyStart, prevKeyLength,
                                   currentKeyBytes, currentKeyStart, currentKeyLength)) {
                duplicateCounts[seriesCount]++;
              } else {
                duplicateCounts[++seriesCount] = 1;
                seriesIsAllNull[seriesCount] = false;
                serialize(nonNullKeyCount++, currentKeyBytes, currentKeyStart, currentKeyLength);
                prevKeyIsNull = false;
                prevKeyBytes = currentKeyBytes;
                prevKeyStart = currentKeyStart;
                prevKeyLength = currentKeyLength;
              }
            }
          }
          seriesCount++;
          Preconditions.checkState(seriesCount <= currentBatchSize);
        }
      } else {

        // NOT selectedInUse

        if (bytesColVector.noNulls) {

          duplicateCounts[0] = 1;
          byte[] prevKeyBytes = vectorBytesArrays[0];
          int prevKeyStart = vectorStarts[0];
          int prevKeyLength = vectorLengths[0];
          serialize(0, prevKeyBytes, prevKeyStart, prevKeyLength);

          int currentKeyStart;
          int currentKeyLength;
          byte[] currentKeyBytes;
          for (int index = 1; index < currentBatchSize; index++) {
            currentKeyBytes = vectorBytesArrays[index];
            currentKeyStart = vectorStarts[index];
            currentKeyLength = vectorLengths[index];
            if (StringExpr.equal(prevKeyBytes, prevKeyStart, prevKeyLength,
                                 currentKeyBytes, currentKeyStart, currentKeyLength)) {
              duplicateCounts[seriesCount]++;
            } else {
              duplicateCounts[++seriesCount] = 1;
              serialize(seriesCount, currentKeyBytes, currentKeyStart, currentKeyLength);
              prevKeyBytes = currentKeyBytes;
              prevKeyStart = currentKeyStart;
              prevKeyLength = currentKeyLength;
            }
          }
          Arrays.fill(seriesIsAllNull, 0, ++seriesCount, false);
          nonNullKeyCount = seriesCount;
          Preconditions.checkState(seriesCount <= currentBatchSize);
        } else {
          boolean[] isNull = bytesColVector.isNull;

          boolean prevKeyIsNull;
          byte[] prevKeyBytes = null;
          int prevKeyStart = 0;
          int prevKeyLength = 0;
          duplicateCounts[0] = 1;
          if (isNull[0]) {
            seriesIsAllNull[0] = true;
            prevKeyIsNull = true;
          } else {
            seriesIsAllNull[0] = false;
            prevKeyIsNull = false;
            prevKeyBytes = vectorBytesArrays[0];
            prevKeyStart = vectorStarts[0];
            prevKeyLength = vectorLengths[0];
            serialize(0, prevKeyBytes, prevKeyStart, prevKeyLength);
            nonNullKeyCount = 1;
          }

          byte[] currentKeyBytes;
          int currentKeyStart;
          int currentKeyLength;
          for (int index = 1; index < currentBatchSize; index++) {
            if (isNull[index]) {
              if (prevKeyIsNull) {
                duplicateCounts[seriesCount]++;
              } else {
                duplicateCounts[++seriesCount] = 1;
                seriesIsAllNull[seriesCount] = true;
                prevKeyIsNull = true;
              }
            } else {
              currentKeyBytes = vectorBytesArrays[index];
              currentKeyStart = vectorStarts[index];
              currentKeyLength = vectorLengths[index];
              if (!prevKeyIsNull &&
                  StringExpr.equal(prevKeyBytes, prevKeyStart, prevKeyLength,
                                   currentKeyBytes, currentKeyStart, currentKeyLength)) {
                duplicateCounts[seriesCount]++;
              } else {
                duplicateCounts[++seriesCount] = 1;
                seriesIsAllNull[seriesCount] = false;
                serialize(nonNullKeyCount++, currentKeyBytes, currentKeyStart, currentKeyLength);
                prevKeyIsNull = false;
                prevKeyBytes = currentKeyBytes;
                prevKeyStart = currentKeyStart;
                prevKeyLength = currentKeyLength;
              }
            }
          }
          seriesCount++;
          Preconditions.checkState(seriesCount <= currentBatchSize);
        }
      }
    }

    // Finally.
    computeSerializedHashCodes();
    positionToFirst();
    Preconditions.checkState(validate());
  }
A key series of a single column of byte array keys where the keys get serialized.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/keyseries/VectorKeySeriesBytesSerialized.java