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 aggregation pipeline projection expressions #667

Closed
wants to merge 3 commits into from
Closed

Support for aggregation pipeline projection expressions #667

wants to merge 3 commits into from

Conversation

kothar
Copy link

@kothar kothar commented Nov 1, 2014

This is a patch to the Projections class which provides the option to build projection expressions which take lists of arguments, such as $add and $multiply.

Projection.projection("hour", Projection.subtract(
    Projection.projection("$hour", dateField),
    Projection.mod(Projection.projection("$hour", dateField), 6)))

I've tried to follow the style of the Group support for expressions, although I haven't implemented the analogue of the Accumulator class, as I wasn't sure how to approach nested projection expressions.

The type of the arguments to the expressions are not defined: just an Object list. This may need some improvement, but again, I'm not sure how to approach interchangeable field references, number literals and nested expressions.

A new test is included, which verifies that the $divide expression works as expected. Other expressions follow the same structure, and should be equivalent.

I've run gradlew check, which passes the style checks and the new unit test - let me know if you need anything else, or more tests.

Regards,
Mike.

evanchooly pushed a commit that referenced this pull request Dec 15, 2014
Squashed commit of the following:

commit 20f9533030a236ad77cf4eb8b58345cc667153a0
Author: Mike Houston <mike@stashmetrics.com>
Date:   Wed Dec 3 17:35:34 2014 +0000

    Added support for lists as arguments in Projection expressions

commit b09d6ddb4c8ef3a1840f213a148262ca3fc9dda1
Author: Mike Houston <mike@stashmetrics.com>
Date:   Sat Nov 1 19:18:39 2014 +0000

    Allow Projection objects with projectedField set to generate query expressions

commit 9dc51fd9d7bfab1017ceb0b853401ccbf2c91cfc
Author: Mike Houston <mike@stashmetrics.com>
Date:   Sat Nov 1 16:58:45 2014 +0000

    Support for aggregation pipeline projection expressions which take a list of arguments, such as $add, $subtract and $mod
@evanchooly
Copy link
Member

Thanks for the pull request. Merged in the hash below:

merged f47cde5

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