Documentation
¶
Index ¶
- type Child
- type ClosureTable
- func (table *ClosureTable) AddChild(new Child) error
- func (table *ClosureTable) AddRelationship(r Relationship) error
- func (table *ClosureTable) DeepestRelationships() ([]int, map[int][]Relationship)
- func (table *ClosureTable) DepthOneRelationships() []Relationship
- func (table *ClosureTable) EntityExists(id int64) bool
- func (table *ClosureTable) GetAncestralRelationships(id int64) []Relationship
- func (table *ClosureTable) RootNodeId() (int64, error)
- func (ct *ClosureTable) Size() int
- func (table *ClosureTable) TableToTree(entries map[int64]interface{}) (*binarytree.Tree, error)
- type Relationship
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Child ¶
A Child is intended to be an ephemeral entity that gets validated and converted to a Relationship
type ClosureTable ¶
type ClosureTable []Relationship
A ClosureTable should represent every direct-line relationship, including self-to-self
func New ¶
func New(origin int64) *ClosureTable
func (*ClosureTable) AddChild ¶
func (table *ClosureTable) AddChild(new Child) error
AddChild takes a Child, verifies that it is acceptable, verifies that the ClosureTable is suitable to accept a child, and then creates the appropriate Relationships within the ClosureTable to instantiate that child.
func (*ClosureTable) AddRelationship ¶
func (table *ClosureTable) AddRelationship(r Relationship) error
Allows you to add relationships manually Note that this is unsafe, because it relies on you to get all relationships right, instead of building intermediary relationships for you
func (*ClosureTable) DeepestRelationships ¶
func (table *ClosureTable) DeepestRelationships() ([]int, map[int][]Relationship)
Returns a map of the ID of each node along with its maximum depth
func (*ClosureTable) DepthOneRelationships ¶
func (table *ClosureTable) DepthOneRelationships() []Relationship
Returns a map of the ID of each node along with its immediate parent
func (*ClosureTable) EntityExists ¶
func (table *ClosureTable) EntityExists(id int64) bool
EntityExists asks if an entity of a given id exists in the closure table Entities that exist are guaranteed to appear at least once in ancestor and descendant thanks to the self relationship, so the choice of which one to inspect is arbitrary
func (*ClosureTable) GetAncestralRelationships ¶
func (table *ClosureTable) GetAncestralRelationships(id int64) []Relationship
func (*ClosureTable) RootNodeId ¶
func (table *ClosureTable) RootNodeId() (int64, error)
Return the id of the root node of the closure table. This method assumes that there can only be one root node.
func (*ClosureTable) Size ¶
func (ct *ClosureTable) Size() int
func (*ClosureTable) TableToTree ¶
func (table *ClosureTable) TableToTree(entries map[int64]interface{}) (*binarytree.Tree, error)
Takes map of entries whose keys are the same values as the IDs of the closure table entries Returns a well-formed *binarytree.Tree with those entries as values.
type Relationship ¶
A Relationship is the fundamental unit of the closure table. A relationship is defined between every entry and itselft, its parent, and any of its parent's ancestors.