You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "javanna (via GitHub)" <gi...@apache.org> on 2023/01/31 19:33:46 UTC

[GitHub] [lucene] javanna opened a new pull request, #12122: Adjust return type for VectorUtil methods

javanna opened a new pull request, #12122:
URL: https://github.com/apache/lucene/pull/12122

   Two of the methods (squareDistance and dotProduct) that take byte arrays return a float while the variable used to store the value is an int. They can just return an int.


-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] javanna merged pull request #12122: Adjust return type for VectorUtil methods

Posted by "javanna (via GitHub)" <gi...@apache.org>.
javanna merged PR #12122:
URL: https://github.com/apache/lucene/pull/12122


-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] benwtrent commented on a diff in pull request #12122: Adjust return type for VectorUtil methods

Posted by "benwtrent (via GitHub)" <gi...@apache.org>.
benwtrent commented on code in PR #12122:
URL: https://github.com/apache/lucene/pull/12122#discussion_r1092395951


##########
lucene/core/src/java/org/apache/lucene/util/VectorUtil.java:
##########
@@ -181,7 +181,7 @@ private static float squareDistanceUnrolled(float[] v1, float[] v2, int index) {
   }
 
   /** Returns the sum of squared differences of the two vectors. */
-  public static float squareDistance(byte[] a, byte[] b) {
+  public static int squareDistance(byte[] a, byte[] b) {

Review Comment:
   `EUCLIDEAN#compare(byte[], byte[])` needs to be updated because switching this to int changes `1/(1 + int)` where as previously it would return factional. 
   
   Something like `1f/(1f + VectorUtil#squareDistance(byte[], byte[])`



-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] javanna commented on a diff in pull request #12122: Adjust return type for VectorUtil methods

Posted by "javanna (via GitHub)" <gi...@apache.org>.
javanna commented on code in PR #12122:
URL: https://github.com/apache/lucene/pull/12122#discussion_r1092402069


##########
lucene/core/src/java/org/apache/lucene/util/VectorUtil.java:
##########
@@ -181,7 +181,7 @@ private static float squareDistanceUnrolled(float[] v1, float[] v2, int index) {
   }
 
   /** Returns the sum of squared differences of the two vectors. */
-  public static float squareDistance(byte[] a, byte[] b) {
+  public static int squareDistance(byte[] a, byte[] b) {

Review Comment:
   yep should be fixed now. I am glad we had that code inspection.



-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org