physical

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2019 License: MIT Imports: 10 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate

type Aggregate string
const (
	Avg           Aggregate = "avg"
	AvgDistinct   Aggregate = "avg_distinct"
	Count         Aggregate = "count"
	CountDistinct Aggregate = "count_distinct"
	First         Aggregate = "first"
	Last          Aggregate = "last"
	Max           Aggregate = "max"
	Min           Aggregate = "min"
	Sum           Aggregate = "sum"
	SumDistinct   Aggregate = "sum_distinct"
)

func NewAggregate

func NewAggregate(aggregate string) Aggregate

type AliasedExpression

type AliasedExpression struct {
	Name octosql.VariableName
	Expr Expression
}

AliasedExpression describes an expression which is explicitly named.

func NewAliasedExpression

func NewAliasedExpression(name octosql.VariableName, expr Expression) *AliasedExpression

func (*AliasedExpression) Materialize

func (alExpr *AliasedExpression) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Expression, error)

func (*AliasedExpression) MaterializeNamed

func (alExpr *AliasedExpression) MaterializeNamed(ctx context.Context, matCtx *MaterializationContext) (execution.NamedExpression, error)

func (*AliasedExpression) Transform

func (alExpr *AliasedExpression) Transform(ctx context.Context, transformers *Transformers) Expression

func (*AliasedExpression) TransformNamed

func (alExpr *AliasedExpression) TransformNamed(ctx context.Context, transformers *Transformers) NamedExpression

type And

type And struct {
	Left, Right Formula
}

func NewAnd

func NewAnd(left Formula, right Formula) *And

func (*And) ExtractPredicates

func (f *And) ExtractPredicates() []*Predicate

func (*And) Materialize

func (f *And) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Formula, error)

func (*And) SplitByAnd

func (f *And) SplitByAnd() []Formula

func (*And) Transform

func (f *And) Transform(ctx context.Context, transformers *Transformers) Formula

type Constant

type Constant struct {
	Value bool
}

func NewConstant

func NewConstant(value bool) *Constant

func (*Constant) ExtractPredicates

func (f *Constant) ExtractPredicates() []*Predicate

func (*Constant) Materialize

func (f *Constant) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Formula, error)

func (*Constant) SplitByAnd

func (f *Constant) SplitByAnd() []Formula

func (*Constant) Transform

func (f *Constant) Transform(ctx context.Context, transformers *Transformers) Formula

type DataSourceBuilder

type DataSourceBuilder struct {
	Materializer     func(ctx context.Context, matCtx *MaterializationContext, dbConfig map[string]interface{}, filter Formula, alias string) (execution.Node, error)
	PrimaryKeys      []octosql.VariableName
	AvailableFilters map[FieldType]map[Relation]struct{}
	Filter           Formula
	Name             string
	Alias            string
}

DataSourceBuilder is used to build a data source instance with an alias. It may be given filters, which are later executed at the database level.

func (*DataSourceBuilder) Materialize

func (dsb *DataSourceBuilder) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)

func (*DataSourceBuilder) Transform

func (dsb *DataSourceBuilder) Transform(ctx context.Context, transformers *Transformers) Node

type DataSourceBuilderFactory

type DataSourceBuilderFactory func(name, alias string) *DataSourceBuilder

DataSourceBuilderFactory is a function used to create a new aliased data source builder.

func NewDataSourceBuilderFactory

func NewDataSourceBuilderFactory(materializer func(ctx context.Context, matCtx *MaterializationContext, dbConfig map[string]interface{}, filter Formula, alias string) (execution.Node, error), primaryKeys []octosql.VariableName, availableFilters map[FieldType]map[Relation]struct{}) DataSourceBuilderFactory

type DataSourceRepository

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

DataSourceRepository is used to register factories for builders for any data source. It can also later create a builder for any of those data source.

func CreateDataSourceRepositoryFromConfig added in v0.1.1

func CreateDataSourceRepositoryFromConfig(factories map[string]Factory, config *config.Config) (*DataSourceRepository, error)

CreateDataSourceRepositoryFromConfig creates a DataSourceRepository from a config, using the given configuration reading data source factories. The map should be given as databaseType -> Factory.

func NewDataSourceRepository

func NewDataSourceRepository() *DataSourceRepository

func (*DataSourceRepository) Get

func (repo *DataSourceRepository) Get(dataSourceName, alias string) (*DataSourceBuilder, error)

Get gets a new builder for a given data source.

func (*DataSourceRepository) Register

func (repo *DataSourceRepository) Register(dataSourceName string, factory DataSourceBuilderFactory) error

Register registers a builder factory for the given data source ColumnName.

type Distinct

type Distinct struct {
	Child Node
}

func NewDistinct

func NewDistinct(child Node) *Distinct

func (*Distinct) Materialize

func (node *Distinct) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)

func (*Distinct) Transform

func (node *Distinct) Transform(ctx context.Context, transformers *Transformers) Node

type Expression

type Expression interface {
	// Transform returns a new Expression after recursively calling Transform
	Transform(ctx context.Context, transformers *Transformers) Expression
	Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Expression, error)
}

Expressions describes a single value source.

type Factory added in v0.1.1

type Factory func(dbConfig map[string]interface{}) (DataSourceBuilderFactory, error)

type FieldType

type FieldType string

FieldType describes if a key is a primary or secondary attribute.

const (
	Primary   FieldType = "primary"
	Secondary FieldType = "secondary"
)

type Filter

type Filter struct {
	Formula Formula
	Source  Node
}

func NewFilter

func NewFilter(formula Formula, child Node) *Filter

func (*Filter) Materialize

func (node *Filter) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)

func (*Filter) Transform

func (node *Filter) Transform(ctx context.Context, transformers *Transformers) Node

type Formula

type Formula interface {
	// Transform returns a new Formula after recursively calling Transform
	Transform(ctx context.Context, transformers *Transformers) Formula
	SplitByAnd() []Formula
	ExtractPredicates() []*Predicate
	Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Formula, error)
}

Formula describes any source of a logical value.

type FunctionExpression

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

func NewFunctionExpression

func NewFunctionExpression(name string, args []Expression) *FunctionExpression

func (*FunctionExpression) Materialize

func (*FunctionExpression) Transform

func (fe *FunctionExpression) Transform(ctx context.Context, transformers *Transformers) Expression

type GroupBy

type GroupBy struct {
	Source Node
	Key    []Expression

	Fields     []octosql.VariableName
	Aggregates []Aggregate

	As []octosql.VariableName
}

func NewGroupBy

func NewGroupBy(source Node, key []Expression, fields []octosql.VariableName, aggregates []Aggregate, as []octosql.VariableName) *GroupBy

func (*GroupBy) Materialize

func (node *GroupBy) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)

func (*GroupBy) Transform

func (node *GroupBy) Transform(ctx context.Context, transformers *Transformers) Node

type InnerJoin

type InnerJoin struct {
	Source Node
	Joined Node
}

func NewInnerJoin

func NewInnerJoin(source Node, joined Node) *InnerJoin

func (*InnerJoin) Materialize

func (node *InnerJoin) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)

func (*InnerJoin) Transform

func (node *InnerJoin) Transform(ctx context.Context, transformers *Transformers) Node

type LeftJoin

type LeftJoin struct {
	Source Node
	Joined Node
}

func NewLeftJoin

func NewLeftJoin(source Node, joined Node) *LeftJoin

func (*LeftJoin) Materialize

func (node *LeftJoin) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)

func (*LeftJoin) Transform

func (node *LeftJoin) Transform(ctx context.Context, transformers *Transformers) Node

type Limit

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

func NewLimit

func NewLimit(data Node, expr Expression) *Limit

func (*Limit) Materialize

func (node *Limit) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)

func (*Limit) Transform

func (node *Limit) Transform(ctx context.Context, transformers *Transformers) Node

type LogicExpression

type LogicExpression struct {
	Formula Formula
}

LogicExpressions describes a boolean expression which get's it's value from the logic formula underneath.

func NewLogicExpression

func NewLogicExpression(formula Formula) *LogicExpression

func (*LogicExpression) Materialize

func (*LogicExpression) Transform

func (le *LogicExpression) Transform(ctx context.Context, transformers *Transformers) Expression

type Map

type Map struct {
	Expressions []NamedExpression
	Source      Node
	Keep        bool
}

func NewMap

func NewMap(expressions []NamedExpression, child Node, keep bool) *Map

func (*Map) Materialize

func (node *Map) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)

func (*Map) Transform

func (node *Map) Transform(ctx context.Context, transformers *Transformers) Node

type MaterializationContext added in v0.1.1

type MaterializationContext struct {
	Config *config.Config
}

MaterializationContext is a structure containing the configuration for the materialization.

func NewMaterializationContext added in v0.1.1

func NewMaterializationContext(config *config.Config) *MaterializationContext

type NamedExpression

type NamedExpression interface {
	Expression
	// TransformNamed returns a new NamedExpression after recursively calling Transform
	TransformNamed(ctx context.Context, transformers *Transformers) NamedExpression
	MaterializeNamed(ctx context.Context, matCtx *MaterializationContext) (execution.NamedExpression, error)
}

NamedExpressions describes a single named value source.

type Node

type Node interface {
	// Transform returns a new Node after recursively calling Transform
	Transform(ctx context.Context, transformers *Transformers) Node
	Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)
}

Node describes a single record stream source.

type NodeExpression

type NodeExpression struct {
	Node Node
}

NodeExpressions describes an expression which gets it's value from a node underneath.

func NewNodeExpression

func NewNodeExpression(node Node) *NodeExpression

func (*NodeExpression) Materialize

func (*NodeExpression) Transform

func (ne *NodeExpression) Transform(ctx context.Context, transformers *Transformers) Expression

type Not

type Not struct {
	Child Formula
}

func NewNot

func NewNot(child Formula) *Not

func (*Not) ExtractPredicates

func (f *Not) ExtractPredicates() []*Predicate

func (*Not) Materialize

func (f *Not) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Formula, error)

func (*Not) SplitByAnd

func (f *Not) SplitByAnd() []Formula

func (*Not) Transform

func (f *Not) Transform(ctx context.Context, transformers *Transformers) Formula

type Offset

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

func NewOffset

func NewOffset(data Node, expr Expression) *Offset

func (*Offset) Materialize

func (node *Offset) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)

func (*Offset) Transform

func (node *Offset) Transform(ctx context.Context, transformers *Transformers) Node

type Or

type Or struct {
	Left, Right Formula
}

func NewOr

func NewOr(left Formula, right Formula) *Or

func (*Or) ExtractPredicates

func (f *Or) ExtractPredicates() []*Predicate

func (*Or) Materialize

func (f *Or) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Formula, error)

func (*Or) SplitByAnd

func (f *Or) SplitByAnd() []Formula

func (*Or) Transform

func (f *Or) Transform(ctx context.Context, transformers *Transformers) Formula

type OrderBy

type OrderBy struct {
	Expressions []Expression
	Directions  []OrderDirection
	Source      Node
}

func NewOrderBy

func NewOrderBy(expressions []Expression, directions []OrderDirection, source Node) *OrderBy

func (*OrderBy) Materialize

func (node *OrderBy) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)

func (*OrderBy) Transform

func (node *OrderBy) Transform(ctx context.Context, transformers *Transformers) Node

type OrderDirection

type OrderDirection string
const (
	Ascending  OrderDirection = "asc"
	Descending OrderDirection = "desc"
)

type Predicate

type Predicate struct {
	Left     Expression
	Relation Relation
	Right    Expression
}

func NewPredicate

func NewPredicate(left Expression, relation Relation, right Expression) *Predicate

func (*Predicate) ExtractPredicates

func (f *Predicate) ExtractPredicates() []*Predicate

func (*Predicate) Materialize

func (f *Predicate) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Formula, error)

func (*Predicate) SplitByAnd

func (f *Predicate) SplitByAnd() []Formula

func (*Predicate) Transform

func (f *Predicate) Transform(ctx context.Context, transformers *Transformers) Formula

type Relation

type Relation string

Relation describes a comparison operator.

const (
	Equal        Relation = "equal"
	NotEqual     Relation = "not_equal"
	MoreThan     Relation = "more_than"
	LessThan     Relation = "less_than"
	Like         Relation = "like"
	In           Relation = "in"
	NotIn        Relation = "not_in"
	GreaterEqual Relation = "greater_equal"
	LessEqual    Relation = "less_equal"
)

func NewRelation

func NewRelation(relation string) Relation

func (Relation) Materialize

func (rel Relation) Materialize(ctx context.Context, matCtx *MaterializationContext) execution.Relation

type Requalifier

type Requalifier struct {
	Qualifier string
	Source    Node
}

func NewRequalifier

func NewRequalifier(qualifier string, child Node) *Requalifier

func (*Requalifier) Materialize

func (node *Requalifier) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)

func (*Requalifier) Transform

func (node *Requalifier) Transform(ctx context.Context, transformers *Transformers) Node

type Transformers

type Transformers struct {
	NodeT      func(Node) Node
	ExprT      func(Expression) Expression
	NamedExprT func(NamedExpression) NamedExpression
	FormulaT   func(Formula) Formula
}

Transformers is a structure containing functions to transform each of the physical plan components.

type Tuple

type Tuple struct {
	Expressions []Expression
}

TupleExpression describes an expression which is a tuple of subexpressions.

func NewTuple

func NewTuple(expressions []Expression) *Tuple

func (*Tuple) Materialize

func (tup *Tuple) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Expression, error)

func (*Tuple) Transform

func (tup *Tuple) Transform(ctx context.Context, transformers *Transformers) Expression

type UnionAll

type UnionAll struct {
	First, Second Node
}

func NewUnionAll

func NewUnionAll(first, second Node) *UnionAll

func (*UnionAll) Materialize

func (node *UnionAll) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Node, error)

func (*UnionAll) Transform

func (node *UnionAll) Transform(ctx context.Context, transformers *Transformers) Node

type Variable

type Variable struct {
	Name octosql.VariableName
}

Variables describes a variable Name.

func NewVariable

func NewVariable(name octosql.VariableName) *Variable

func (*Variable) Materialize

func (v *Variable) Materialize(ctx context.Context, matCtx *MaterializationContext) (execution.Expression, error)

func (*Variable) MaterializeNamed

func (v *Variable) MaterializeNamed(ctx context.Context, matCtx *MaterializationContext) (execution.NamedExpression, error)

func (*Variable) Transform

func (v *Variable) Transform(ctx context.Context, transformers *Transformers) Expression

func (*Variable) TransformNamed

func (v *Variable) TransformNamed(ctx context.Context, transformers *Transformers) NamedExpression

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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