You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/05/20 21:23:21 UTC

[GitHub] [lucene] msokolov commented on a diff in pull request #913: Lucene 10577

msokolov commented on code in PR #913:
URL: https://github.com/apache/lucene/pull/913#discussion_r878553114


##########
lucene/core/src/java/org/apache/lucene/util/VectorUtil.java:
##########
@@ -213,4 +213,21 @@ public static void add(float[] u, float[] v) {
       u[i] += v[i];
     }
   }
+
+  public static float dotProduct(BytesRef a, int aOffset, BytesRef b, int bOffset, int len) {
+    // fixme -- move to codec? What if later we want to access the bytes some other way?
+    int total = 0;
+    for (int i = 0; i < len; i++) {
+      total += a.bytes[aOffset++] * b.bytes[bOffset++];

Review Comment:
   hm, well in the worst case (128 * 128) = 2^7*2^7 = 2^14 and we can sum lots of these in an int without any concern about overflow. I think the limit is on the dimension of the vector; I mean 2^31/2^14 = 2^17 and I don't think we would ever have a 2^17-dimensional vector. Perhaps this gives us a principled way to choose that max dimension :) I guess 2^17 = 128K.
   
   Looking at what `ByteVector.mul()` does ...



-- 
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