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

Fix l2 operator bug when used with int arrays #243

Merged
merged 2 commits into from
Dec 11, 2023
Merged

Fix l2 operator bug when used with int arrays #243

merged 2 commits into from
Dec 11, 2023

Conversation

Ngalstyan4
Copy link
Contributor

We need properly copy and cast array elements when int array is bassed and we need floats.
Previusly we were interpreting float* array as an int32* array when calculating distances.

I think this issue does not exist when creating an index since there casts happen before. I also added a test to demonstrate this (was it already tested elsewhere and I missed it?). If you can think of other edge cases, let me know here.

The added tests check operator output when used directly. Below is the diff if I ran the same tests without the bugfix:

@@ -33,7 +33,7 @@
 SELECT ARRAY[0,0,0] <-> ARRAY[2,3,-4];
  ?column?
 ----------
-       29
+      NaN
 (1 row)

 -- with float arrays:
@@ -52,7 +52,7 @@
 SELECT '{1,0,1}' <-> '{0,1,0}'::integer[];
  ?column?
 ----------
-        3
+        0
 (1 row)

 SELECT '{1,0,1}' <=> '{0,1,0}'::integer[];

Copy link

github-actions bot commented Dec 11, 2023

Benchmarks

metric old new pct change
recall (after create) 0.740 0.740 -
recall (after insert) 0.754 0.780 +3.45%
select bulk tps 486.766 493.583 +1.40%
select bulk latency (ms) 15.702 15.673 -0.18%
select bulk latency (stddev ms) 3.712 1.760 -52.59%
create latency (ms) 1197.828 1197.734 -0.01%
insert bulk tps 11.514 11.551 +0.32%
insert bulk latency (ms) 86.841 86.565 -0.32%
insert bulk latency (stddev ms) 1.995 3.136 +57.19%
disk usage (bytes) 6348800.000 6348800.000 -

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Merging #243 (28f4264) into main (50c294b) will decrease coverage by 0.42%.
The diff coverage is 64.70%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #243      +/-   ##
==========================================
- Coverage   77.68%   77.26%   -0.42%     
==========================================
  Files          23       23              
  Lines        1685     1698      +13     
  Branches      415      421       +6     
==========================================
+ Hits         1309     1312       +3     
- Misses        191      198       +7     
- Partials      185      188       +3     
Files Coverage Δ
src/hnsw/utils.h 40.00% <ø> (ø)
src/hnsw.c 79.82% <60.00%> (-2.17%) ⬇️
src/hnsw/utils.c 81.08% <66.66%> (-6.92%) ⬇️

... and 1 file with indirect coverage changes

@var77 var77 merged commit 896ed5a into main Dec 11, 2023
@var77 var77 deleted the narek/dec9misc branch December 11, 2023 07:50
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.

2 participants