graphd

package
v0.0.0-...-1eb5c16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MetaDBName = "meta.db"

MetaDBName is the filename of the meta database

View Source
var PartitionSize = 100_000

PartitionSize is the number of actors per SQLite partition

View Source
var ShardDBPattern = "actors_%d.db"

ShardDBPattern is the pattern for the shard database filenames

Functions

This section is empty.

Types

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

func NewGraph

func NewGraph(ctx context.Context, logger *slog.Logger, cfg *GraphConfig) (*Graph, error)

func (*Graph) AcquireDID

func (g *Graph) AcquireDID(ctx context.Context, did string, flush bool) (uint32, bool, error)

AcquireDID links a DID to a UID, creating a new UID if necessary. If the DID is already linked to a UID, that UID is returned If the DID is not linked to a UID, a new UID is created and linked to the DID The function returns the UID and a boolean indicating if the UID was created

func (*Graph) AddFollow

func (g *Graph) AddFollow(ctx context.Context, actorUID, targetUID uint32, flush bool) error

AddFollow adds a follow relationship between the actorUID and the targetUID

func (*Graph) DoesFollow

func (g *Graph) DoesFollow(ctx context.Context, actorUID, targetUID uint32) (bool, error)

DoesFollow returns true if the actorUID is following the targetUID

func (*Graph) GetDID

func (g *Graph) GetDID(ctx context.Context, uid uint32) (string, bool, error)

func (*Graph) GetDIDs

func (g *Graph) GetDIDs(ctx context.Context, uids []uint32) ([]string, error)

func (*Graph) GetFollowers

func (g *Graph) GetFollowers(ctx context.Context, uid uint32) ([]uint32, error)

GetFollowers returns the accounts that are following the given UID

func (*Graph) GetFollowersNotFollowing

func (g *Graph) GetFollowersNotFollowing(ctx context.Context, uid uint32) ([]uint32, error)

GetFollowersNotFollowing returns a list of followers of the given UID that the given UID is not following

func (*Graph) GetFollowing

func (g *Graph) GetFollowing(ctx context.Context, uid uint32) ([]uint32, error)

GetFollowing returns the accounts that the given UID is following

func (*Graph) GetMoots

func (g *Graph) GetMoots(ctx context.Context, uid uint32) ([]uint32, error)

GetMoots returns the accounts that the given UID is following and that are following the given UID back

func (*Graph) GetUID

func (g *Graph) GetUID(ctx context.Context, did string) (uint32, bool, error)

func (*Graph) GetUIDs

func (g *Graph) GetUIDs(ctx context.Context, dids []string) ([]uint32, error)

func (*Graph) IntersectFollowers

func (g *Graph) IntersectFollowers(ctx context.Context, uids []uint32) ([]uint32, error)

IntersectFollowers returns the intersection of the followers of the given UIDs

func (*Graph) IntersectFollowing

func (g *Graph) IntersectFollowing(ctx context.Context, uids []uint32) ([]uint32, error)

IntersectFollowing returns the intersection of the accounts that the given UIDs are following

func (*Graph) IntersectFollowingAndFollowers

func (g *Graph) IntersectFollowingAndFollowers(ctx context.Context, actorUID, targetUID uint32) ([]uint32, error)

IntersectFollowingAndFollowers returns the intersection of the following of the actorUID and the followers of the targetUID

func (*Graph) LoadFromCSV

func (g *Graph) LoadFromCSV(csvFile string) error

func (*Graph) RemoveFollow

func (g *Graph) RemoveFollow(ctx context.Context, actorUID, targetUID uint32, flush bool) error

RemoveFollow removes the follow relationship between the actorUID and the targetUID

func (*Graph) Shutdown

func (g *Graph) Shutdown()

type GraphConfig

type GraphConfig struct {
	DBPath    string
	ShardSize uint32
	CacheSize int
}

func DefaultGraphConfig

func DefaultGraphConfig() *GraphConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL