protected boolean doNextPage()

in jdbc/src/main/java/software/amazon/timestream/jdbc/TimestreamResultSet.java [179:217]


  protected boolean doNextPage() throws SQLException {
    if (((largeMaxRows != 0) && (totalRows >= largeMaxRows))
      || (result == null)
      || (result.getNextToken() == null)) {
      result = null;
      LOGGER.debug("Reached max rows limit or no more result sets.");
      return false;
    }

    final TimestreamResultHolder resultHolder = this.resultRetriever.getResult();
    result = resultHolder.queryResult;
    if (result == TERMINATION_MARKER) {
      LOGGER.debug("Retrieved a termination marker.");
      return false;
    }

    List<Row> rows = result.getRows();
    final int rowSize = rows.size();

    LOGGER.info(
      "QueryID: {}\nNumber of rows: {}", result.getQueryId(), rowSize);

    LOGGER.debug("Execution time to retrieve the next page: {}ms", resultHolder.executionTime);

    if (largeMaxRows != 0) {
      totalRows += rowSize;
      final long overflow = largeMaxRows - totalRows;
      if (overflow < 0) {
        // Silently truncate the extra rows.
        LOGGER.debug(
          "Total number of rows retrieved has exceeded max rows limit of {}, truncating the extra {} rows.",
          largeMaxRows,
          Math.abs(overflow));
        rows = rows.subList(0, rowSize - (int) Math.abs(overflow));
      }
    }
    rowItr = rows.iterator();
    return true;
  }