Skip to content

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

Closed
wants to merge 8 commits into from

Conversation

thomasdarimont
Copy link

Initial PoC for a MongoDB Cursor backed Iterator that allows fetching of large result sets.

thomasdarimont pushed a commit that referenced this pull request Feb 16, 2015
Initial PoC for a MongoDB Cursor backed Iterator that allows fetching of large result sets.

Original pull request: #274.
@odrotbohm
Copy link
Member

There are a few aspects we should improve on here:

  • I'd like to avoid additions to MongoTemplate / MongoOperations in the first place. I think the executions should basically call MongoOperations.execute(…) with a callback to make sure we get exception translation applied. Also we need to make sure to publish the application events before and after mapping. MongoTemplate contains all necessary callbacks, we might just need to make some of them public to reuse them appropriately.
  • I think we should focus on Iterable as return type, not Iterator.
  • While a lot of the wording in the introduced code talks about streams there's no dedicated support for a Java 8 Stream yet. While I can see that we probably can generically map from Iterable to Stream throuhg some code in Spring Data Commons, I think we should be consistent in terms of the terms we use to describe scenarios.
  • The newly introduced interfaces probably should make it into Spring Data Commons, too.

Thomas Darimont added 4 commits February 24, 2015 16:56
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.
/**
* @author Thomas Darimont
*/
final class StreamExecution extends CursorBackedExecution {
Copy link
Member

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 Optionals. I think this would allow us to automatically support Stream as return type on all stores that implement the execution into a ClosableIterable.

Thomas Darimont added 2 commits February 25, 2015 17:39
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) {
Copy link
Author

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.

Thomas Darimont added 2 commits March 2, 2015 17:17
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.
thomasdarimont pushed a commit that referenced this pull request Mar 3, 2015
…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.
odrotbohm added a commit that referenced this pull request Mar 3, 2015
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.
odrotbohm added a commit that referenced this pull request Mar 3, 2015
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.
@odrotbohm odrotbohm closed this Mar 5, 2015
@odrotbohm odrotbohm deleted the issue/DATAMONGO-1165 branch March 5, 2015 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants