You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working with CursorResult and CursorRawResult classes. Both of them implement the Iterable interface, enabling us to iterate more than once over the result.
However, the iterator method returns always the same iterator and thus the result can only be consumed once.
@OverridepublicIterator<T> iterator() {
if (iter == null) {
iter = newCursorIterator();
}
returniter;
}
It makes perfectly sense that the result can only be consumed once, because the cursor of the DB is also moved with continueQuery method. One could aggregate the results instead of overwriting it and always provide a new iterator. But the list can grow huge and there is also the asList method.
Wouldn't it be more clear for the user if CursorResult and CursorRawResult would implement the Iterator interface, indicating that it can only be consumed once?
And the asList method returns only a complete list if no object is already consumed from the iterator. Should the asList method be called asListRemaining just like the forEachRemaining of the Iterator interface? Or completely remove this method to avoid confusing?
The text was updated successfully, but these errors were encountered:
christian-lechner
changed the title
Cursor(Raw)Result: why do they implement the Iterable interface?
Cursor(Raw)Result: why do they implement the Iterable interface and not the Iterator interface?
Sep 21, 2016
christian-lechner
changed the title
Cursor(Raw)Result: why do they implement the Iterable interface and not the Iterator interface?
Cursor(Raw)Result: shouldn't they implement the Iterator interface instead of the Iterable interface?
Sep 21, 2016
Thanks for your feedback. This is a really good point.
Currently we rewrite the Java Driver. It gets a new api, async and VelocyPack/VelocyStream under the hood.
I already changed the implementation of our new cursor with your input. (which your can find here)
The new driver version will probably be released by the end of the month, but you can already try it out. (Branch 4.0)
Your feedback is much appreciated.
Hello!
I'm currently working with
CursorResult
andCursorRawResult
classes. Both of them implement theIterable
interface, enabling us to iterate more than once over the result.However, the
iterator
method returns always the same iterator and thus the result can only be consumed once.It makes perfectly sense that the result can only be consumed once, because the cursor of the DB is also moved with
continueQuery
method. One could aggregate the results instead of overwriting it and always provide a new iterator. But the list can grow huge and there is also theasList
method.Wouldn't it be more clear for the user if
CursorResult
andCursorRawResult
would implement theIterator
interface, indicating that it can only be consumed once?And the
asList
method returns only a complete list if no object is already consumed from the iterator. Should theasList
method be calledasListRemaining
just like theforEachRemaining
of theIterator
interface? Or completely remove this method to avoid confusing?The text was updated successfully, but these errors were encountered: