JunRuiLee commented on code in PR #99:
URL:
https://github.com/apache/paimon-vector-index/pull/99#discussion_r4001932332
##########
core/src/distance.rs:
##########
@@ -173,6 +253,25 @@ fn fvec_l2sqr_scalar(a: &[f32], b: &[f32]) -> f32 {
sum
}
+/// Mirrors [`fvec_l2sqr_scalar`] term for term, so the value it returns on
+/// completion is the one that function would have produced.
+#[cfg(any(
+ target_arch = "x86_64",
+ not(any(target_arch = "x86_64", target_arch = "aarch64"))
+))]
+#[inline]
+fn fvec_l2sqr_unless_exceeds_scalar(a: &[f32], b: &[f32], threshold: f32) ->
Option<f32> {
+ let mut sum = 0.0f32;
+ for i in 0..a.len() {
+ let d = a[i] - b[i];
+ sum += d * d;
+ if sum > threshold {
Review Comment:
Fixed in `27ab132`. The scalar fallback now accumulates in
`L2_PROBE_STRIDE`-sized blocks, probes only at stride boundaries, and performs
one final check after the remaining tail. This preserves the strict `>` and NaN
behavior while removing the per-coordinate compare/branch. Verified with `cargo
fmt --check`, native and x86_64 distance tests (17 each), and the range-search
integration tests (31).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]