public static String longArrayToRangesString(long selection[], int size) {
    if (size == 0) {
      return "[]";
    }

    StringBuilder sb = new StringBuilder();

    // Use ranges and duplicate multipliers to reduce the size of the display.
    sb.append("[");
    int firstIndex = 0;
    long firstValue = selection[0];

    boolean duplicates = false;

    int i = 1;
    for ( ; i < size; i++) {
      long newValue = selection[i];
      if (newValue == selection[i - 1]) {

        // Duplicate.
        duplicates = true;

        if (newValue == firstValue) {
          continue;
        } else {
          // Prior none, singleton, or range?
          int priorRangeLength = i - 1 - firstIndex;

          if (priorRangeLength == 0) {
            continue;
          }
          if (firstIndex > 0) {
            sb.append(",");
          }
          sb.append(firstValue);
          if (priorRangeLength > 1) {
            sb.append(".." + selection[i - 2]);
          }
          firstIndex = i - 1;
          firstValue = newValue;
          continue;
        }
      } else {
        if (duplicates) {
          int numDuplicates = i - firstIndex;
          if (firstIndex > 0) {
            sb.append(",");
          }
          sb.append(numDuplicates + "*" + firstValue);
          duplicates = false;
          firstIndex = i;
          firstValue = newValue;
          continue;
        } if (newValue == selection[i - 1] + 1) {
          // Continue range..
          continue;
        } else {
          // Prior singleton or range?
          int priorRangeLength = i - firstIndex;
          if (firstIndex > 0) {
            sb.append(",");
          }
          sb.append(firstValue);
          if (priorRangeLength > 1) {
            sb.append(".." + selection[i - 1]);
          }
          firstIndex = i;
          firstValue = newValue;
          continue;
        }
      }
    }
    if (duplicates) {
      int numDuplicates = i - firstIndex;
      if (firstIndex > 0) {
        sb.append(",");
      }
      sb.append(numDuplicates + "*" + firstValue);
    } else {
      // Last singleton or range?
      int priorRangeLength = i - firstIndex;
      if (firstIndex > 0) {
        sb.append(",");
      }
      sb.append(firstValue);
      if (priorRangeLength > 1) {
        sb.append(".." + selection[i - 1]);
      }
    }
    sb.append("]");
    return sb.toString();
  }
On close, make sure a partially filled overflow batch gets forwarded.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/mapjoin/VectorMapJoinGenerateResultOperator.java