private int sortMerge(int[] selected1, int selected1Count,
          int[] selected2, int selected2Count, int[] sortMerged) throws HiveException {

    // if (!verifyMonotonicallyIncreasing(selected1, selected1Count)) {
    //   throw new HiveException("selected1 is not in sort order and unique");
    // }

    // if (!verifyMonotonicallyIncreasing(selected2, selected2Count)) {
    //   throw new HiveException("selected1 is not in sort order and unique");
    // }


    int sortMergeCount = 0;

    int selected1Index = 0;
    int selected2Index = 0;
    for (int i = 0; i < selected1Count + selected2Count; i++) {
      if (selected1Index < selected1Count && selected2Index < selected2Count) {
        if (selected1[selected1Index] < selected2[selected2Index]) {
          sortMerged[sortMergeCount++] = selected1[selected1Index++];
        } else {
          sortMerged[sortMergeCount++] = selected2[selected2Index++];
        }
      } else if (selected1Index < selected1Count) {
        sortMerged[sortMergeCount++] = selected1[selected1Index++];
      } else {
        sortMerged[sortMergeCount++] = selected2[selected2Index++];
      }
    }

    // if (!verifyMonotonicallyIncreasing(sortMerged, sortMergeCount)) {
    //   throw new HiveException("sortMerged is not in sort order and unique");
    // }

    return sortMergeCount;
  }
Sort merge two select arrays so the resulting array is ordered by (batch) index.

@param selected1
@param selected1Count
@param selected2
@param selected2Count
@param sortMerged
         The resulting sort merge of selected1 and selected2.
@return
         The resulting size of the sortMerged array.
@throws HiveException
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/VectorMapJoinOuterGenerateResultOperator.java