protected int binarySearchBack(int rowId, PTFPartition p, Object sortKey, int amt,
      Order order) throws HiveException {
    boolean isOrderDesc = order.equals(Order.DESC);
    Object rowVal = null;

    int rMin = 0;  // tracks lowest possible number fulfilling the range requirement
    int rMax = rowId; // tracks highest possible number fulfilling the range requirement

    boolean isDistanceGreater = true;
    while (rMin < rMax) {
      rowVal = computeValueUseCache(rowId, p);
      isDistanceGreater = isDistanceGreater(isOrderDesc ? rowVal : sortKey, isOrderDesc ? sortKey : rowVal, amt);
      if (isDistanceGreater) {
        rMin = rowId + 1;
      } else {
        rMax = rowId;
      }
      rowId = rMin + (rMax - rMin) / 2;
    }
    return rMin;
  }
Checks if the values of v1 or v2 are the same.
@return True if both values are the same or both are nulls.
ql/src/java/org/apache/hadoop/hive/ql/udf/ptf/ValueBoundaryScanner.java