Documentation ¶
Index ¶
- type DistancePair
- type DistancePairList
- type RegommendItem
- type RegommendTable
- func (table *RegommendTable) Add(key interface{}, data map[interface{}]float64) *RegommendItem
- func (table *RegommendTable) Count() int
- func (table *RegommendTable) Delete(key interface{}) (*RegommendItem, error)
- func (table *RegommendTable) Exists(key interface{}) bool
- func (table *RegommendTable) Flush()
- func (table *RegommendTable) Neighbors(key interface{}) (DistancePairList, error)
- func (table *RegommendTable) Recommend(key interface{}) (DistancePairList, error)
- func (table *RegommendTable) SetAboutToDeleteItemCallback(f func(*RegommendItem))
- func (table *RegommendTable) SetAddedItemCallback(f func(*RegommendItem))
- func (table *RegommendTable) SetDataLoader(f func(interface{}) *RegommendItem)
- func (table *RegommendTable) SetLogger(logger *log.Logger)
- func (table *RegommendTable) Value(key interface{}) (*RegommendItem, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DistancePair ¶
type DistancePair struct { Key interface{} Distance float64 }
type DistancePairList ¶
type DistancePairList []DistancePair
func (DistancePairList) Len ¶
func (p DistancePairList) Len() int
func (DistancePairList) Less ¶
func (p DistancePairList) Less(i, j int) bool
func (DistancePairList) Swap ¶
func (p DistancePairList) Swap(i, j int)
type RegommendItem ¶
Structure of an item in the recommendation engine. Parameter data contains the user-set value in the engine.
func CreateRegommendItem ¶
func CreateRegommendItem(key interface{}, data map[interface{}]float64) RegommendItem
CreateRegommendItem returns a newly created RegommendItem. Parameter key is the item's key. Parameter data is the item's value.
func (*RegommendItem) Data ¶
func (item *RegommendItem) Data() map[interface{}]float64
Data returns the value of this item.
func (*RegommendItem) Key ¶
func (item *RegommendItem) Key() interface{}
Key returns the key of this item.
type RegommendTable ¶
Structure of a table with items in the engine.
func Table ¶
func Table(table string) *RegommendTable
Table returns the existing engine table with given name or creates a new one if the table does not exist yet.
func (*RegommendTable) Add ¶
func (table *RegommendTable) Add(key interface{}, data map[interface{}]float64) *RegommendItem
Add adds a key/value pair to the engine. Parameter key is the item's engine-key. Parameter data is the item's value.
func (*RegommendTable) Count ¶
func (table *RegommendTable) Count() int
Count returns how many items are currently stored in the engine.
func (*RegommendTable) Delete ¶
func (table *RegommendTable) Delete(key interface{}) (*RegommendItem, error)
Delete an item from the engine.
func (*RegommendTable) Exists ¶
func (table *RegommendTable) Exists(key interface{}) bool
Test whether an item exists in the engine. Unlike the Value method Exists neither tries to fetch data via the loadData callback nor does it keep the item alive in the engine.
func (*RegommendTable) Neighbors ¶
func (table *RegommendTable) Neighbors(key interface{}) (DistancePairList, error)
func (*RegommendTable) Recommend ¶
func (table *RegommendTable) Recommend(key interface{}) (DistancePairList, error)
func (*RegommendTable) SetAboutToDeleteItemCallback ¶
func (table *RegommendTable) SetAboutToDeleteItemCallback(f func(*RegommendItem))
Configures a callback, which will be called every time an item is about to be removed from the engine.
func (*RegommendTable) SetAddedItemCallback ¶
func (table *RegommendTable) SetAddedItemCallback(f func(*RegommendItem))
Configures a callback, which will be called every time a new item is added to the engine.
func (*RegommendTable) SetDataLoader ¶
func (table *RegommendTable) SetDataLoader(f func(interface{}) *RegommendItem)
Configures a data-loader callback, which will be called when trying to use access a non-existing key.
func (*RegommendTable) SetLogger ¶
func (table *RegommendTable) SetLogger(logger *log.Logger)
Sets the logger to be used by this engine table.
func (*RegommendTable) Value ¶
func (table *RegommendTable) Value(key interface{}) (*RegommendItem, error)
Value gets an item from the engine and mark it to be kept alive.