defineBuilder: Define an index builder

defineBuilderR Documentation

Define an index builder

Description

Define a builder object that can construct C++ indices for neighbor searches.

Usage

defineBuilder(BNPARAM)

Arguments

BNPARAM

A BiocNeighborParam object specifying the type of index to be constructed. If NULL, this defaults to a KmknnParam object.

Details

The external pointer returned in builder should refer to a BiocNeighbors::Builder object, see the definition in system.file("include", "BiocNeighbors.h", package="BiocNeighbors") for details. If a developer defines a defineBuilder method for a search algorithm, they do not have to define a new buildIndex method. The existing buildIndex methods will automatically create an instance of the appropriate BiocNeighborGenericIndex subclass based on class, which can be immediately used in all generics (e.g., findKNN, queryNeighbors) without further effort.

Note that the pointer returned by defineBuilder should not be used as the ptr in the BiocNeighborIndex subclasses. The ptr slot is expected to contain a pointer referring to a BiocNeighbors::Prebuilt object, as returned by the default buildIndex. Using the pointer from builder will probably crash the R session.

Needless to say, users should not attempt to serialize the external pointer returned by this generic. Attempting to use a deserialized pointer in buildIndex will cause the R session to crash.

Value

List containing:

  • builder, a pointer to a builder instance that can be used to construct a prebuilt index in buildIndex.

  • class, the constructor for a BiocNeighborGenericIndex subclass that accepts ptr and names arguments.

Author(s)

Aaron Lun

See Also

defineBuilder,KmknnParam-method, defineBuilder,VptreeParam-method, defineBuilder,AnnoyParam-method and defineBuilder,HnswParam-method for specific methods.

Examples

(out <- defineBuilder())
(out2 <- defineBuilder(AnnoyParam()))


LTLA/kmknn documentation built on Oct. 18, 2024, 9:01 p.m.