public boolean next()

in src/main/java/com/aliyun/odps/jdbc/OdpsForwardResultSet.java [120:168]


  public boolean next() throws SQLException {
    checkClosed();

    if (fetchedRows == totalRows) {
      return false;
    }

    // Tolerate the network problem by simply reopen the reader
    int retry = 0;
    while (true) {
      try {
        if (reader == null) {
          rebuildReader();
        }
        reuseRecord = reader.read(reuseRecord);
        if (reuseRecord == null) {
          // this means the end of stream
          long end = System.currentTimeMillis();
          conn.log.info(
              "It took me " + (end - startTime) + " ms to fetch all records, count:" + fetchedRows);
          return false;
        }
        int columns = reuseRecord.getColumnCount();
        currentRow = new Object[columns];
        for (int i = 0; i < columns; i++) {
          currentRow[i] = reuseRecord.get(i);
        }

        fetchedRows++;
        // Log the time consumption for fetching a bunch of rows
        if (fetchedRows % ACCUM_FETCHED_ROWS == 0 && fetchedRows != 0) {
          long current = System.currentTimeMillis();
          conn.log.info(
              String.format("fetched %d rows, %d KB, %.2f KB/s",
                            fetchedRows,
                            reader.getTotalBytes() / 1000,
                            (float) reader.getTotalBytes() / (current - startTime))
          );
        }
        return true;
      } catch (IOException e) {
        conn.log.info("read from a bad file, retry=" + retry);
        if (++retry == READER_REOPEN_TIME_MAX) {
          throw new SQLException("to much retries because: " + e.getMessage());
        }
        rebuildReader();
      }
    }
  }