Documentation
¶
Overview ¶
The mock store package allows for testing that are decoupled from a particular RandomWalkStore implementation.
Index ¶
- type RandomWalkStore
- func (RWS *RandomWalkStore) AddWalks(ctx context.Context, walks ...models.RandomWalk) error
- func (RWS *RandomWalkStore) Alpha(ctx context.Context) float32
- func (RWS *RandomWalkStore) GraftWalk(ctx context.Context, walkID uint32, walkSegment []uint32) error
- func (RWS *RandomWalkStore) PruneGraftWalk(ctx context.Context, walkID uint32, cutIndex int, ...) error
- func (RWS *RandomWalkStore) PruneWalk(ctx context.Context, walkID uint32, cutIndex int) error
- func (RWS *RandomWalkStore) RemoveWalks(ctx context.Context, walkIDs ...uint32) error
- func (RWS *RandomWalkStore) TotalVisits(ctx context.Context) int
- func (RWS *RandomWalkStore) Validate() error
- func (RWS *RandomWalkStore) VisitCounts(ctx context.Context, nodeIDs ...uint32) ([]int, error)
- func (RWS *RandomWalkStore) Walks(ctx context.Context, walkIDs ...uint32) ([]models.RandomWalk, error)
- func (RWS *RandomWalkStore) WalksPerNode(ctx context.Context) uint16
- func (RWS *RandomWalkStore) WalksVisiting(ctx context.Context, limit int, nodeIDs ...uint32) ([]uint32, error)
- func (RWS *RandomWalkStore) WalksVisitingAll(ctx context.Context, nodeIDs ...uint32) ([]uint32, error)
- type WalkSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RandomWalkStore ¶
type RandomWalkStore struct {
//Associates a walkID to the corrisponding RandomWalk
WalkIndex map[uint32]models.RandomWalk
// contains filtered or unexported fields
}
the in-memory version of the RandomWalkStore interface.
func NewRWS ¶
func NewRWS(alpha float32, walksPerNode uint16) (*RandomWalkStore, error)
Creates a new RandomWalkStore.
func SetupRWS ¶
func SetupRWS(RWSType string) *RandomWalkStore
SetupRWS() returns a RWS setup based on the RWSType.
func (*RandomWalkStore) AddWalks ¶
func (RWS *RandomWalkStore) AddWalks(ctx context.Context, walks ...models.RandomWalk) error
AddWalks() adds all the specified walks to the RWS. If at least one of the walks is invalid, no one gets added.
func (*RandomWalkStore) Alpha ¶
func (RWS *RandomWalkStore) Alpha(ctx context.Context) float32
Alpha() returns the dampening factor used for the RandomWalks
func (*RandomWalkStore) GraftWalk ¶
func (RWS *RandomWalkStore) GraftWalk(ctx context.Context, walkID uint32, walkSegment []uint32) error
GraftWalk() grafts (extends) the walk with the walkSegment, and adds the walkID to the WalkSet of each node in the new walkSegment.
func (*RandomWalkStore) PruneGraftWalk ¶
func (RWS *RandomWalkStore) PruneGraftWalk(ctx context.Context, walkID uint32, cutIndex int, walkSegment models.RandomWalk) error
PruneGraftWalk() encapsulates the functions of Pruning and Grafting a walk.
func (*RandomWalkStore) PruneWalk ¶
PruneWalk() prunes the specified walk, cutting at cutIndex (walk[:cutIndex])
func (*RandomWalkStore) RemoveWalks ¶
func (RWS *RandomWalkStore) RemoveWalks(ctx context.Context, walkIDs ...uint32) error
RemoveWalks() removes the all the specified walks from the RWS. If one walkID is not found, no walk gets removed.
func (*RandomWalkStore) TotalVisits ¶
func (RWS *RandomWalkStore) TotalVisits(ctx context.Context) int
TotalVisits() returns the total number of visits.
func (*RandomWalkStore) Validate ¶
func (RWS *RandomWalkStore) Validate() error
Validate() that RWS is not nil, and the fields alpha and walksPerNode
func (*RandomWalkStore) VisitCounts ¶
VisitCounts() returns the number of times each nodeID was visited by a walk. If nodeID is not found, 0 visits are returned.
func (*RandomWalkStore) Walks ¶
func (RWS *RandomWalkStore) Walks(ctx context.Context, walkIDs ...uint32) ([]models.RandomWalk, error)
Walks() returns a map of walks by walkID that visit nodeID. - if limit > 0, the map contains up to that many key-value pairs. - if limit < 0, all walks are returned - if no walks are found for nodeID, an error is returned
func (*RandomWalkStore) WalksPerNode ¶
func (RWS *RandomWalkStore) WalksPerNode(ctx context.Context) uint16
WalkPerNode() returns the number of walks to be generated for each node in the DB
func (*RandomWalkStore) WalksVisiting ¶
func (RWS *RandomWalkStore) WalksVisiting(ctx context.Context, limit int, nodeIDs ...uint32) ([]uint32, error)
WalksVisiting() returns up to limit UNIQUE walkIDs evenly distributed among the specified nodeIDs. In other words, it returns up to limit/len(nodeIDs) walkIDs for each of the nodes.
Note: - If limit = 0, no walk is returned - If limit < nodeIDs, no walk is returned - If limit = -1, all walks for all nodes are returned (USE WITH CAUTION).
func (*RandomWalkStore) WalksVisitingAll ¶
func (RWS *RandomWalkStore) WalksVisitingAll(ctx context.Context, nodeIDs ...uint32) ([]uint32, error)
WalksVisitingAll() returns all the IDs of the walk that visit ALL specified nodes.