diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 830a2172..1a54413f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,9 +26,9 @@ jobs: fetch-depth: 0 - name: Import GPG Key uses: crazy-max/ghaction-import-gpg@v6 - env: - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} - name: Publish artifacts run: | sbt -java-home "$JAVA_HOME_17_X64" clean +publishSigned sonatypeBundleRelease diff --git a/build.sbt b/build.sbt index 4a5fe209..3efb6fa5 100644 --- a/build.sbt +++ b/build.sbt @@ -145,6 +145,7 @@ lazy val hnswlibMetricsDropwizard = (project in file("hnswlib-metrics-dropwizard lazy val hnswlibScala = (project in file("hnswlib-scala")) .dependsOn(hnswlibCore) .dependsOn(hnswlibMetricsDropwizard % Optional) + .dependsOn(hnswlibCoreJdk17 % Optional) .settings( name := "hnswlib-scala", crossScalaVersions := List("2.11.12", "2.12.18", "2.13.10"), diff --git a/hnswlib-scala/src/main/scala/com/github/jelmerk/knn/scalalike/package.scala b/hnswlib-scala/src/main/scala/com/github/jelmerk/knn/scalalike/package.scala index 6999ed7f..597c5859 100644 --- a/hnswlib-scala/src/main/scala/com/github/jelmerk/knn/scalalike/package.scala +++ b/hnswlib-scala/src/main/scala/com/github/jelmerk/knn/scalalike/package.scala @@ -126,4 +126,68 @@ package object scalalike { */ val doubleSparseVectorInnerProduct: DistanceFunction[SparseVector[Array[Double]], Double] = JDistanceFunctions.DOUBLE_SPARSE_VECTOR_INNER_PRODUCT.distance + + object jdk17DistanceFunctions { + + /** + * Calculates the cosine distance. + */ + val vectorFloat128CosineDistance: DistanceFunction[Array[Float], Float] = Jdk17DistanceFunctions.VECTOR_FLOAT_128_COSINE_DISTANCE.distance + + /** + * Calculates the cosine distance. + */ + val vectorFloat256CosineDistance: DistanceFunction[Array[Float], Float] = Jdk17DistanceFunctions.VECTOR_FLOAT_256_COSINE_DISTANCE.distance + + /** + * Calculates the inner product. + */ + val vectorFloat128InnerProduct: DistanceFunction[Array[Float], Float] = Jdk17DistanceFunctions.VECTOR_FLOAT_128_INNER_PRODUCT.distance + + /** + * Calculates the inner product. + */ + val vectorFloat256InnerProduct: DistanceFunction[Array[Float], Float] = Jdk17DistanceFunctions.VECTOR_FLOAT_256_INNER_PRODUCT.distance + + /** + * Calculates the euclidean distance. + */ + val vectorFloat128EuclideanDistance: DistanceFunction[Array[Float], Float] = Jdk17DistanceFunctions.VECTOR_FLOAT_128_EUCLIDEAN_DISTANCE.distance + + /** + * Calculates the euclidean distance. + */ + val vectorFloat256EuclideanDistance: DistanceFunction[Array[Float], Float] = Jdk17DistanceFunctions.VECTOR_FLOAT_256_EUCLIDEAN_DISTANCE.distance + + /** + * Calculates the manhattan distance. + */ + val vectorFloat128ManhattanDistance: DistanceFunction[Array[Float], Float] = Jdk17DistanceFunctions.VECTOR_FLOAT_128_MANHATTAN_DISTANCE.distance + + /** + * Calculates the manhattan distance. + */ + val vectorFloat256ManhattanDistance: DistanceFunction[Array[Float], Float] = Jdk17DistanceFunctions.VECTOR_FLOAT_256_MANHATTAN_DISTANCE.distance + + /** + * Calculates the canberra distance. + */ + val vectorFloat128CanberraDistance: DistanceFunction[Array[Float], Float] = Jdk17DistanceFunctions.VECTOR_FLOAT_128_CANBERRA_DISTANCE.distance + + /** + * Calculates the canberra distance. + */ + val vectorFloat256CanberraDistance: DistanceFunction[Array[Float], Float] = Jdk17DistanceFunctions.VECTOR_FLOAT_256_CANBERRA_DISTANCE.distance + + /** + * Calculates the bray curtis distance. + */ + val vectorFloat128BrayCurtisDistance: DistanceFunction[Array[Float], Float] = Jdk17DistanceFunctions.VECTOR_FLOAT_128_BRAY_CURTIS_DISTANCE.distance + + /** + * Calculates the bray curtis distance. + */ + val vectorFloat256BrayCurtisDistance: DistanceFunction[Array[Float], Float] = Jdk17DistanceFunctions.VECTOR_FLOAT_256_BRAY_CURTIS_DISTANCE.distance + + } }