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

ScoreValue.from return type #1717

Closed
paualarco opened this issue Apr 11, 2021 · 3 comments
Closed

ScoreValue.from return type #1717

paualarco opened this issue Apr 11, 2021 · 3 comments
Labels
for: team-attention An issue we need to discuss as a team to make progress status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue

Comments

@paualarco
Copy link
Contributor

Hello! I am having problems to create a ScoredValue from an Optional value in the recent release 6.1.0.RELEASE,
in which the signature ScoreValue.from(Double score, Optional<T> value) now returns Value instead of ScoredValue, and I have to explicitly cast it to ScoreValue in order to use it in the SortedStreams api...

As I see the method is creating a ScoredValue so I think it would be better to return that type directly instead of using the parent Value. What are your thoughts? Changing the type will be a breaking change so perhaps we could have a new method to address that?

@mp911de
Copy link
Collaborator

mp911de commented Apr 11, 2021

Thanks for raising an issue. The problem is somewhat that a scored value that is empty isn't really useful because it represents a score only without a value. We tried to express the value optionality with changing the return type. There's a similar issue with the geo variant of Value.

The way out is to map the optimal value with Optional.map(v -> ScoredValue.just(score, v).orElse(...).

Can you help us understand the context in which you're using ScoredValue and how your code behaves if the Optional is empty?

@mp911de mp911de added for: team-attention An issue we need to discuss as a team to make progress status: waiting-for-feedback We need additional information before we can continue labels Apr 11, 2021
@paualarco
Copy link
Contributor Author

The problem is somewhat that a scored value that is empty isn't really useful because it represents a score only without a value.

Neither I find the application for empty ScoredValue, and I was wondering if it can ever be the case where it is comes empty from one of the library methods. Because if there are no such cases maybe it would be easier to not allow Optional values (empty) to be passed and to work directly with the value with a NotNull validation. But I am not sure...

In my case I have found that case while building a Scala and Monix friendly Redis client that actually is a wrapper around lettuce, but don't have specific scenario where that happens. This is the line where I found that problem.

Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 30 days this issue will be closed.

@github-actions github-actions bot added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: team-attention An issue we need to discuss as a team to make progress status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue
Projects
None yet
Development

No branches or pull requests

2 participants