You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2023/02/01 09:52:48 UTC

[lucene] branch branch_9x updated (dedafdee14c -> 6711a805e43)

This is an automated email from the ASF dual-hosted git repository.

javanna pushed a change to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


    from dedafdee14c Add back-compat indices for 9.5.0
     new 36b65032ce3 Release wizard: update folder name in stage artifacts command (#12117)
     new ae268472af8 Remove VectorUtil#toBytesRef (#12121)
     new 6711a805e43 Adjust return type for VectorUtil methods (#12122)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 dev-tools/scripts/releaseWizard.yaml               |  2 +-
 .../lucene/index/VectorSimilarityFunction.java     |  2 +-
 .../java/org/apache/lucene/util/VectorUtil.java    | 23 ++--------------------
 .../org/apache/lucene/util/TestVectorUtil.java     | 12 -----------
 4 files changed, 4 insertions(+), 35 deletions(-)


[lucene] 02/03: Remove VectorUtil#toBytesRef (#12121)

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

javanna pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit ae268472af8823f4205243f658ae990a9fabd59c
Author: Luca Cavanna <ja...@apache.org>
AuthorDate: Wed Feb 1 10:47:50 2023 +0100

    Remove VectorUtil#toBytesRef (#12121)
    
    The method is currently only used in its corresponding test method.
---
 .../src/java/org/apache/lucene/util/VectorUtil.java   | 19 -------------------
 .../test/org/apache/lucene/util/TestVectorUtil.java   | 12 ------------
 2 files changed, 31 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/util/VectorUtil.java b/lucene/core/src/java/org/apache/lucene/util/VectorUtil.java
index 9b18414c004..8800d434ba6 100644
--- a/lucene/core/src/java/org/apache/lucene/util/VectorUtil.java
+++ b/lucene/core/src/java/org/apache/lucene/util/VectorUtil.java
@@ -270,23 +270,4 @@ public final class VectorUtil {
     float denom = (float) (a.length * (1 << 15));
     return 0.5f + dotProduct(a, b) / denom;
   }
-
-  /**
-   * Convert a floating point vector to an array of bytes using casting; the vector values should be
-   * in [-128,127]
-   *
-   * @param vector a vector
-   * @return a new BytesRef containing the vector's values cast to byte.
-   */
-  public static BytesRef toBytesRef(float[] vector) {
-    BytesRef b = new BytesRef(new byte[vector.length]);
-    for (int i = 0; i < vector.length; i++) {
-      if (vector[i] < -128 || vector[i] > 127) {
-        throw new IllegalArgumentException(
-            "Vector value at " + i + " is out of range [-128.127]: " + vector[i]);
-      }
-      b.bytes[i] = (byte) vector[i];
-    }
-    return b;
-  }
 }
diff --git a/lucene/core/src/test/org/apache/lucene/util/TestVectorUtil.java b/lucene/core/src/test/org/apache/lucene/util/TestVectorUtil.java
index 57ed2a6c1f4..21ad580de6c 100644
--- a/lucene/core/src/test/org/apache/lucene/util/TestVectorUtil.java
+++ b/lucene/core/src/test/org/apache/lucene/util/TestVectorUtil.java
@@ -262,16 +262,4 @@ public class TestVectorUtil extends LuceneTestCase {
     u[1] = -v[0];
     assertEquals(0, VectorUtil.cosine(u, v), DELTA);
   }
-
-  public void testToBytesRef() {
-    assertEquals(
-        new BytesRef(new byte[] {-128, 0, 127}),
-        VectorUtil.toBytesRef(new float[] {-128f, 0, 127f}));
-    assertEquals(
-        new BytesRef(new byte[] {-19, 0, 33}),
-        VectorUtil.toBytesRef(new float[] {-19.9f, 0.5f, 33.7f}));
-    expectThrows(
-        IllegalArgumentException.class, () -> VectorUtil.toBytesRef(new float[] {-128.1f}));
-    expectThrows(IllegalArgumentException.class, () -> VectorUtil.toBytesRef(new float[] {127.1f}));
-  }
 }


[lucene] 01/03: Release wizard: update folder name in stage artifacts command (#12117)

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

javanna pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 36b65032ce38d223b985fd40938f47069d5f01a6
Author: Luca Cavanna <ja...@apache.org>
AuthorDate: Wed Feb 1 10:47:32 2023 +0100

    Release wizard: update folder name in stage artifacts command (#12117)
---
 dev-tools/scripts/releaseWizard.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dev-tools/scripts/releaseWizard.yaml b/dev-tools/scripts/releaseWizard.yaml
index 737c8298696..d6ae6ab1e8c 100644
--- a/dev-tools/scripts/releaseWizard.yaml
+++ b/dev-tools/scripts/releaseWizard.yaml
@@ -933,7 +933,7 @@ groups:
       commands_text: In the source checkout do the following (note that this step will prompt you for your Apache LDAP credentials)
       commands:
         - !Command
-          cmd: java dev-tools/scripts/StageArtifacts.java --user {{ gpg.apache_id }} --description "{{ 'Apache Lucene ', release_version, ' (commit ', git_sha, ')' }}" "{{ [dist_file_path, dist_folder, 'solr', 'maven'] | path_join }}"
+          cmd: java dev-tools/scripts/StageArtifacts.java --user {{ gpg.apache_id }} --description "{{ 'Apache Lucene ', release_version, ' (commit ', git_sha, ')' }}" "{{ [dist_file_path, dist_folder, 'lucene', 'maven'] | path_join }}"
           tee: true
           logfile: publish_lucene_maven.log
     post_description: The artifacts are not published yet, please proceed with the next step to actually publish!


[lucene] 03/03: Adjust return type for VectorUtil methods (#12122)

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

javanna pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 6711a805e430cf355f55168785d628fb4066128b
Author: Luca Cavanna <ja...@apache.org>
AuthorDate: Wed Feb 1 10:48:05 2023 +0100

    Adjust return type for VectorUtil methods (#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.
---
 .../src/java/org/apache/lucene/index/VectorSimilarityFunction.java    | 2 +-
 lucene/core/src/java/org/apache/lucene/util/VectorUtil.java           | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/index/VectorSimilarityFunction.java b/lucene/core/src/java/org/apache/lucene/index/VectorSimilarityFunction.java
index d5ebcabb7a3..3646cf65584 100644
--- a/lucene/core/src/java/org/apache/lucene/index/VectorSimilarityFunction.java
+++ b/lucene/core/src/java/org/apache/lucene/index/VectorSimilarityFunction.java
@@ -37,7 +37,7 @@ public enum VectorSimilarityFunction {
 
     @Override
     public float compare(byte[] v1, byte[] v2) {
-      return 1 / (1 + squareDistance(v1, v2));
+      return 1 / (1f + squareDistance(v1, v2));
     }
   },
 
diff --git a/lucene/core/src/java/org/apache/lucene/util/VectorUtil.java b/lucene/core/src/java/org/apache/lucene/util/VectorUtil.java
index 8800d434ba6..2a08436ec0b 100644
--- a/lucene/core/src/java/org/apache/lucene/util/VectorUtil.java
+++ b/lucene/core/src/java/org/apache/lucene/util/VectorUtil.java
@@ -181,7 +181,7 @@ public final class VectorUtil {
   }
 
   /** 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) {
     // Note: this will not overflow if dim < 2^18, since max(byte * byte) = 2^14.
     int squareSum = 0;
     for (int i = 0; i < a.length; i++) {
@@ -249,7 +249,7 @@ public final class VectorUtil {
    * @param b bytes containing another vector, of the same dimension
    * @return the value of the dot product of the two vectors
    */
-  public static float dotProduct(byte[] a, byte[] b) {
+  public static int dotProduct(byte[] a, byte[] b) {
     assert a.length == b.length;
     int total = 0;
     for (int i = 0; i < a.length; i++) {