Skip to content
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 map-reduce operations in MongoTemplate [DATAMONGO-7] #945

Closed
spring-projects-issues opened this issue Dec 1, 2010 · 7 comments
Labels
in: core Issues in core support type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link

Mark Pollack opened DATAMONGO-7 and commented

The use of MapReduce via the driver is cumbersome, provide a layer that exposes map reduce operations with type-safe helper objects.

Investigate: http://cookbook.mongodb.org/ lists a few common cases where one would use map-reduce, typically to sort/count document array elements. See how this might be better packaged up so as to avoid Java users from having to write JavaScript/MapReduce for common tasks


Issue Links:

  • DATAMONGO-182 add 'group' and 'mapreduce' to the MongoOps
    ("Cloned from")

1 votes, 1 watchers

@spring-projects-issues
Copy link
Author

Matthias Scudlik commented

group by (like sql) integration with min/max/sum etc. in the Criteria API would be very useful

@spring-projects-issues
Copy link
Author

Mark Pollack commented

looks like 1.9 will have this - http://jira.mongodb.org/browse/SERVER-447

@spring-projects-issues
Copy link
Author

Matthias Scudlik commented

Will this be added to the Criteria API, once 1.9 is out?
How do you handle that spring-document-mongodb is compatible to various mongodb versions?

@spring-projects-issues
Copy link
Author

Mark Pollack commented

I think we will add features into the API to track the latest releases, these would then fail on an older server. Documenting this seems enough for now I think, we could add some server number checks as well. FWIW, the aggregation framework was move to 2.1, due date is now in Oct 2011

@spring-projects-issues
Copy link
Author

Matthias Scudlik commented

I think you're right, but only with the new aggregation framework. All of these features can be done with map reduce as well i think. So the question is whether you can reverse engineer parts of it with map reduce

@spring-projects-issues
Copy link
Author

Mark Pollack commented

The API i'm thinking of implementing is looking like like what is in the C# driver.

<T> MapReduceResult<T> mapReduce(String map, String reduce, Class<T> entityClass )

<T> MapReduceResult<T> mapReduce(String map, String reduce, MapReduceOptions options, Class<T> entityClass )

<T> MapReduceResult<T> mapReduce(Query query, String map, String reduce, Class<T> entityClass)

<T> MapReduceResult<T> mapReduce(Query query, String map, String reduce, MapReduceOptions options, Class<T> entityClass)

where you can create MapReduceOptions in a fluent API style like this

public static MapReduceOptions options() { return new MapReduceOptions() } // possible pass in some common options in a ctor arg

public static MapReduceOutput replace(String collectionName) {
new MapReduceOutput...
}

options().output(MapReduceOutput.replace(collectionName))
options().output(replace(collectionName))

//default is replace
options().output(collectionName, databaseName))
options().output(collectionName)

options().finalize(finalize)

etc...

Strings will be attempted to be converted to a Spring resource URI so they can be picked up via the classpath or such this way map and reduce .js files can live separately.

Using an extended criteria API just for map reduce, e.g. min-max might be possible in that one could generate the .js files on the fly for simple cases. I'd need to play with it a bit more as the more I dig into it the more delicate it seems to provide a general solution.

What do you think?

@spring-projects-issues
Copy link
Author

Matthias Scudlik commented

I think this is a good solution. One can provide .js files for own UseCases but you also support the common functions like min and max.

Note:
You probably need some placeholders in the .js files

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core support labels Dec 30, 2020
@spring-projects-issues spring-projects-issues added this to the 1.0 M4 milestone Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core support type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant