Package org.apache.ignite.sql.async
Interface AsyncResultSet<T>
- Type Parameters:
T- A type of the objects contained by this result set (when row set is present). This will be eitherSqlRowif no explicit mapper is provided or a particular type defined by supplied mapper.
- All Superinterfaces:
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));
}
-
Method Summary
Modifier and TypeMethodDescriptionlongReturns the number of rows affected by the DML statement execution (such as "INSERT", "UPDATE", etc.), or0if the statement returns nothing (such as "ALTER TABLE", etc), or-1if inapplicable.Invalidates a query result, stops the query, and cleans up query resources.Returns the current page content if the query returns rows.intReturns the current page size if the query return rows.CompletableFuture<? extends AsyncResultSet<T>>Fetches the next page of results asynchronously.booleanDefines whether the result of a query is a collection of rows or not.@Nullable ResultSetMetadatametadata()Returns metadata for query results.booleanIndicates 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
Returns metadata for query results. If the result set contains rows (hasRowSet(), returnstrue). If not applicable, returnsnull.- 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, callingcurrentPage()will fail, and eitheraffectedRows()return number of affected rows orwasApplied()returnstrue.- Returns:
Trueif a query returned rows,falseotherwise.
-
affectedRows
long affectedRows()Returns the number of rows affected by the DML statement execution (such as "INSERT", "UPDATE", etc.), or0if the statement returns nothing (such as "ALTER TABLE", etc), or-1if inapplicable.Note: If the method returns
-1, eitherhasRowSet()orwasApplied()returnstrue.- Returns:
- Number of rows affected by the query, or
0if the statement returns nothing, or-1if 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 returnstrueif the operation was successful orfalseif the operation was ignored because the table already existed.Note: If the method returns
false, then eitheraffectedRows()returns the number of affected rows, orhasRowSet()returnstrue, or the conditional DDL query is not applied.- Returns:
Trueif a conditional query is applied,falseotherwise.- See Also:
-
currentPage
Returns the current page content if the query returns rows.- Specified by:
currentPagein interfaceAsyncCursor<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:
currentPageSizein interfaceAsyncCursor<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 methodscurrentPage(),currentPageSize(),AsyncCursor.hasMorePages()use the current page and return consistent results between complete last page future and callfetchNextPage.- Specified by:
fetchNextPagein interfaceAsyncCursor<T>- Returns:
- A future which will be completed when next page will be fetched and set as the current page.
The future will return
thisfor 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:
closeAsyncin interfaceAsyncCursor<T>- Returns:
- Operation future.
-