Documentation ¶
Index ¶
- func AngularDistance(a []float32, b []float32) float64
- func CalculateAverage(avg []float32, p []float32, n float32) []float32
- func CheckIfUnkownError(err error) bool
- func CloneResult(result []*pb.ScoredDatum) []*pb.ScoredDatum
- func CosineSimilarity(a []float32, b []float32) float64
- func CosineSimilarity32(a []float32, b []float32) float32
- func CosineSimilarity64(a []float64, b []float64) float64
- func DefaultSearchConfig() *pb.SearchConfig
- func EncodeSearchConfig(sc *pb.SearchConfig) []byte
- func GetDefaultConfig(name string) *pb.DataConfig
- func GetInternalKeyAsBytes(datum *models.InternalDatum) ([]byte, error)
- func GetKeyAsBytes(datum *pb.Datum) ([]byte, error)
- func GetRetention(retention uint64) time.Duration
- func GetSearchKey(datum *pb.Datum, config *pb.SearchConfig) string
- func GetValueAsBytes(datum *pb.Datum) ([]byte, error)
- func GetVectorComparisonFunction(name string) func(arr1 []float32, arr2 []float32) float64
- func InsertConfigFromExpireAt(expiresAt uint64) *pb.InsertConfig
- func InternalDatumToDatum(ptrValue *models.InternalDatum) *pb.Datum
- func NewAllocadtedDatum(datum *pb.Datum) *models.InternalDatum
- func NewDatum(feature []float32, dim1 uint32, dim2 uint32, size1 uint32, size2 uint32, ...) *pb.Datum
- func QuickVectorDistance(arr1 []float32, arr2 []float32) float64
- func ToDatum(key, value []byte) (*pb.Datum, error)
- func ToDatumKey(byteArray []byte) (*pb.DatumKey, error)
- func ToDatumValue(byteArray []byte) (*pb.DatumValue, error)
- func VectorDistance(arr1 []float32, arr2 []float32) float64
- func VectorMultiplication(arr1 []float32, arr2 []float32) float64
- type Aggregator
- func (a *Aggregator) BestScore(scoredDatum *pb.ScoredDatum) float64
- func (a *Aggregator) Insert(scoredDatum *pb.ScoredDatum) error
- func (a *Aggregator) InsertToList(scoredDatum *pb.ScoredDatum) error
- func (a *Aggregator) IsNewScoredBetter(old, new float64) bool
- func (a *Aggregator) One() *pb.ScoredDatum
- func (a *Aggregator) Result() []*pb.ScoredDatum
- type AggregatorInterface
- type Annoyer
- type Collector
- type DBMapEntry
- type Data
- func (dt *Data) AddSource(dataSource DataSource) error
- func (dt *Data) AggregatedSearch(datum *pb.Datum, scoredDatumStreamOutput chan<- *pb.ScoredDatum, ...) error
- func (dt *Data) Close() error
- func (dt *Data) DataSourceDiffMap() (map[string]uint64, uint64)
- func (dt *Data) Delete(datum *pb.Datum) error
- func (dt *Data) DeleteBDMap(datum *pb.Datum) error
- func (dt *Data) DeletePath() error
- func (d *Data) GetConfig() *pb.DataConfig
- func (dt *Data) GetDataInfo() *pb.DataInfo
- func (dt *Data) GetID() string
- func (dt *Data) InitData() error
- func (dt *Data) Insert(datum *pb.Datum, config *pb.InsertConfig) error
- func (dt *Data) InsertBDMap(datum *pb.Datum, config *pb.InsertConfig) error
- func (dt *Data) LoopDBMap(entryFunction func(entry *DBMapEntry) error) error
- func (dt *Data) MultiAggregatedSearch(datumList []*pb.Datum, config *pb.SearchConfig, context *pb.SearchContext) ([]*pb.ScoredDatum, error)
- func (dt *Data) Process(force bool) error
- func (dt *Data) Run() error
- func (dt *Data) RunOnRandomSources(sourceLimit int, sourceFunction func(dataSource DataSource) error) error
- func (dt *Data) SearchAnnoy(datum *pb.Datum, config *pb.SearchConfig) *Collector
- func (dt *Data) StreamSearch(datum *pb.Datum, scoredDatumStream chan<- *pb.ScoredDatum, ...) error
- type DataSource
- type Dataset
- func (dts *Dataset) Close() error
- func (dts *Dataset) CreateIfNotExists(config *pb.DataConfig) error
- func (dts *Dataset) DataConfigList() []*pb.DataConfig
- func (dts *Dataset) Delete(name string) error
- func (dts *Dataset) Get(name string) (*Data, error)
- func (dts *Dataset) GetNoCreate(name string) (*Data, error)
- func (dts *Dataset) GetNoOp(name string) (*Data, error)
- func (dts *Dataset) GetOrCreateIfNotExists(config *pb.DataConfig) (*Data, error)
- func (dts *Dataset) List() []string
- func (dts *Dataset) LoadIndex() error
- func (dts *Dataset) SaveIndex() error
- type InsertStreamCollector
- type StreamCollector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AngularDistance ¶ added in v0.0.53
AngularDistance sim(u.v) = (1 - arccos(cosine_similarity(u, v)) / pi)
func CalculateAverage ¶
CalculateAverage calculates average of two arrays divided by n
func CheckIfUnkownError ¶ added in v0.0.63
func CloneResult ¶ added in v0.0.30
func CloneResult(result []*pb.ScoredDatum) []*pb.ScoredDatum
func CosineSimilarity ¶ added in v0.0.23
CosineSimilarity for vector similarity
func CosineSimilarity32 ¶ added in v0.0.46
CosineSimilarity for vector similarity
func CosineSimilarity64 ¶ added in v0.0.46
CosineSimilarity64 for vector similarity
func DefaultSearchConfig ¶ added in v0.0.22
func DefaultSearchConfig() *pb.SearchConfig
func EncodeSearchConfig ¶ added in v0.0.22
func EncodeSearchConfig(sc *pb.SearchConfig) []byte
func GetDefaultConfig ¶ added in v0.0.43
func GetDefaultConfig(name string) *pb.DataConfig
func GetInternalKeyAsBytes ¶ added in v0.0.70
func GetInternalKeyAsBytes(datum *models.InternalDatum) ([]byte, error)
Gencode
func GetRetention ¶ added in v0.0.44
func GetSearchKey ¶ added in v0.0.22
func GetSearchKey(datum *pb.Datum, config *pb.SearchConfig) string
func GetVectorComparisonFunction ¶ added in v0.0.23
func InsertConfigFromExpireAt ¶ added in v0.0.22
func InsertConfigFromExpireAt(expiresAt uint64) *pb.InsertConfig
func InternalDatumToDatum ¶ added in v0.0.70
func InternalDatumToDatum(ptrValue *models.InternalDatum) *pb.Datum
func NewAllocadtedDatum ¶ added in v0.0.68
func NewAllocadtedDatum(datum *pb.Datum) *models.InternalDatum
func NewDatum ¶ added in v0.0.22
func NewDatum(feature []float32, dim1 uint32, dim2 uint32, size1 uint32, size2 uint32, groupLabel []byte, label []byte, version uint64, ) *pb.Datum
NewDatum is an utily function to initialize datum type
func QuickVectorDistance ¶ added in v0.0.30
func ToDatumValue ¶ added in v0.0.22
func ToDatumValue(byteArray []byte) (*pb.DatumValue, error)
func VectorDistance ¶
VectorDistance calculates distance of two vector by euclidean distance
func VectorMultiplication ¶ added in v0.0.22
VectorMultiplication calculates elementwise of multiplication of two vectors
Types ¶
type Aggregator ¶ added in v0.0.23
type Aggregator struct { Config *pb.SearchConfig List []*pb.ScoredDatum DeDuplicationMap *cache.Cache Grouped bool Context *pb.SearchContext ScoreFunc func(arr1 []float32, arr2 []float32) float64 }
func (*Aggregator) BestScore ¶ added in v0.0.23
func (a *Aggregator) BestScore(scoredDatum *pb.ScoredDatum) float64
func (*Aggregator) Insert ¶ added in v0.0.23
func (a *Aggregator) Insert(scoredDatum *pb.ScoredDatum) error
func (*Aggregator) InsertToList ¶ added in v0.0.23
func (a *Aggregator) InsertToList(scoredDatum *pb.ScoredDatum) error
func (*Aggregator) IsNewScoredBetter ¶ added in v0.0.23
func (a *Aggregator) IsNewScoredBetter(old, new float64) bool
func (*Aggregator) One ¶ added in v0.0.23
func (a *Aggregator) One() *pb.ScoredDatum
func (*Aggregator) Result ¶ added in v0.0.23
func (a *Aggregator) Result() []*pb.ScoredDatum
type AggregatorInterface ¶ added in v0.0.23
type AggregatorInterface interface { Insert(*pb.ScoredDatum) error One() *pb.ScoredDatum Result() []*pb.ScoredDatum }
func NewAggrator ¶ added in v0.0.23
func NewAggrator(config *pb.SearchConfig, grouped bool, context *pb.SearchContext) AggregatorInterface
type Annoyer ¶ added in v0.0.45
type Annoyer struct { sync.RWMutex DataIndex *[]*DBMapEntry AnnoyIndex annoyindex.AnnoyIndexAngular BuildFileName string }
type Collector ¶ added in v0.0.22
type Collector struct { List []*pb.ScoredDatum ScoreFunc func(arr1 []float32, arr2 []float32) float64 MaxScore float64 DatumKey *pb.DatumKey N uint32 HigherIsBetter bool Filters []string GroupFilters []string }
Collector collects results
type DBMapEntry ¶ added in v0.0.64
type Data ¶
type Data struct { sync.RWMutex Config *pb.DataConfig Path string Avg []float32 N uint64 MaxDistance float64 Hist []float32 Timestamp uint64 // DB *badger.DB DBPath string Dirty bool Sources *cache.Cache QueryCache *cache.Cache Initialized bool Alive bool Annoyer Annoyer Runs int32 DBMap sync.Map }
Data represents a dataset with similar struture
func NewData ¶
func NewData(config *pb.DataConfig, dataPath string) (*Data, error)
NewData creates a data struct
func NewPreData ¶ added in v0.0.22
func NewPreData(config *pb.DataConfig, dataPath string) *Data
NewPreData creates a data struct
func (*Data) AddSource ¶ added in v0.0.22
func (dt *Data) AddSource(dataSource DataSource) error
AddSource adds a source
func (*Data) AggregatedSearch ¶ added in v0.0.23
func (dt *Data) AggregatedSearch(datum *pb.Datum, scoredDatumStreamOutput chan<- *pb.ScoredDatum, upperWaitGroup *sync.WaitGroup, config *pb.SearchConfig) error
AggregatedSearch searches and merges other resources
func (*Data) DataSourceDiffMap ¶ added in v0.0.57
func (*Data) DeletePath ¶ added in v0.0.25
Delete currently deletes underlying data folder ignores errors.
func (*Data) GetConfig ¶ added in v0.0.22
func (d *Data) GetConfig() *pb.DataConfig
func (*Data) GetDataInfo ¶ added in v0.0.22
GetDataInfo out of data
func (*Data) InsertBDMap ¶ added in v0.0.64
func (*Data) LoopDBMap ¶ added in v0.0.64
func (dt *Data) LoopDBMap(entryFunction func(entry *DBMapEntry) error) error
func (*Data) MultiAggregatedSearch ¶ added in v0.0.23
func (dt *Data) MultiAggregatedSearch(datumList []*pb.Datum, config *pb.SearchConfig, context *pb.SearchContext) ([]*pb.ScoredDatum, error)
MultiAggregatedSearch searches and merges other resources
func (*Data) RunOnRandomSources ¶ added in v0.0.46
func (dt *Data) RunOnRandomSources(sourceLimit int, sourceFunction func(dataSource DataSource) error) error
func (*Data) SearchAnnoy ¶ added in v0.0.45
Search does a search based on distances of keys
func (*Data) StreamSearch ¶ added in v0.0.22
func (dt *Data) StreamSearch(datum *pb.Datum, scoredDatumStream chan<- *pb.ScoredDatum, queryWaitGroup *sync.WaitGroup, config *pb.SearchConfig) error
StreamSearch does a search based on distances of keys
type DataSource ¶ added in v0.0.22
type Dataset ¶ added in v0.0.22
func NewDataset ¶ added in v0.0.22
func (*Dataset) CreateIfNotExists ¶ added in v0.0.22
func (dts *Dataset) CreateIfNotExists(config *pb.DataConfig) error
func (*Dataset) DataConfigList ¶ added in v0.0.22
func (dts *Dataset) DataConfigList() []*pb.DataConfig
func (*Dataset) GetNoCreate ¶ added in v0.0.43
func (*Dataset) GetOrCreateIfNotExists ¶ added in v0.0.22
func (dts *Dataset) GetOrCreateIfNotExists(config *pb.DataConfig) (*Data, error)
type InsertStreamCollector ¶ added in v0.0.22
type InsertStreamCollector struct {
DatumStream chan<- *pb.InsertDatumWithConfig
}
InsertStreamCollector collects results
type StreamCollector ¶ added in v0.0.22
StreamCollector collects results