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

Streaming Aggregation #38

Closed
whitfin opened this issue Dec 22, 2016 · 3 comments
Closed

Streaming Aggregation #38

whitfin opened this issue Dec 22, 2016 · 3 comments

Comments

@whitfin
Copy link

whitfin commented Dec 22, 2016

It seems that there's no reason why aggregations can't be streamed, is there a chance support can be added for this?

@kofrasa
Copy link
Owner

kofrasa commented Dec 23, 2016

Thanks for the question zackehh.

I did consider streaming aggregations early in the implementation, but then realized that it is not feasible due to $group and $sort operations which must operate on the entire collection.

The current streaming implementation for queries is not lazy and it was introduced to mimic MongoDB API interface so users can almost copy + paste code. That said, it is possible to do streaming subject to these constraints.

  1. Ensuring the collection is immutable
  2. Enforcing rules for streaming functionality (no $sort, $group etc)

Streaming can be implemented in one of two ways.

  1. Using an iterator with chained functions
  2. Using the new coroutine and/or generator functions in modern javascript.

Although I haven't settled on a position yet, there are some constraints I have place on the project to guide development. This include making Mingo a zero-dependency library and backward compatible for not too old browser version. So these will inform the implementation choice.

Please let me know whether this answers your question.

Thanks.

@kofrasa
Copy link
Owner

kofrasa commented Dec 18, 2017

Added in v2.1.0. See https://github.com/kofrasa/mingo/wiki/API

@kofrasa kofrasa closed this as completed Dec 18, 2017
@kofrasa
Copy link
Owner

kofrasa commented Dec 18, 2017

For special cases ($sort, $group etc) the entire sequence is realized, processed, and a new iterator (stream object) is returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants