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 eitherSqlRow
if 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 TypeMethodDescriptionlong
Returns the number of rows affected by the DML statement execution (such as "INSERT", "UPDATE", etc.), or0
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.CompletableFuture<? extends AsyncResultSet<T>>
Fetches the next page of results asynchronously.boolean
Defines whether the result of a query is a collection of rows or not.@Nullable ResultSetMetadata
metadata()
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
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:
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.), or0
if the statement returns nothing (such as "ALTER TABLE", etc), or-1
if inapplicable.Note: If the method returns
-1
, eitherhasRowSet()
orwasApplied()
returnstrue
.- 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 returnstrue
if the operation was successful orfalse
if 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:
True
if a conditional query is applied,false
otherwise.- See Also:
-
currentPage
Returns the current page content if the query returns rows.- Specified by:
currentPage
in 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:
currentPageSize
in 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:
fetchNextPage
in 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
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 interfaceAsyncCursor<T>
- Returns:
- Operation future.
-