private int subtract(int[] all, int allSize,
      int[] remove, int removeSize, int[] difference) throws HiveException {

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

    int differenceCount = 0;

    // Determine which rows are left.
    int removeIndex = 0;
    for (int i = 0; i < allSize; i++) {
      int candidateIndex = all[i];
      if (removeIndex < removeSize && candidateIndex == remove[removeIndex]) {
        removeIndex++;
      } else {
        difference[differenceCount++] = candidateIndex;
      }
    }

    if (removeIndex != removeSize) {
      throw new HiveException("Not all batch indices removed");
    }

    return differenceCount;
  }
Remove (subtract) members from an array and produce the results into
a difference array.
@param all
         The selected array containing all members.
@param allSize
         The size of all.
@param remove
         The indices to remove.  They must all be present in input selected array.
@param removeSize
         The size of remove.
@param difference
         The resulting difference -- the all array indices not in the
         remove array.
@return
         The resulting size of the difference array.
@throws HiveException
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/VectorMapJoinOuterGenerateResultOperator.java