Reimplement split() with backpressure#47
Merged
abersnaze merged 3 commits intoReactiveX:1.xfrom Dec 12, 2016
Merged
Conversation
pwittchen
reviewed
Dec 12, 2016
| @Override | ||
| public void onError(Throwable e) { | ||
| if (done) { | ||
| // RxJavaHooks.onError(e); RxJava 1.2+ required |
There was a problem hiding this comment.
Is this comment valid? I see that RxJava dependency was bumped to v. 1.2.3 in this PR.
abersnaze
requested changes
Dec 12, 2016
| * limitations under the License. | ||
| */ | ||
|
|
||
| package rx.observables; |
Contributor
There was a problem hiding this comment.
could you move this to rx.internal.operators
abersnaze
approved these changes
Dec 12, 2016
Contributor
|
@akarnokd to the rescue. |
Contributor
|
thanks @akarnokd, all it needed was 5 or 6 minutes of your time... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR reimplements the
split()operator to support backpressure.The algorithm uses the stable-prefetch approach and queues the entire split array of strings instead of enqueueing them one by one - this allows a bounded queue instead of an unbounded one. On the drain side, we know there are only strings of length 2 or more, and the emission simply ignores the last element - no need to copy items into a new array when enqueueing. Stripping off the trailing empty strings was a bit tricky but got inspiration from the current implementation. When the current array is traversed, empty strings are counted only and while this happens, the emission count doesn't move forward. Once a non-empty array entry was found, all previously counted empty elements are emitted just then - considering the request amount in the process. Once all empties have been emitted, the actual non-empty element is emitted.
Also this PR bumps RxJava version to 1.2.3 to have access to better operators such as
rebatchRequestswhich allows requesting one by one.