relation

package
v0.1.2-beta Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Relation

type Relation struct {
	schema.Schema
	tuple.TupleSet
}

Relation is a set of tuples with a common schema.

func Clone

func Clone(r *Relation) *Relation

Clone returns a new relation with the same schema and tuples as r. The schema is considered read-only so it is not cloned.

func New

func New(s schema.Schema) (*Relation, error)

New creates a new relation with the given schema.

func (*Relation) Add

func (r *Relation) Add(t tuple.Tuple) error

Add adds a tuple to the relation. If the tuple is already in the relation, it does nothing. If the tuple has a different schema than the relation, it returns ErrSchemaMismatch.

func (*Relation) Delete

func (r *Relation) Delete(u map[string]any)

func (*Relation) Difference

func (r *Relation) Difference(s *Relation) (*Relation, error)

Difference returns a new relation with tuples that are in r but not in s.

func (*Relation) Intersection

func (r *Relation) Intersection(s *Relation) (*Relation, error)

Intersection returns a new relation with tuples that are in r and in s.

func (*Relation) List

func (r *Relation) List() iter.Seq[map[string]any]

List returns a sequence of tuples in the relation.

func (*Relation) NaturalJoin

func (r *Relation) NaturalJoin(s *Relation) (*Relation, bool)

func (*Relation) Projection

func (r *Relation) Projection(p ...string) (*Relation, error)

func (*Relation) Rename1

func (r *Relation) Rename1(old, new string) (*Relation, error)

Rename1 returns a new relation with the attribute old renamed to new.

func (*Relation) Union

func (r *Relation) Union(s *Relation) (*Relation, error)

Union returns a new relation with tuples that are in r or in s.

type RelationSet

type RelationSet []*Relation

func (*RelationSet) Add

func (rs *RelationSet) Add(r *Relation)

Add adds a relation to the set.

func (*RelationSet) Relation

func (rs *RelationSet) Relation(schema schema.Schema) (*Relation, bool)

Relation returns the relation with the given schema and true if it is in the set.

Jump to

Keyboard shortcuts

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