public interface AsyncPagingIterable<ElementT,SelfT extends AsyncPagingIterable<ElementT,SelfT>>
Modifier and Type | Method and Description |
---|---|
Iterable<ElementT> |
currentPage()
The elements in the current page.
|
CompletionStage<SelfT> |
fetchNextPage()
Fetch the next page of results asynchronously.
|
ColumnDefinitions |
getColumnDefinitions()
Metadata about the columns returned by the CQL request that was used to build this result.
|
ExecutionInfo |
getExecutionInfo()
Returns information about the execution of this page of results.
|
boolean |
hasMorePages()
Whether there are more pages of results.
|
default <TargetT> MappedAsyncPagingIterable<TargetT> |
map(Function<? super ElementT,? extends TargetT> elementMapper)
Creates a new instance by transforming each element of this iterable with the provided
function.
|
default ElementT |
one()
Returns the next element, or
null if the results are exhausted. |
int |
remaining()
How many rows are left before the current page is exhausted.
|
boolean |
wasApplied()
If the query that produced this result was a CQL conditional update, indicate whether it was
successfully applied.
|
@NonNull ColumnDefinitions getColumnDefinitions()
@NonNull ExecutionInfo getExecutionInfo()
int remaining()
@NonNull Iterable<ElementT> currentPage()
hasMorePages()
and fetchNextPage()
.
Note that this method always returns the same object, and that that object can only be iterated once: elements are "consumed" as they are read.
@Nullable default ElementT one()
null
if the results are exhausted.
This is convenient for queries that are known to return exactly one element, for example count queries.
boolean hasMorePages()
fetchNextPage()
to fetch the next
one asynchronously.@NonNull CompletionStage<SelfT> fetchNextPage() throws IllegalStateException
IllegalStateException
- if there are no more pages. Use hasMorePages()
to check
if you can call this method.boolean wasApplied()
For consistency, this method always returns true
for non-conditional queries
(although there is no reason to call the method in that case). This is also the case for
conditional DDL statements (CREATE KEYSPACE... IF NOT EXISTS
, CREATE TABLE... IF
NOT EXISTS
), for which Cassandra doesn't return an [applied]
column.
Note that, for versions of Cassandra strictly lower than 2.1.0-rc2, a server-side bug (CASSANDRA-7337) causes this
method to always return true
for batches containing conditional queries.
default <TargetT> MappedAsyncPagingIterable<TargetT> map(Function<? super ElementT,? extends TargetT> elementMapper)
Note that both instances share the same underlying data: consuming elements from the transformed iterable will also consume them from this object, and vice-versa.
Copyright © 2017–2024. All rights reserved.