Versions in this module Expand all Collapse all v0 v0.1.4 Jul 24, 2024 v0.1.3 Oct 5, 2023 Changes in this version type Index + Get func(values []any) (*list.Element, error) type Relation + func (r *Relation) CheckPrimaryKey(tuple *Tuple) (bool, error) v0.1.2 Aug 25, 2023 v0.1.1 Aug 21, 2023 v0.1.0 Aug 17, 2023 Changes in this version + const DefaultSchema + var NotImplemented = errors.New("not implemented") + func PrintQueryPlan(n Node, depth int, printer func(fmt string, varargs ...any)) + func ToInstance(value, typeName string) (any, error) + func WithAlias(alias string) func(*AttributeSelector) + type AndPredicate struct + func NewAndPredicate(left, right Predicate) *AndPredicate + func (p *AndPredicate) Attribute() []string + func (p *AndPredicate) Eval(cols []string, t *Tuple) (bool, error) + func (p *AndPredicate) Left() (Predicate, bool) + func (p *AndPredicate) Relation() string + func (p *AndPredicate) Right() (Predicate, bool) + func (p *AndPredicate) Type() PredicateType + func (p AndPredicate) String() string + type Attribute struct + func NewAttribute(name, typeName string) Attribute + func (a Attribute) HasAutoIncrement() bool + func (a Attribute) Name() string + func (a Attribute) String() string + func (a Attribute) WithAutoIncrement() Attribute + func (a Attribute) WithDefault(defaultValue Defaulter) Attribute + func (a Attribute) WithDefaultConst(defaultValue any) Attribute + func (a Attribute) WithDefaultNow() Attribute + func (a Attribute) WithUnique() Attribute + type AttributeSelector struct + func NewAttributeSelector(rel string, attrs []string, functors ...func(*AttributeSelector)) *AttributeSelector + func (s *AttributeSelector) Alias() string + func (s *AttributeSelector) Attribute() []string + func (s *AttributeSelector) Relation() string + func (s *AttributeSelector) Select(cols []string, in []*list.Element) (out []*Tuple, err error) + func (s AttributeSelector) String() string + type AttributeValueFunctor struct + func (f *AttributeValueFunctor) Attribute() []string + func (f *AttributeValueFunctor) Relation() string + func (f *AttributeValueFunctor) Value(cols []string, t *Tuple) any + func (f AttributeValueFunctor) String() string + type AvgSelector struct + type ConstValueFunctor struct + func (f *ConstValueFunctor) Attribute() []string + func (f *ConstValueFunctor) Relation() string + func (f *ConstValueFunctor) Value([]string, *Tuple) any + func (f ConstValueFunctor) String() string + type CountSelector struct + func NewCountSelector(rname string, attr string) *CountSelector + func (s *CountSelector) Alias() string + func (s *CountSelector) Attribute() []string + func (s *CountSelector) Relation() string + func (s *CountSelector) Select(cols []string, in []*list.Element) (out []*Tuple, err error) + type Defaulter func() any + func NewRandString(n int) Defaulter + type Deleter struct + func NewDeleterNode(relation *Relation, changes *list.List) *Deleter + func (u *Deleter) Attribute() []string + func (u *Deleter) Children() []Node + func (u *Deleter) EstimateCardinal() int64 + func (u *Deleter) Exec() (cols []string, out []*list.Element, err error) + func (u *Deleter) Relation() string + func (u Deleter) String() string + type DistinctSorter struct + func NewDistinctSorter(rel string, attrs []string) *DistinctSorter + func (d *DistinctSorter) Children() []Node + func (d *DistinctSorter) EstimateCardinal() int64 + func (d *DistinctSorter) Exec() ([]string, []*list.Element, error) + func (d *DistinctSorter) Priority() int + func (d *DistinctSorter) SetNode(n Node) + func (s DistinctSorter) String() string + type Domain struct + type Engine struct + func NewEngine() *Engine + func (e *Engine) Begin() (*Transaction, error) + type EqPredicate struct + func NewEqPredicate(left, right ValueFunctor) *EqPredicate + func (p *EqPredicate) Attribute() []string + func (p *EqPredicate) Eval(cols []string, t *Tuple) (bool, error) + func (p *EqPredicate) Left() (Predicate, bool) + func (p *EqPredicate) Relation() string + func (p *EqPredicate) Right() (Predicate, bool) + func (p *EqPredicate) Type() PredicateType + func (p EqPredicate) String() string + type FalsePredicate struct + func NewFalsePredicate() *FalsePredicate + func (p *FalsePredicate) Attribute() []string + func (p *FalsePredicate) Eval([]string, *Tuple) (bool, error) + func (p *FalsePredicate) Left() (Predicate, bool) + func (p *FalsePredicate) Relation() string + func (p *FalsePredicate) Right() (Predicate, bool) + func (p *FalsePredicate) Type() PredicateType + func (p FalsePredicate) String() string + type ForeignKey struct + type GePredicate struct + func NewGePredicate(left, right ValueFunctor) *GePredicate + func (p *GePredicate) Attribute() []string + func (p *GePredicate) Eval(cols []string, t *Tuple) (bool, error) + func (p *GePredicate) Left() (Predicate, bool) + func (p *GePredicate) Relation() string + func (p *GePredicate) Right() (Predicate, bool) + func (p *GePredicate) Type() PredicateType + func (p GePredicate) String() string + type GeqPredicate struct + func NewGeqPredicate(left, right ValueFunctor) *GeqPredicate + func (p *GeqPredicate) Attribute() []string + func (p *GeqPredicate) Eval(cols []string, t *Tuple) (bool, error) + func (p *GeqPredicate) Left() (Predicate, bool) + func (p *GeqPredicate) Relation() string + func (p *GeqPredicate) Right() (Predicate, bool) + func (p *GeqPredicate) Type() PredicateType + func (p GeqPredicate) String() string + type GroupBySorter struct + func NewGroupBySorter(rel string, attrs []string) *GroupBySorter + func (s *GroupBySorter) Children() []Node + func (s *GroupBySorter) EstimateCardinal() int64 + func (s *GroupBySorter) Exec() ([]string, []*list.Element, error) + func (s *GroupBySorter) Priority() int + func (s *GroupBySorter) SetNode(n Node) + func (s *GroupBySorter) SetSelector(n Node) + func (s GroupBySorter) String() string + type HashIndex struct + func NewHashIndex(name string, relName string, relAttrs []Attribute, attrsName []string, ...) *HashIndex + func (h *HashIndex) Add(e *list.Element) + func (h *HashIndex) CanSourceWith(p Predicate) (bool, int64) + func (h *HashIndex) Get(values []any) (*list.Element, error) + func (h *HashIndex) Name() string + func (h *HashIndex) Remove(e *list.Element) + func (h *HashIndex) String() string + func (h *HashIndex) Truncate() + type InPredicate struct + func NewInPredicate(v ValueFunctor, src Node) *InPredicate + func (p *InPredicate) Attribute() []string + func (p *InPredicate) Eval(inCols []string, in *Tuple) (bool, error) + func (p *InPredicate) Left() (Predicate, bool) + func (p *InPredicate) Relation() string + func (p *InPredicate) Right() (Predicate, bool) + func (p *InPredicate) Type() PredicateType + func (p InPredicate) String() string + type Index interface + Add func(*list.Element) + CanSourceWith func(p Predicate) (bool, int64) + Name func() string + Remove func(*list.Element) + Truncate func() + type IndexSrc struct + func NewHashIndexSource(index Index, alias string, p Predicate) (*IndexSrc, error) + func (s *IndexSrc) Columns() []string + func (s *IndexSrc) EstimateCardinal() int64 + func (s *IndexSrc) HasNext() bool + func (s *IndexSrc) Next() *list.Element + func (s IndexSrc) String() string + type IndexType int + const BTreeIndexType + const HashIndexType + type Joiner interface + Left func() string + Right func() string + SetLeft func(n Node) + SetRight func(n Node) + type Joiners []Joiner + func (js Joiners) Len() int + func (js Joiners) Less(i, j int) bool + func (js Joiners) Swap(i, j int) + type LePredicate struct + func NewLePredicate(left, right ValueFunctor) *LePredicate + func (p *LePredicate) Attribute() []string + func (p *LePredicate) Eval(cols []string, t *Tuple) (bool, error) + func (p *LePredicate) Left() (Predicate, bool) + func (p *LePredicate) Relation() string + func (p *LePredicate) Right() (Predicate, bool) + func (p *LePredicate) Type() PredicateType + func (p LePredicate) String() string + type LeqPredicate struct + func NewLeqPredicate(left, right ValueFunctor) *LeqPredicate + func (p *LeqPredicate) Attribute() []string + func (p *LeqPredicate) Eval(cols []string, t *Tuple) (bool, error) + func (p *LeqPredicate) Left() (Predicate, bool) + func (p *LeqPredicate) Relation() string + func (p *LeqPredicate) Right() (Predicate, bool) + func (p *LeqPredicate) Type() PredicateType + func (p LeqPredicate) String() string + type LimitSorter struct + func NewLimitSorter(limit int64) *LimitSorter + func (d *LimitSorter) Children() []Node + func (d *LimitSorter) EstimateCardinal() int64 + func (d *LimitSorter) Exec() ([]string, []*list.Element, error) + func (d *LimitSorter) Priority() int + func (d *LimitSorter) SetNode(n Node) + func (s LimitSorter) String() string + type ListNode struct + func NewListNode(values ...any) *ListNode + func (ln *ListNode) Children() []Node + func (ln *ListNode) EstimateCardinal() int64 + func (ln *ListNode) Exec() ([]string, []*list.Element, error) + func (ln ListNode) String() string + type MaxSelector struct + type NaturalJoin struct + func NewNaturalJoin(leftRel, leftAttr, rightRel, rightAttr string) *NaturalJoin + func (j *NaturalJoin) Children() []Node + func (j *NaturalJoin) EstimateCardinal() int64 + func (j *NaturalJoin) Exec() ([]string, []*list.Element, error) + func (j *NaturalJoin) Left() string + func (j *NaturalJoin) Right() string + func (j *NaturalJoin) SetLeft(n Node) + func (j *NaturalJoin) SetRight(n Node) + func (j NaturalJoin) String() string + type NeqPredicate struct + func NewNeqPredicate(left, right ValueFunctor) *NeqPredicate + func (p *NeqPredicate) Attribute() []string + func (p *NeqPredicate) Eval(cols []string, t *Tuple) (bool, error) + func (p *NeqPredicate) Left() (Predicate, bool) + func (p *NeqPredicate) Relation() string + func (p *NeqPredicate) Right() (Predicate, bool) + func (p *NeqPredicate) Type() PredicateType + func (p NeqPredicate) String() string + type Node interface + Children func() []Node + EstimateCardinal func() int64 + Exec func() ([]string, []*list.Element, error) + type NotPredicate struct + func NewNotPredicate(src Predicate) *NotPredicate + func (p *NotPredicate) Attribute() []string + func (p *NotPredicate) Eval(cols []string, t *Tuple) (bool, error) + func (p *NotPredicate) Left() (Predicate, bool) + func (p *NotPredicate) Relation() string + func (p *NotPredicate) Right() (Predicate, bool) + func (p *NotPredicate) Type() PredicateType + func (p NotPredicate) String() string + type NowValueFunctor struct + func (f *NowValueFunctor) Attribute() []string + func (f *NowValueFunctor) Relation() string + func (f *NowValueFunctor) Value([]string, *Tuple) any + func (f NowValueFunctor) String() string + type OffsetSorter struct + func NewOffsetSorter(o int) *OffsetSorter + func (s *OffsetSorter) Children() []Node + func (s *OffsetSorter) EstimateCardinal() int64 + func (s *OffsetSorter) Exec() ([]string, []*list.Element, error) + func (s *OffsetSorter) Priority() int + func (s *OffsetSorter) SetNode(n Node) + func (s OffsetSorter) String() string + type OrPredicate struct + func NewOrPredicate(left, right Predicate) *OrPredicate + func (p *OrPredicate) Attribute() []string + func (p *OrPredicate) Eval(cols []string, t *Tuple) (bool, error) + func (p *OrPredicate) Left() (Predicate, bool) + func (p *OrPredicate) Relation() string + func (p *OrPredicate) Right() (Predicate, bool) + func (p *OrPredicate) Type() PredicateType + func (p OrPredicate) String() string + type OrderBySorter struct + func NewOrderBySorter(rel string, attrs []SortExpression) *OrderBySorter + func (s *OrderBySorter) Children() []Node + func (s *OrderBySorter) EstimateCardinal() int64 + func (s *OrderBySorter) Exec() ([]string, []*list.Element, error) + func (s *OrderBySorter) Priority() int + func (s *OrderBySorter) SetNode(n Node) + func (s OrderBySorter) String() string + type Picker interface + Attribute func() []string + Relation func() string + type Predicate interface + Eval func([]string, *Tuple) (bool, error) + Left func() (Predicate, bool) + Right func() (Predicate, bool) + Type func() PredicateType + func NewComparisonPredicate(left ValueFunctor, t PredicateType, right ValueFunctor) (Predicate, error) + type PredicateType int + const And + const Eq + const False + const Ge + const Geq + const In + const Le + const Leq + const Like + const Neq + const Not + const Or + const True + type Relation struct + func NewRelation(schema, name string, attributes []Attribute, pk []string) (*Relation, error) + func (r *Relation) Attribute(name string) (int, Attribute, error) + func (r *Relation) Truncate() int64 + func (r Relation) String() string + type RelationChange struct + type RelationScanner struct + func NewRelationScanner(src Source, predicates []Predicate) *RelationScanner + func (s *RelationScanner) Append(p Predicate) + func (s *RelationScanner) Children() []Node + func (s *RelationScanner) EstimateCardinal() int64 + func (s *RelationScanner) Exec() ([]string, []*list.Element, error) + func (s RelationScanner) String() string + type Scanner interface + Append func(Predicate) + type Schema struct + func NewSchema(name string) *Schema + func (s *Schema) Add(name string, r *Relation) + func (s *Schema) Relation(name string) (*Relation, error) + func (s *Schema) Remove(name string) (*Relation, error) + type SchemaChange struct + type Selector interface + Alias func() string + Select func([]string, []*list.Element) ([]*Tuple, error) + type SelectorNode struct + func NewSelectorNode(selectors []Selector, n Node) *SelectorNode + func (sn *SelectorNode) Children() []Node + func (sn *SelectorNode) Columns() []string + func (sn *SelectorNode) EstimateCardinal() int64 + func (sn *SelectorNode) Exec() ([]string, []*list.Element, error) + func (sn SelectorNode) String() string + type SeqScanSrc struct + func NewSeqScan(r *Relation, alias string) *SeqScanSrc + func (s *SeqScanSrc) Columns() []string + func (s *SeqScanSrc) EstimateCardinal() int64 + func (s *SeqScanSrc) HasNext() bool + func (s *SeqScanSrc) Next() *list.Element + func (s SeqScanSrc) String() string + type SortExpression struct + func NewSortExpression(attr string, direction SortType) SortExpression + type SortType int + const ASC + const DESC + type Sorter interface + Priority func() int + SetNode func(Node) + type Sorters []Sorter + func (js Sorters) Len() int + func (js Sorters) Less(i, j int) bool + func (js Sorters) Swap(i, j int) + type Source interface + Columns func() []string + EstimateCardinal func() int64 + HasNext func() bool + Next func() *list.Element + type StarSelector struct + func NewStarSelector(rname string) *StarSelector + func (s *StarSelector) Alias() string + func (s *StarSelector) Attribute() []string + func (s *StarSelector) Relation() string + func (s *StarSelector) Select(cols []string, in []*list.Element) (out []*Tuple, err error) + func (s StarSelector) String() string + type SubqueryNode struct + func NewSubqueryNode(src Node) *SubqueryNode + func (sn *SubqueryNode) Children() []Node + func (sn *SubqueryNode) EstimateCardinal() int64 + func (sn *SubqueryNode) Exec() ([]string, []*list.Element, error) + func (sn SubqueryNode) String() string + type Transaction struct + func NewTransaction(e *Engine) (*Transaction, error) + func (t *Transaction) CheckRelation(schemaName, relName string) bool + func (t *Transaction) CheckSchema(schemaName string) bool + func (t *Transaction) Commit() (int, error) + func (t *Transaction) CreateIndex(schema, relation, index string, it IndexType, attrs []string) error + func (t *Transaction) CreateRelation(schemaName, relName string, attributes []Attribute, pk []string) error + func (t *Transaction) CreateSchema(schemaName string) error + func (t *Transaction) Delete(schema, relation string, selectors []Selector, p Predicate) ([]string, []*Tuple, error) + func (t *Transaction) DropRelation(schemaName, relName string) error + func (t *Transaction) DropSchema(schemaName string) error + func (t *Transaction) Insert(schema, relation string, values map[string]any) (*Tuple, error) + func (t *Transaction) Plan(schema string, selectors []Selector, p Predicate, joiners []Joiner, ...) (Node, error) + func (t *Transaction) Query(schema string, selectors []Selector, p Predicate, joiners []Joiner, ...) ([]string, []*Tuple, error) + func (t *Transaction) RelationAttribute(schName, relName, attrName string) (int, Attribute, error) + func (t *Transaction) Rollback() + func (t *Transaction) Truncate(schema, relation string) (int64, error) + func (t *Transaction) Update(schema, relation string, values map[string]any, selectors []Selector, ...) ([]string, []*Tuple, error) + func (t Transaction) Error() error + type TruePredicate struct + func NewTruePredicate() *TruePredicate + func (p *TruePredicate) Attribute() []string + func (p *TruePredicate) Eval([]string, *Tuple) (bool, error) + func (p *TruePredicate) Left() (Predicate, bool) + func (p *TruePredicate) Relation() string + func (p *TruePredicate) Right() (Predicate, bool) + func (p *TruePredicate) Type() PredicateType + func (p TruePredicate) String() string + type Tuple struct + func NewTuple(values ...any) *Tuple + func (t *Tuple) Append(values ...any) + func (t *Tuple) Values() []any + type Updater struct + func NewUpdaterNode(relation *Relation, changes *list.List, values map[string]any) *Updater + func (u *Updater) Attribute() []string + func (u *Updater) Children() []Node + func (u *Updater) EstimateCardinal() int64 + func (u *Updater) Exec() (cols []string, out []*list.Element, err error) + func (u *Updater) Relation() string + func (u Updater) String() string + type ValueChange struct + type ValueFunctor interface + Value func(columns []string, tuple *Tuple) any + func NewAttributeValueFunctor(rname, aname string) ValueFunctor + func NewConstValueFunctor(v any) ValueFunctor + func NewNowValueFunctor() ValueFunctor