Documentation
¶
Index ¶
- type RPTIndex
- func (r *RPTIndex) Add(id int, vector []float32) error
- func (r *RPTIndex) BulkAdd(vectors map[int][]float32) error
- func (r *RPTIndex) BulkDelete(ids []int) error
- func (r *RPTIndex) BulkUpdate(updates map[int][]float32) error
- func (r *RPTIndex) Delete(id int) error
- func (r *RPTIndex) GobDecode(data []byte) error
- func (r *RPTIndex) GobEncode() ([]byte, error)
- func (r *RPTIndex) Load(rdr io.Reader) error
- func (r *RPTIndex) Save(w io.Writer) error
- func (r *RPTIndex) Search(query []float32, k int) ([]core.Neighbor, error)
- func (r *RPTIndex) Stats() core.IndexStats
- func (r *RPTIndex) Update(id int, vector []float32) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RPTIndex ¶
type RPTIndex struct {
Distance core.DistanceFunc // function to compute distance between vectors
DistanceName string // name of the distance metric
LeafCapacity int // maximum number of points in a leaf
CandidateProjections int // number of random projections to try when splitting
ParallelThreshold int // threshold to trigger parallel tree building
ProbeMargin float64 // margin for multi-probe search
AllowBruteForceFallback bool // whether to allow falling back to a full brute-force scan
// contains filtered or unexported fields
}
RPTIndex is the main structure for the random projection tree index. It holds all points, the tree root, and configuration parameters.
func NewRPTIndex ¶
func NewRPTIndex( dimension int, leafCapacity int, candidateProjections int, parallelThreshold int, probeMargin float64, ) *RPTIndex
NewRPTIndex creates a new RPT (Random Projection Tree) index. It initializes parameters like dimension, leaf capacity, candidate projections, parallel threshold, and probe margin.
func (*RPTIndex) Add ¶
Add inserts a new point with the given id and vector into the index. It marks the tree as dirty so it will be rebuilt.
func (*RPTIndex) BulkAdd ¶
BulkAdd inserts multiple points into the index and marks the tree as dirty.
func (*RPTIndex) BulkDelete ¶
BulkDelete removes multiple points from the index and marks the tree as dirty.
func (*RPTIndex) BulkUpdate ¶
BulkUpdate updates multiple points in the index.
func (*RPTIndex) Search ¶
Search returns the k nearest neighbors to the query vector. It rebuilds the tree if needed and uses multi-probe search to get candidate ids.
func (*RPTIndex) Stats ¶
func (r *RPTIndex) Stats() core.IndexStats
Stats returns some basic statistics about the index.