-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for-each loop and forEach() for OracleCursor #6
Comments
We've considered various ways to support "for each" with the Cursor, but it's not doable. The issue is having to implement Iterable/Iterator, those are not appropriate for the Cursor (for example, we want to throw custom SODA exceptions from next(), with SQLException attached as the cause, which we can't do with the Iterator next()). We could potentially add getDocuments(), which will return all the documents fetched by the operation as some kind of an array, and you'd be able to use the "for each" loop on that. We'll look into it. As far as Java 8 forEach, will investigate to see what we can do. |
You could always define an unchecked exception but then it isn't clear to me how the close() would be communicated (e.g. on error, early exit, etc). Lambdas may be a better fit. Something like
https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html |
We considered unchecked exceptions but didn't want to go that route. For forEach, I'll look into it. |
OracleCursor
should be enabled to to be used in the Java for-each loop as well as the Java 8 forEach() streams implementation. The.getCursor()
operation will return a cursor to self-containedOracleDocument
objects. Right now the user has to write ugly boiler plate code to iterate over these documents, e.g.:This should be simplified to allow the user to use the for-each construct instead:
The text was updated successfully, but these errors were encountered: