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
Make some Mono sources and aggregators lazier #3081
Conversation
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
4e2e6a5
to
a34b17a
Compare
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: SerhiiPanasiuk <odokuka@vmware.com>
in case of empty sources flux to mono operators emits a value which in that case may violate backpressure components of RS spec. Thus, this PR reworks implementation and adds lighter ways of checking if there is request using non-volatile field and extra volatile int state Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: OlegDokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: OlegDokuka <odokuka@vmware.com>
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.
I know this is in an intermediate state, but I've commented anyway.
I like the direction it is going with the hasRequest
/state
👍
things that needs to be addressed in the final revision:
- scan support of at least
TERMINATED
, instead of removing the test lines that check this attribute (there is no reason the attribute couldn't be supported thanks tostate
) - test coverage regression: some tests for operator X use one of the modified operators Y (eg. count) to trigger a fusion path. now operator Y doesn't support fusion anymore => the test is deleted 😨. since operator X does support fusion, the case has to be covered which means we need to find an alternative to Y instead of purely deleting the whole test
- as discussed, you already intend to mutualize some code around
QueueSubscription
that always negotiateFuseable.NONE
in a common base class, which I think makes sense. this would allow fixing the bug ofisEmpty() == false && size() == 0
in one go :) that said, we might want to reconsider some of these fusion deactivation/removal...
reactor-core/src/main/java/reactor/core/publisher/FluxDefaultIfEmpty.java
Outdated
Show resolved
Hide resolved
reactor-core/src/main/java/reactor/core/publisher/MonoCollect.java
Outdated
Show resolved
Hide resolved
reactor-core/src/main/java/reactor/core/publisher/MonoCollectList.java
Outdated
Show resolved
Hide resolved
reactor-core/src/main/java/reactor/core/publisher/MonoFlatMap.java
Outdated
Show resolved
Hide resolved
reactor-core/src/main/java/reactor/core/publisher/MonoStreamCollector.java
Outdated
Show resolved
Hide resolved
reactor-core/src/main/java/reactor/core/publisher/ParallelThen.java
Outdated
Show resolved
Hide resolved
reactor-core/src/test/java/reactor/core/publisher/FluxDefaultIfEmptyTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: OlegDokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: OlegDokuka <odokuka@vmware.com>
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.
shaping up good, this is a big one !
I have found some issues and also added more minor comments / questions
reactor-core/src/main/java/reactor/core/publisher/Operators.java
Outdated
Show resolved
Hide resolved
this.aggregator = aggregator; | ||
//noinspection unchecked | ||
this.aggregate = (T) INITIAL_STATE; |
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.
this feels a bit hacky but I understand 😅
my concern is that it becomes too easy to add code like actual.onNext(aggregate)
while forgetting the aggregate != INITIAL_STATE
check beforehand, as this wouldn't trigger any compiler error.
having an Object
field instead kinda forces us to at least add an explicit cast, which in turns should raise our awareness (and shouldn't need warning suppression either).
instead of 1 cast, it would mean at least 2 though:
- when the
BiFunction
is applied inonNext
(with slightly more work, 1 more local variable to track probably) - when
actual.onNext(r)
is called inonComplete
wdyt?
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.
☑️
reactor-core/src/test/java/reactor/core/publisher/MonoReduceSeedTest.java
Outdated
Show resolved
Hide resolved
reactor-core/src/test/java/reactor/core/publisher/MonoReduceTest.java
Outdated
Show resolved
Hide resolved
reactor-core/src/test/java/reactor/core/publisher/ParallelCollectTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: OlegDokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: OlegDokuka <odokuka@vmware.com>
Signed-off-by: Oleh Dokuka <odokuka@vmware.com> Signed-off-by: OlegDokuka <odokuka@vmware.com>
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.
nice ! finally ready to merge 😄 🎉
Mono
producers
Signed-off-by: Oleh Dokuka odokuka@vmware.com