Skip to content

Commit

Permalink
Add core jdk 17 support to the scala library
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmerk committed Jan 1, 2024
1 parent 13349cf commit 4ca5e90
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
}

0 comments on commit 4ca5e90

Please sign in to comment.