@Override
    public T next() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      try {
        T result = rowMapper.apply(rs);
        hasNext = rs.next();
        if (!hasNext) {
          close();
        }
        return result;
      } catch (SQLException e) {
        throw new IllegalStateException("Could not read mbtiles file", e);
      }
    }
Iterates through the results of a query one at a time without materializing the entire list in memory.
planetiler-core/src/main/java/com/onthegomap/planetiler/mbtiles/Mbtiles.java