private int fetchNext()

in parquet-column/src/main/java/org/apache/parquet/internal/column/columnindex/IndexIterator.java [133:167]


      private int fetchNext() {
        if ((peekL == -1 && peekR == -1) && (!lhs.hasNext() && !rhs.hasNext())) {
          return -1;
        }

        if (peekL == -1 && lhs.hasNext()) {
          peekL = lhs.next();
        }

        if (peekR == -1 && rhs.hasNext()) {
          peekR = rhs.next();
        }

        // Return the smaller of the two next iterator values
        int result;
        if (peekL != -1 && (peekL == peekR || peekR == -1)) {
          // If RHS is exhausted or intersects with LHS, return l and throw away r to avoid duplicates
          result = peekL;
          peekL = -1;
          peekR = -1;
        } else if (peekL == -1 && peekR != -1) {
          // If LHS is exhausted, return RHS
          result = peekR;
          peekR = -1;
        } else if (peekL < peekR) {
          // If LHS value is smaller than RHS value, return LHS
          result = peekL;
          peekL = -1;
        } else {
          // If RHS value is smaller than LHS value, return RHS
          result = peekR;
          peekR = -1;
        }
        return result;
      }