public boolean advanceResultSetToOffset()

in server/src/main/java/org/apache/calcite/avatica/jdbc/StatementInfo.java [97:138]


  public boolean advanceResultSetToOffset(ResultSet results, long offset) throws SQLException {
    if (offset < 0 || offset < position) {
      throw new IllegalArgumentException("Offset should be "
        + " non-negative and not less than the current position. " + offset + ", " + position);
    }
    if (position >= offset) {
      return true;
    }

    if (null == relativeSupported) {
      Boolean moreResults = null;
      synchronized (this) {
        if (null == relativeSupported) {
          try {
            moreResults = advanceByRelative(results, offset);
            relativeSupported = true;
          } catch (SQLFeatureNotSupportedException e) {
            relativeSupported = false;
          }
        }
      }

      if (null != moreResults) {
        // We figured out whether or not relative is supported.
        // Make sure we actually do the necessary work.
        if (!relativeSupported) {
          // We avoided calling advanceByNext in the synchronized block earlier.
          moreResults = advanceByNext(results, offset);
        }

        return moreResults;
      }

      // Another thread updated the RELATIVE_SUPPORTED before we did, fall through.
    }

    if (relativeSupported) {
      return advanceByRelative(results, offset);
    } else {
      return advanceByNext(results, offset);
    }
  }