Interface AsyncResultSet<T>

Type Parameters:
T - A type of the objects contained by this result set (when row set is present). This will be either SqlRow if no explicit mapper is provided or a particular type defined by supplied mapper.
All Superinterfaces:
AsyncCursor<T>

public interface AsyncResultSet<T> extends AsyncCursor<T>
Provides methods for processing query results in an asynchronous way.

Usage example:


      private CompletionStage<Void> fetchAllRowsInto(
          AsyncResultSet resultSet,
          List<SqlRow> target
      ) {
          for (var row : resultSet.currentPage()) {
              target.add(row);
          }

          if (!resultSet.hasMorePages()) {
              return CompletableFuture.completedFuture(null);
          }

           return resultSet.fetchNextPage()
              .thenCompose(res -> fetchAllRowsInto(res, target));
      }
 
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the number of rows affected by the DML statement execution (such as "INSERT", "UPDATE", etc.), or 0 if the statement returns nothing (such as "ALTER TABLE", etc), or -1 if inapplicable.
    Invalidates a query result, stops the query, and cleans up query resources.
    Returns the current page content if the query returns rows.
    int
    Returns the current page size if the query return rows.
    Fetches the next page of results asynchronously.
    boolean
    Defines whether the result of a query is a collection of rows or not.
    Returns metadata for query results.
    boolean
    Indicates whether the query that had produced the result was a conditional query.

    Methods inherited from interface org.apache.ignite.lang.AsyncCursor

    hasMorePages
  • Method Details

    • metadata

      @Nullable @Nullable ResultSetMetadata metadata()
      Returns metadata for query results. If the result set contains rows (hasRowSet(), returns true). If not applicable, returns null.
      Returns:
      ResultSet Metadata.
      See Also:
    • hasRowSet

      boolean hasRowSet()
      Defines whether the result of a query is a collection of rows or not.

      Note: If the method returns false, calling currentPage() will fail, and either affectedRows() return number of affected rows or wasApplied() returns true.

      Returns:
      True if a query returned rows, false otherwise.
    • affectedRows

      long affectedRows()
      Returns the number of rows affected by the DML statement execution (such as "INSERT", "UPDATE", etc.), or 0 if the statement returns nothing (such as "ALTER TABLE", etc), or -1 if inapplicable.

      Note: If the method returns -1, either hasRowSet() or wasApplied() returns true.

      Returns:
      Number of rows affected by the query, or 0 if the statement returns nothing, or -1 if not applicable.
      See Also:
    • wasApplied

      boolean wasApplied()
      Indicates whether the query that had produced the result was a conditional query. E.g., for query "Create table if not exists", the method returns true if the operation was successful or false if the operation was ignored because the table already existed.

      Note: If the method returns false, then either affectedRows() returns the number of affected rows, or hasRowSet() returns true, or the conditional DDL query is not applied.

      Returns:
      True if a conditional query is applied, false otherwise.
      See Also:
    • currentPage

      Iterable<T> currentPage()
      Returns the current page content if the query returns rows.
      Specified by:
      currentPage in interface AsyncCursor<T>
      Returns:
      Iterable set of rows.
      Throws:
      NoRowSetExpectedException - if no row set is returned.
    • currentPageSize

      int currentPageSize()
      Returns the current page size if the query return rows.
      Specified by:
      currentPageSize in interface AsyncCursor<T>
      Returns:
      The size of currentPage().
      Throws:
      NoRowSetExpectedException - if no row set is returned.
    • fetchNextPage

      CompletableFuture<? extends AsyncResultSet<T>> fetchNextPage()
      Fetches the next page of results asynchronously. The current page is changed after the future completion. The methods currentPage(), currentPageSize(), AsyncCursor.hasMorePages() use the current page and return consistent results between complete last page future and call fetchNextPage.
      Specified by:
      fetchNextPage in interface AsyncCursor<T>
      Returns:
      A future which will be completed when next page will be fetched and set as the current page. The future will return this for chaining.
      Throws:
      NoRowSetExpectedException - If no row set is expected as a query result.
      CursorClosedException - If cursor is closed.
    • closeAsync

      CompletableFuture<Void> closeAsync()
      Invalidates a query result, stops the query, and cleans up query resources.
      Specified by:
      closeAsync in interface AsyncCursor<T>
      Returns:
      Operation future.