protected int computeEndCurrentRow(int rowIdx, PTFPartition p) throws HiveException {
    Object sortKey = computeValueUseCache(rowIdx, p);

    // Use Case 6.
    if ( sortKey == null ) {
      while ( sortKey == null && rowIdx < p.size() ) {
        Pair<Integer, Object> stepResult = skipOrStepForward(rowIdx, p);
        rowIdx = stepResult.getLeft();
        sortKey = stepResult.getRight();
      }
      return rowIdx;
    }

    Object rowVal = sortKey;
    int r = rowIdx;

    // Use Case 7.
    while (r < p.size() && isEqual(sortKey, rowVal) ) {
      Pair<Integer, Object> stepResult = skipOrStepForward(r, p);
      r = stepResult.getLeft();
      rowVal = stepResult.getRight();
    }
    return r;
  }
Uses cache to lookup row value. Computes it on the fly on cache miss.
@param r
@param p
@return row value.
@throws HiveException
ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/ValueBoundaryScanner.java