-
Notifications
You must be signed in to change notification settings - Fork 1.1k
DATAMONGO-1165 - Add support for Streaming large result lists. #274
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
Conversation
c9e497e
to
5eecc33
Compare
Initial PoC for a MongoDB Cursor backed Iterator that allows fetching of large result sets. Original pull request: #274.
There are a few aspects we should improve on here:
|
Prepare issue branch.
Initial PoC for a MongoDB Cursor backed Iterator that allows fetching of large result sets. Original pull request: #274.
Initial support for CloteableIterable and Java 8 Stream as return type of custom Repository finder methods.
5eecc33
to
2144209
Compare
/** | ||
* @author Thomas Darimont | ||
*/ | ||
final class StreamExecution extends CursorBackedExecution { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it's possible to move that into Spring Data Commons and rather turn it into a post-processing step in case the execution returns a CloseableIterable
but effectively needs to be a Stream
(similarly to what we already do with Optional
s. I think this would allow us to automatically support Stream
as return type on all stores that implement the execution into a ClosableIterable
.
Added ExceptionTranslation to CloseableIterableCursorAdapter.
Introduced new executeAsStream(..) method to MongoOperations in the context of pushing cursor creation and wrapping in CloseableIterator down to MongoTemplate.
final class StreamExecution extends CursorBackedExecution { | ||
|
||
@Override | ||
Object execute(Query query) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think part of this code could be moved to SD Commons.
Added support for translation of MongoDB Exceptions as well as potential event propagation via ReadDbObjectCallback in MongoTemplate.executeAsStream(..).
Adapted Java 8 Stream creation to new Java8StreamUtils from SD Commons.
…ository methods. Added support for a MongoDB Cursor backed Iterator that allows the usage of a Java 8 Stream at the repository level. Original pull request: #274.
Renamed MongoOperations executeAsStream(…) to stream(…). Make use of Spring Data Commons StreamUtils in AbstractMongoQuery's StreamExecution. Moved test case from PersonRepositoryIntegrationTests to AbstractPersonRepositoryIntegrationTests to make sure they're executed for all sub-types. Original pull request: #274.
Renamed MongoOperations executeAsStream(…) to stream(…). Make use of Spring Data Commons StreamUtils in AbstractMongoQuery's StreamExecution. Moved test case from PersonRepositoryIntegrationTests to AbstractPersonRepositoryIntegrationTests to make sure they're executed for all sub-types. Original pull request: #274.
Initial PoC for a MongoDB Cursor backed Iterator that allows fetching of large result sets.