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()
Deprecated.
|
List<ExecutionInfo> |
getAllExecutionInfo()
Returns the execution information for all queries made to retrieve this result set.
|
int |
getAvailableWithoutFetching()
Deprecated.
|
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()
Deprecated.
|
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()
public Iterator<GraphNode> iterator()
The 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.
@Deprecated public int getAvailableWithoutFetching()
all()
is recommended instead to gather all the results
coming back from a DSE Graph query.
The number of results that can be retrieved without blocking to fetch.
isFullyFetched()
, this is the
total number of results remaining, otherwise going past that limit will trigger background
fetches.@Deprecated public boolean isFullyFetched()
Whether all results have been fetched from the database.
If 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).
@Deprecated public ListenableFuture<GraphResultSet> fetchMoreResults()
Force fetching the next page of results for this result set, if any.
This method is entirely optional. It will be called automatically while the result set is
consumed (through 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()
Note that in most cases, a result set is fetched with only one query, but large result sets
can be paged and thus be retrieved by multiple queries. In that case this method return the
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()
If paging was used, the returned list contains the 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.