Skip to content

Fix vector count in metrics showing minus zero#7678

Merged
timvisee merged 1 commit intodevfrom
metrics-count-vector-size-min-zero
Dec 3, 2025
Merged

Fix vector count in metrics showing minus zero#7678
timvisee merged 1 commit intodevfrom
metrics-count-vector-size-min-zero

Conversation

@timvisee
Copy link
Member

@timvisee timvisee commented Dec 3, 2025

Picked from #7670 to allow including it in the patch release

Prevent showing -0.0 in metrics if we have no vectors.

Documentation: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.sum

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Co-authored-by: <jojii <jojii@gmx.net>
Copy link
Member

@agourlay agourlay left a comment

Choose a reason for hiding this comment

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

I was super surprised by the behavior but I did get that -0 on the Rust playground 🫨

@qdrant qdrant deleted a comment from coderabbitai bot Dec 3, 2025
@timvisee
Copy link
Member Author

timvisee commented Dec 3, 2025

I was super surprised by the behavior but I did get that -0 on the Rust playground 🫨

There's a ""good"" reason for it.

sum() uses fold and needs some default value to start summing.

It picked -0.0 for floats to keep the sign bit if summing -0.0 items:

  • 0.0 + 0.0 = 0.0
  • -0.0 + 0.0 = 0.0
  • 0.0 + -0.0 = 0.0
  • -0.0 + -0.0 = -0.0 (we only keep sign bit here)

@timvisee timvisee merged commit 3d4cf54 into dev Dec 3, 2025
15 checks passed
@timvisee timvisee deleted the metrics-count-vector-size-min-zero branch December 3, 2025 09:26
timvisee added a commit that referenced this pull request Dec 3, 2025
Co-authored-by: <jojii <jojii@gmx.net>
@timvisee timvisee mentioned this pull request Dec 3, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants