Documentation
¶
Index ¶
- func Distance(vec1 []float32, vec2 []float32, dims uint, metric Metric) (float32, error)
- type Index
- func (index *Index) Add(key Key, vec []float32) error
- func (index *Index) Capacity() (cap uint, err error)
- func (index *Index) ChangeExpansionAdd(val uint) error
- func (index *Index) ChangeExpansionSearch(val uint) error
- func (index *Index) ChangeThreadsAdd(val uint) error
- func (index *Index) ChangeThreadsSearch(val uint) error
- func (index *Index) Connectivity() (con uint, err error)
- func (index *Index) Contains(key Key) (found bool, err error)
- func (index *Index) Destroy() error
- func (index *Index) Dimensions() (dim uint, err error)
- func (index *Index) ExpansionAdd() (val uint, err error)
- func (index *Index) ExpansionSearch() (val uint, err error)
- func (index *Index) Get(key Key, count uint) (vectors []float32, err error)
- func (index *Index) HardwareAcceleration() (string, error)
- func (index *Index) Len() (len uint, err error)
- func (index *Index) Load(path string) error
- func (index *Index) LoadBuffer(buf []byte, buffer_size uint) error
- func (index *Index) MemoryUsage() (len uint, err error)
- func (index *Index) Remove(key Key) error
- func (index *Index) Rename(from Key, to Key) error
- func (index *Index) Reserve(capacity uint) error
- func (index *Index) Save(path string) error
- func (index *Index) SaveBuffer(buf []byte, buffer_size uint) error
- func (index *Index) Search(query []float32, limit uint) (keys []Key, distances []float32, err error)
- func (index *Index) SerializedLength() (len uint, err error)
- func (index *Index) View(path string) error
- func (index *Index) ViewBuffer(buf []byte, buffer_size uint) error
- type IndexConfig
- type Key
- type Metric
- type Quantization
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index represents a USearch index.
func NewIndex ¶
func NewIndex(conf IndexConfig) (index *Index, err error)
NewIndex initializes a new instance of the index with the specified configuration.
func (*Index) ChangeExpansionAdd ¶
ChangeExpansionAdd sets the expansion value used during index creation
func (*Index) ChangeExpansionSearch ¶
ChangeExpansionSearch sets the expansion value used during search
func (*Index) ChangeThreadsAdd ¶
ChangeThreadsAdd sets the threads limit for add
func (*Index) ChangeThreadsSearch ¶
ChangeThreadsSearch sets the threads limit for search
func (*Index) Connectivity ¶
Connectivity returns the connectivity parameter of the index.
func (*Index) Dimensions ¶
Dimensions returns the number of dimensions of the vectors in the index.
func (*Index) ExpansionAdd ¶
ExpansionAdd returns the expansion value used during index creation
func (*Index) ExpansionSearch ¶
ExpansionSearch returns the expansion value used during search
func (*Index) HardwareAcceleration ¶
HardwareAcceleration returns a string showing the SIMD capability for the index
func (*Index) LoadBuffer ¶
Loads the index from a specified buffer.
func (*Index) MemoryUsage ¶
MemoryUsage reports the memory usage of the index
func (*Index) SaveBuffer ¶
Save saves the index to a specified buffer.
func (*Index) Search ¶
func (index *Index) Search(query []float32, limit uint) (keys []Key, distances []float32, err error)
Search performs k-Approximate Nearest Neighbors Search for the closest vectors to the query vector.
func (*Index) SerializedLength ¶
SerializedLength reports the expected file size after serialization.
type IndexConfig ¶
type IndexConfig struct { Quantization Quantization // The scalar kind used for quantization of vector data during indexing. Metric Metric // The metric kind used for distance calculation between vectors. Dimensions uint // The number of dimensions in the vectors to be indexed. Connectivity uint // The optional connectivity parameter that limits connections-per-node in the graph. ExpansionAdd uint // The optional expansion factor used for index construction when adding vectors. ExpansionSearch uint // The optional expansion factor used for index construction during search operations. Multi bool // Indicates whether multiple vectors can map to the same key. }
IndexConfig represents the configuration options for initializing a USearch index.
func DefaultConfig ¶
func DefaultConfig(dimensions uint) IndexConfig
DefaultConfig returns an IndexConfig with default values for the specified number of dimensions.
func Metadata ¶
func Metadata(path string) (c IndexConfig, err error)
Metadata loads the metadata from a specified file.
func MetadataBuffer ¶
func MetadataBuffer(buf []byte, buffer_size uint) (c IndexConfig, err error)
Loads the metadata from a specified buffer.
type Key ¶
type Key = uint64
Key represents the type for keys used in the USearch index.
func ExactSearch ¶
func ExactSearch(dataset []float32, queries []float32, dataset_size uint, queries_size uint, dataset_stride uint, queries_stride uint, dims uint, metric Metric, count uint, threads uint, keys_stride uint, distances_stride uint) (keys []Key, distances []float32, err error)
ExactSearch is a multithreaded exact nearest neighbors search
type Metric ¶
type Metric uint8
Metric represents the type for different metrics used in distance calculations.
const ( InnerProduct Metric = iota Cosine L2sq Haversine Divergence Pearson Hamming Tanimoto Sorensen )
Different metric kinds supported by the USearch library.
func (Metric) CValue ¶
func (m Metric) CValue() C.usearch_metric_kind_t
type Quantization ¶
type Quantization uint8
Quantization represents the type for different scalar kinds used in quantization.
const ( F32 Quantization = iota BF16 F16 F64 I8 B1 )
Different quantization kinds supported by the USearch library.
func (Quantization) String ¶
func (a Quantization) String() string
String returns the string representation of the Quantization.