Documentation ¶
Index ¶
- func ArrToBytes(arr []float64) []byte
- func BytesToArray(arr []byte) []float64
- func EuclideanDistance(x Vector, y Vector) float64
- func Float64bytes(float float64) []byte
- func Float64frombytes(bytes []byte) float64
- type BranchDistance
- type Distance
- type Index
- type MemoryVector
- type PersistantStore
- func ConstructPersistantStore(dimension uint32, indexFile, vectorsFile, searchindexFile string) *PersistantStore
- func LoadPersistantStore(dimension uint32, indexFile, vectorsFile, searchindexFiles string) *PersistantStore
- func NewPersitantStore(dimension uint32, indexFile, vectorsFile, searchindexFile string) (*PersistantStore, error)
- func (s *PersistantStore) Delete(id string) error
- func (s *PersistantStore) Get(id string) (Vector, error)
- func (s *PersistantStore) KNN(vector Vector, k int) (*[]Distance, error)
- func (s *PersistantStore) ReadVector(id string) ([]float64, error)
- func (s *PersistantStore) Set(id string, vector Vector) error
- func (s *PersistantStore) WriteVector(v *[]float64, id string)
- type PersistantVector
- type SimpleMapStore
- type Store
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EuclideanDistance ¶
*
- EuclideanDistance
- Distance between two vectors x= <x_1, x_2, x_3> and y= <y_1, y_2, y_3>
- is defined as {(x_1-y_1)²+(x_2-y_2)²+(x_3-y_3)²\}^{1/2}.
func Float64frombytes ¶
Transforms a float64 into 8 bytes
Types ¶
type BranchDistance ¶
type BranchDistance struct { Target *branch Distance float64 //Distance }
type Distance ¶
* * Return structure for the kNN algorithm * holding the string as key, the vector for corresponding key and the distance
type MemoryVector ¶
Vector is the main storage unit
func Ones ¶
func Ones(id string, size int) *MemoryVector
Ones will return a Vector where all the values are equal to 1.0
func Random ¶
func Random(id string, size int) *MemoryVector
Random will create a Vector with values in range (0,1)
func Zeros ¶
func Zeros(id string, size int) *MemoryVector
Zeros will return a Vector where all the values are equal to 0.0
func (*MemoryVector) Name ¶
func (v *MemoryVector) Name() string
func (*MemoryVector) Values ¶
func (v *MemoryVector) Values() *[]float64
type PersistantStore ¶
type PersistantStore struct {
// contains filtered or unexported fields
}
func ConstructPersistantStore ¶
func ConstructPersistantStore(dimension uint32, indexFile, vectorsFile, searchindexFile string) *PersistantStore
Creates a new persistant store
func LoadPersistantStore ¶
func LoadPersistantStore(dimension uint32, indexFile, vectorsFile, searchindexFiles string) *PersistantStore
Loads an existing store
func NewPersitantStore ¶
func NewPersitantStore(dimension uint32, indexFile, vectorsFile, searchindexFile string) (*PersistantStore, error)
func (*PersistantStore) Delete ¶
func (s *PersistantStore) Delete(id string) error
func (*PersistantStore) KNN ¶
func (s *PersistantStore) KNN(vector Vector, k int) (*[]Distance, error)
func (*PersistantStore) ReadVector ¶
func (s *PersistantStore) ReadVector(id string) ([]float64, error)
Reads the values of a vector from a given position
func (*PersistantStore) WriteVector ¶
func (s *PersistantStore) WriteVector(v *[]float64, id string)
Writes the values of a vector in a given position in the file
type PersistantVector ¶
type PersistantVector struct { ID string // contains filtered or unexported fields }
func (*PersistantVector) Name ¶
func (v *PersistantVector) Name() string
func (*PersistantVector) Values ¶
func (v *PersistantVector) Values() *[]float64
type SimpleMapStore ¶
type SimpleMapStore struct {
// contains filtered or unexported fields
}
SimpleMapStore implements the Store interface using a Go map
func NewSimpleMapStore ¶
func NewSimpleMapStore() *SimpleMapStore
NewSimpleMapStore returns a new map store
func (*SimpleMapStore) Delete ¶
func (s *SimpleMapStore) Delete(id string) error
Delete a given value from the store
func (*SimpleMapStore) Get ¶
func (s *SimpleMapStore) Get(id string) (Vector, error)
Get Vector pointer using a given id, returns error if not found