zhidongqu-db commented on code in PR #53481:
URL: https://github.com/apache/spark/pull/53481#discussion_r2665791858
##########
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtils.java:
##########
@@ -342,4 +342,223 @@ public static UTF8String quote(UTF8String str) {
String sp = str.toString().replaceAll(qtChar, qtCharRep);
return UTF8String.fromString(qtChar + sp + qtChar);
}
+
+ /**
+ * Computes the cosine similarity between two float vectors.
+ * Returns NULL if either vector contains NULL elements, has zero magnitude,
or is empty.
+ * Throws an exception if vectors have different dimensions.
+ * Uses manual loop unrolling (8 elements at a time) for speculative SIMD
optimization.
+ */
+ public static Float vectorCosineSimilarity(ArrayData left, ArrayData right,
UTF8String funcName) {
Review Comment:
done
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]