private int subtractFromInputSelected(boolean inputSelectedInUse, int inputLogicalSize,
      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;
   if (inputSelectedInUse) {
     for (int i = 0; i < inputLogicalSize; i++) {
       int candidateIndex = inputSelected[i];
       if (removeIndex < removeSize && candidateIndex == remove[removeIndex]) {
         removeIndex++;
       } else {
         difference[differenceCount++] = candidateIndex;
       }
     }
   } else {
     for (int candidateIndex = 0; candidateIndex < inputLogicalSize; candidateIndex++) {
       if (removeIndex < removeSize && candidateIndex == remove[removeIndex]) {
         removeIndex++;
       } else {
         difference[differenceCount++] = candidateIndex;
       }
     }
   }

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

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

   return differenceCount;
 }
Remove (subtract) members from the input selected array and produce the results into
a difference array.

@param inputSelectedInUse
         Whether the (original) input batch is selectedInUse.
@param inputLogicalSize
         The (original) input batch size.
@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 input selected 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