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

Issue 7032: Implement Comparable on StreamCut & StreamCut.UNBOUNDED #7033

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

derekm
Copy link
Contributor

@derekm derekm commented Mar 30, 2023

Change log description
Adds Comparable<StreamCut> interface to StreamCut. Adds compareTo() methods to StreamCutImpl and StreamCut.UNBOUNDED.

Purpose of the change
Fixes #7032

What the code does
It allows StreamCuts to be compared as naturally ordered things being less-than (<), greater-than (>), or equal-to (=). Overlapping StreamCuts are not comparable and produce a RuntimeException.

How to verify it
./gradlew :client:test --tests io.pravega.client.stream.StreamCutTest

Signed-off-by: Derek Moore <derek.moore@dell.com>
Signed-off-by: Derek Moore <derek.moore@dell.com>
Signed-off-by: Derek Moore <derek.moore@dell.com>
Signed-off-by: Derek Moore <derek.moore@dell.com>
@derekm derekm marked this pull request as draft March 30, 2023 02:42
@@ -58,6 +58,11 @@ public String toString() {
private Object readResolve() {
return UNBOUNDED;
}

@Override
public int compareTo(StreamCut o) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is StreamCut.UNBOUNDED's compareTo(). UNBOUNDED is used to mean both "possibly ever-truncating stream head" AND "ever-extending stream tail", depending on argument position (whether it is used as a start streamcut or an end streamcut). Given that UNBOUNDED can refer to the head OR the tail, depending on where it is used, how should its compareTo() behave?

Should it be equal only to itself and greater-than all other streamcuts? (That is, should it represent the unbounded tail when compared to?)

Signed-off-by: “jose-robles2” <joserobles2230@gmail.com>
Signed-off-by: “jose-robles2” <joserobles2230@gmail.com>
Signed-off-by: “jose-robles2” <joserobles2230@gmail.com>
@RaulGracia
Copy link
Contributor

@derekm please, look this in case it is useful: #7032 (comment)
For consistency, I think it would be a good idea to have the same logic for comparing StreamCuts both in the client and the controller.

@tkaitchuck tkaitchuck marked this pull request as ready for review April 14, 2023 04:27
@tkaitchuck tkaitchuck self-requested a review April 14, 2023 04:27
@tkaitchuck
Copy link
Member

Derek's changes look good to me. I've added some additional changes, so I am going wider with review.

@codecov
Copy link

codecov bot commented Apr 14, 2023

Codecov Report

Patch coverage: 86.36% and no project coverage change.

Comparison is base (05831c0) 86.35% compared to head (ea804f4) 86.36%.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #7033   +/-   ##
=========================================
  Coverage     86.35%   86.36%           
- Complexity    16050    16068   +18     
=========================================
  Files          1031     1031           
  Lines         59815    59859   +44     
  Branches       6071     6086   +15     
=========================================
+ Hits          51655    51697   +42     
- Misses         4987     4989    +2     
  Partials       3173     3173           
Impacted Files Coverage Δ
.../main/java/io/pravega/client/stream/StreamCut.java 84.21% <57.14%> (-15.79%) ⬇️
...a/io/pravega/client/stream/impl/StreamCutImpl.java 84.87% <91.89%> (+3.16%) ⬆️

... and 16 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@tkaitchuck tkaitchuck requested review from Bhupender-Y and removed request for tkaitchuck January 3, 2024 00:25
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.

Implement Comparable interface on StreamCut objects
4 participants