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 ac9c808
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
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 ac9c808

Please sign in to comment.