rel

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 2 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 = frozen.Set[Tuple]

func CartesianProduct

func CartesianProduct(relations ...Relation) Relation

func Join

func Join(relations ...Relation) Relation

Join returns all {x, y, z} such that s has {x, y} and t has {y, z}. x, y and z represent sets of keys:

x: keys unique to maps in s
y: keys common to maps in both
z: keys unique to maps in t

It is assumed that all maps in s have the same keys and likewise for t.

func Nest

func Nest(s Relation, attrAttrs frozen.Map[string, frozen.Set[string]]) Relation

Nest returns a relation with some attributes nested as subrelations.

Example:

input:
   _c_ _a__
  |_1_|_10_|
  |_1_|_11_|
  |_2_|_13_|
  |_3_|_11_|
  |_4_|_14_|
  |_3_|_10_|
  |_4_|_13_|

nest(input, {aa: {a}}):
   _c_ ___aa___
  | 1 |  _a__  |
  |   | |_10_| |
  |___|_|_11_|_|
  | 2 |  _a__  |
  |___|_|_13_|_|
  | 3 |  _a__  |
  |   | |_10_| |
  |___|_|_11_|_|
  | 4 |  _a__  |
  |   | |_13_| |
  |___|_|_14_|_|

func New

func New(header []string, tuples ...[]any) Relation

New returns a new relation.

func Project

func Project(s Relation, attrs ...string) Relation

Project returns a Set with the result of projecting each map.

func Unnest

func Unnest(s Relation, attr string) Relation

Unnest returns a relation with some subrelations unnested. This is the reverse of Nest.

type RelationBuilder

type RelationBuilder = frozen.SetBuilder[Tuple]

type Tuple

type Tuple = frozen.Map[string, any]

func NewTuple

func NewTuple(kvs ...frozen.KeyValue[string, any]) Tuple

Jump to

Keyboard shortcuts

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