Constructor and Description |
---|
GraphResultSet(ResultSet wrapped)
This constructor is intended for internal use only, users should normally obtain instances from
DseSession.executeGraph(GraphStatement) . |
GraphResultSet(ResultSet wrapped,
Function<Row,GraphNode> transformResultFunction) |
Modifier and Type | Method and Description |
---|---|
List<GraphNode> |
all()
Returns all the remaining results as a list.
|
ListenableFuture<GraphResultSet> |
fetchMoreResults()
Force fetching the next page of results for this result set, if any.
|
List<ExecutionInfo> |
getAllExecutionInfo()
Returns the execution information for all queries made to retrieve this result set.
|
int |
getAvailableWithoutFetching()
The number of results that can be retrieved without blocking to fetch.
|
ExecutionInfo |
getExecutionInfo()
Returns information on the execution of the last query made for this result set.
|
boolean |
isExhausted()
Returns whether there are more results.
|
boolean |
isFullyFetched()
Whether all results have been fetched from the database.
|
Iterator<GraphNode> |
iterator()
Returns an iterator over the results.
|
GraphNode |
one()
Returns the next result.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public GraphResultSet(ResultSet wrapped)
DseSession.executeGraph(GraphStatement)
.public boolean isExhausted()
public GraphNode one()
null
if there are no more of them.public List<GraphNode> all()
iterator()
or successive calls to one()
, this method force-fetches all
remaining results from the server, holding them all in memory. It is thus recommended to prefer iterations
through iterator()
when possible, especially when there is a large number of results.exhausted
. The result set will be exhausted after a call to this method.public Iterator<GraphNode> iterator()
Iterator.next()
method is equivalent to calling one()
. After a full iteration, the result set
will be exhausted
.
The returned iterator does not support the Iterator.remove()
method.public int getAvailableWithoutFetching()
isFullyFetched()
, this is the total number of
results remaining, otherwise going past that limit will trigger background fetches.public boolean isFullyFetched()
isFullyFetched()
, then getAvailableWithoutFetching()
will return the number of results
remaining before exhaustion.
But !isFullyFetched()
does not necessarily mean that the result set is not exhausted (you should call
isExhausted()
to verify it).public ListenableFuture<GraphResultSet> fetchMoreResults()
one()
, all()
or iteration)
when needed (i.e. when getAvailableWithoutFetching() == 0
and
isFullyFetched() == false
).
You can however call this method manually to force the fetching of the
next page of results. This can allow to prefetch results before they are
strictly needed. For instance, if you want to prefetch the next page of
results as soon as there is less than 100 rows readily available in this
result set, you can do:
GraphResultSet rs = session.executeGraph(...); Iterator<GraphNode> iter = rs.iterator(); while (iter.hasNext()) { if (rs.getAvailableWithoutFetching() == 100 && !rs.isFullyFetched()) rs.fetchMoreResults(); GraphNode result = iter.next() ... process the result ... }This method is not blocking, so in the example above, the call to
fetchMoreResults
will not block the processing of the 100 currently available
results (but iter.hasNext()
will block once those results have been processed
until the fetch query returns, if it hasn't yet).
Only one page of results (for a given result set) can be
fetched at any given time. If this method is called twice and the query
triggered by the first call has not returned yet when the second one is
performed, then the 2nd call will simply return a future on the currently
in progress query.isFullyFetched() == true
),
then the returned future will return immediately, but not particular error will be
thrown (you should thus call isFullyFetched() to know if calling this
method can be of any use
).public ExecutionInfo getExecutionInfo()
ExecutionInfo
for the last query
performed. To retrieve the information for all queries, use getAllExecutionInfo()
.
The returned object includes basic information such as the queried hosts,
but also the Cassandra query trace if tracing was enabled for the query.public List<ExecutionInfo> getAllExecutionInfo()
ExecutionInfo
for all the queries done to obtain the
results (at the time of the call), in the order those queries were made.
If no paging was used (because the result set was small enough), the list only contains one element.Copyright © 2012–2018. All rights reserved.