V
- type of the object contained in the result set.public interface ObjectResultSet<V> extends Iterable<V>
Set of objects that represent the result of a query. This class closely
resembles Cassandra's ResultSet
. Basically, it provides the same
methods but deals with typed objects instead of CQL rows.
This design is intended to make it very easy to wrap a ResultSet
in a ObjectResultSet
while retaining the possibility to
implement a ObjectResultSet
that is not based on a
ResultSet
.
Implementations of this interface have to be expected to be not thread safe.
Modifier and Type | Interface and Description |
---|---|
static class |
ObjectResultSet.ObjectResultSetIterator<V>
Simple implementation of an iterator that consumes a object result-set.
|
Modifier and Type | Method and Description |
---|---|
List<V> |
all()
Returns all remaining objects in this object result-set as a list.
|
ListenableFuture<Void> |
fetchMoreResults()
Forces fetching the next page of object for this object result-set.
|
int |
getAvailableWithoutFetching()
Returns the number of objects that can be retrieved from this object
result-set without blocking to fetch.
|
boolean |
isExhausted()
Tells whether this object result-set has more objects.
|
boolean |
isFullyFetched()
Tells whether all objects from this object result set have been fetched
from the database.
|
Iterator<V> |
iterator()
Returns an iterator over the objects contained in this object result-set.
|
V |
one()
Returns the next object from this object result-set.
|
forEach, spliterator
List<V> all()
Returns all remaining objects in this object result-set as a list.
Calls to this method will block until all objects have been retrieved from the database.
Note that, contrary to iterator()
or successive calls to
one()
, this method forces fetching the full content of the object
result-set at once, holding it all in memory in particular. It is thus
recommended to prefer iterations through iterator()
when
possible, especially if the result set can be big.
ListenableFuture<Void> fetchMoreResults()
Forces fetching the next page of object for this object result-set.
The use of 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 objects. This can allow to prefetch objects before they are strictly needed.
This method is not blocking. However, hasNext()
on the
iterator returned by iterator()
or calling one()
will
block until the fetch query returns if all objects that have been fetched
previously have already been returned.
Only one page of objects (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 second call will simply return a future on the currently in progress query.
isFullyFetched() == true
), then the returned future
will return immediately (you should thus call
isFullyFetched()
to know if calling this method can be
of any use}).int getAvailableWithoutFetching()
isFullyFetched()
, this is the total number of objects
remaining in this result set (after which the result set will be
exhausted).boolean isExhausted()
Tells whether this object result-set has more objects.
Calls to this method may block if
getAvailableWithoutFetching() == 0
and
isFullyFetched() == false
.
true
if this object result-set is exhausted (
one() == null
), false
if there are
objects left in this result set.boolean isFullyFetched()
Tells whether all objects from this object result set have been fetched from the database.
Note that if this method returns true
, then
getAvailableWithoutFetching()
will return how many objects remain
in the result set before exhaustion. However, if this method returns
false
, this does not guarantee that the result set is not
exhausted (you should call isExhausted()
to verify it).
true
if all objects have been fetched,
false
if there might be more objects that have not
been loaded from the database yet.Iterator<V> iterator()
Returns an iterator over the objects contained in this object result-set.
Calls to the Iterator.hasNext()
method may block if
getAvailableWithoutFetching() == 0
and
isFullyFetched() == false
.
The Iterator.next()
method is equivalent to calling
one()
. So this iterator will consume objects from this result
set and after a full iteration, the result set will be empty.
The returned iterator does not support the Iterator.remove()
method.
V one()
Returns the next object from this object result-set.
Calls to this method may block if
getAvailableWithoutFetching() == 0
and
isFullyFetched() == false
.
null
if
this result set is exhausted.Copyright © 2011–2016 aquenos GmbH. All rights reserved.