Trait

com.github.jelmerk.knn.scalalike

Index

Related Doc: package scalalike

Permalink

trait Index[TId, TVector, TItem <: Item[TId, TVector], TDistance] extends AnyRef

K-nearest neighbors search index.

TId

type of the external identifier of an item

TVector

The type of the vector to perform distance calculation on

TItem

Type of items stored in the index

TDistance

The type of distance between items (expect any numeric type: float, double, int, ..).

See also

See https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm for more information.

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Index
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type ProgressListener = (Int, Int) ⇒ Unit

    Permalink

    Called periodically to report on progress during indexing.

    Called periodically to report on progress during indexing. The first argument is the number of records processed. The second argument is the total number of record to index as part of this operation.

Abstract Value Members

  1. abstract def add(item: TItem): Unit

    Permalink

    Add a new item to the index.

    Add a new item to the index.

    item

    the item to add to the index

  2. abstract def addAll(items: Iterable[TItem], numThreads: Int = ..., listener: ProgressListener = (_, _) => (), progressUpdateInterval: Int = ...): Unit

    Permalink

    Add multiple items to the index.

    Add multiple items to the index. Reports progress to the passed in progress listener every progressUpdateInterval elements indexed.

    items

    the items to add to the index

    numThreads

    number of threads to use for parallel indexing

    listener

    listener to report progress to

    progressUpdateInterval

    after indexing this many items progress will be reported

  3. abstract def apply(id: TId): TItem

    Permalink

    Returns an item by its identifier.

    Returns an item by its identifier. If the item does not exist in the index a NoSuchElementException is thrown

    id

    unique identifier of the item to return

    returns

    the item

  4. abstract def findNearest(vector: TVector, k: Int): Seq[SearchResult[TItem, TDistance]]

    Permalink

    Find the items closest to the passed in vector.

    Find the items closest to the passed in vector.

    vector

    the vector

    k

    number of items to return

    returns

    the items closest to the passed in vector

  5. abstract def findNeighbors(id: TId, k: Int): Seq[SearchResult[TItem, TDistance]]

    Permalink

    Find the items closest to the item identified by the passed in id.

    Find the items closest to the item identified by the passed in id. If the id does not match an item an empty list is returned. the element itself is not included in the response.

    id

    of the item to find the neighbors of

    k

    number of neighbors to return

    returns

    the items closest to the item

  6. abstract def get(id: TId): Option[TItem]

    Permalink

    Optionally return an item by its identifier

    Optionally return an item by its identifier

    id

    unique identifier of the item to return

    returns

    the item

  7. abstract def remove(id: TId): Boolean

    Permalink

    Removes an item from the index.

    Removes an item from the index.

    id

    unique identifier or the item to remove

    returns

    true if this list contained the specified element

  8. abstract def save(path: Path): Unit

    Permalink

    Saves the index to a path.

    Saves the index to a path.

    path

    path to write the index to

  9. abstract def save(file: File): Unit

    Permalink

    Saves the index to a file.

    Saves the index to a file.

    file

    file to write the index to

  10. abstract def save(out: OutputStream): Unit

    Permalink

    Saves the index to an OutputStream.

    Saves the index to an OutputStream.

    out

    the output stream to write the index to

  11. abstract def size: Int

    Permalink

    Returns the size of the index.

    Returns the size of the index.

    returns

    size of the index

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  16. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped