-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Eager ConcatMap #3357
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
Eager ConcatMap #3357
Conversation
Thanks a lot for contributing this one @akarnokd. I've had one look through and no problems jump out at me but I will review further. This will be useful. |
drain(); | ||
} | ||
|
||
void drain() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For readability I'd suggest longer names for variables like d, a, r, e, p.
2d88119
to
51eb7a8
Compare
Thanks for the review @davidmoten . Usually I use one letter variables because I find it easier to parse the code and instead of long variable names, I use newlines to separate logical blocks. This way, I don't have to type that many letters and I don't have to wait while Eclipse returns with the content assist (which is blocking by the way and may take hundreds of milliseconds, even on my i7 + SSD). I took the time and renamed variables as you asked for and added some more unit tests that check the code paths. That being said, I don't plan to do such renames in my contributions very often in the future and encourage anybody to post their PRs with their proposed cleanups/renames. |
* @return | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
public static <T> Observable<T> eagerConcatMap( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we name these eagerConcat
instead of eagerConcatMap
? These overloads do not take a FuncN
so they aren't really mapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto that @stealthcode and for discoverability call it concatEager?
51eb7a8
to
e64d00c
Compare
Thanks for the feedback. I've updated the method names to |
e64d00c
to
e99f29c
Compare
Updated with a capacity fix for the |
I reviewed in details in the code and I believe it is correct. But I wonder if subscribing to the sources in a "unbounded mode" is the right thing to do. The devil is in the details, and I believe this would significantly complexify the code, but I would like to know what you are thinking about this? |
@stevegury This operator consumes source observables in order and doesn't make sense to split any request from downstream. If the downstream requests n and the first is requested n / count, that would hang the sequence because only the first is allowed to emit and it won't emit enough to trigger a new request. It is possible to use a bounded buffer per source so while they are not consumed, they don't grow indefinitely. However, it means that each of them can produce only |
@akarnokd sorry I wasn't very clear but what I proposed was roughly what you described (replacing My main concern here is the use of unbounded buffer, which, I think, could be avoided. |
@davidmoten What do you think about the bounded buffering and the fact that such sources would act more like a delayed source? |
I'd be happy to see bounded buffering ( If this is significant rework I'm content to see this unbounded version documented with its buffering characteristics merged and we can defer the bounding work to another PR. |
e99f29c
to
a239d02
Compare
Done. |
Great, thanks @akarnokd ! Lightning quick as always. |
LGTM 👍 |
The three of you seem happy with it so I'm merging it. |
Related discussion in #3017.