mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-02 01:08:47 +02:00
ef4c5eb65e
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
27 lines
818 B
Scala
27 lines
818 B
Scala
package com.twitter.ann.common
|
|
|
|
import com.twitter.ann.common.EmbeddingType.EmbeddingVector
|
|
import com.twitter.util.Future
|
|
|
|
object QueryableOperations {
|
|
implicit class Map[T, P <: RuntimeParams, D <: Distance[D]](
|
|
val q: Queryable[T, P, D]) {
|
|
def mapRuntimeParameters(f: P => P): Queryable[T, P, D] = {
|
|
new Queryable[T, P, D] {
|
|
def query(
|
|
embedding: EmbeddingVector,
|
|
numOfNeighbors: Int,
|
|
runtimeParams: P
|
|
): Future[List[T]] = q.query(embedding, numOfNeighbors, f(runtimeParams))
|
|
|
|
def queryWithDistance(
|
|
embedding: EmbeddingVector,
|
|
numOfNeighbors: Int,
|
|
runtimeParams: P
|
|
): Future[List[NeighborWithDistance[T, D]]] =
|
|
q.queryWithDistance(embedding, numOfNeighbors, f(runtimeParams))
|
|
}
|
|
}
|
|
}
|
|
}
|