Skip to content

Support for aggregation pipeline projection expressions#667

Closed
kothar wants to merge 3 commits intoMorphiaOrg:masterfrom
kothar:projection_expressions
Closed

Support for aggregation pipeline projection expressions#667
kothar wants to merge 3 commits intoMorphiaOrg:masterfrom
kothar:projection_expressions

Conversation

@kothar
Copy link
Copy Markdown

@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
Copy Markdown
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