-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[vector] Adding vector functions #11222
Conversation
xiangfu0
commented
Jul 30, 2023
•
edited
Loading
edited
- Support vector scalar functions, assuming vector type is stored as float[]
- cosine distance
- inner product
- l2 distance
- l1 distance
- vector dim
- vector norm
- Support both scalar and transform functions
- Add integration tests for v1/v2
53ff605
to
a052985
Compare
Codecov Report
@@ Coverage Diff @@
## master #11222 +/- ##
==========================================
- Coverage 0.11% 0.11% -0.01%
==========================================
Files 2227 2229 +2
Lines 119628 119768 +140
Branches 18102 18126 +24
==========================================
Hits 137 137
- Misses 119471 119611 +140
Partials 20 20
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 7 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
a052985
to
44b7b3e
Compare
44b7b3e
to
324a45c
Compare
cc8d9e4
to
a4c949d
Compare
norm1 += Math.pow(vector1[i], 2); | ||
norm2 += Math.pow(vector2[i], 2); | ||
} | ||
return 1 - (dotProduct / (Math.sqrt(norm1) * Math.sqrt(norm2))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might need to check for divide by zero
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make cosineDistance
can take third optional argument default value, which is used when either vector has a norm of 0
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/VectorFunctions.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor comments. Overall, LGTM!
a4c949d
to
c178bb2
Compare