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

universal-query: New QueriedPoint struct with extendable Score enum #4251

Closed
wants to merge 5 commits into from

Conversation

coszio
Copy link
Contributor

@coszio coszio commented May 16, 2024

  • Introduces a QueriedPoint struct, which is equivalent to a ScoredPoint, but has a Score enum, which can be used to be the output of scroll-like requests, like when specifying order_by.
  • Changes the output elements of query to be of QueriedPoint type.
  • Also adds this types as external grpc types and in internal grpc service

lib/segment/src/types.rs Outdated Show resolved Hide resolved
@coszio
Copy link
Contributor Author

coszio commented May 21, 2024

Closing in favor of #4291

@coszio coszio closed this May 21, 2024
Copy link
Member

@timvisee timvisee left a comment

Choose a reason for hiding this comment

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

It got closed right when I was done 🥲

Comment on lines +289 to +294
match (&self.score, &other.score) {
(Some(a), Some(b)) => a.cmp(b),
(None, Some(_)) => Ordering::Less,
(Some(_), None) => Ordering::Greater,
(None, None) => self.id.cmp(&other.id),
}
Copy link
Member

Choose a reason for hiding this comment

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

Option implements Ord where None is always less, so you could do this with a bit less branching:

Suggested change
match (&self.score, &other.score) {
(Some(a), Some(b)) => a.cmp(b),
(None, Some(_)) => Ordering::Less,
(Some(_), None) => Ordering::Greater,
(None, None) => self.id.cmp(&other.id),
}
if self.score.is_some() || other.score.is_some() {
self.score.cmp(&other.score)
} else {
self.id.cmp(&other.id)
}

Or maybe you want this instead:

self.score.cmp(&other.score).then_with(|| self.id.cmp(&other.id))

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.

None yet

3 participants