plandef

package
v0.0.0-...-6719cd2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package plandef defines the output of the query planner. It defines all of Akutan's physical execution plan operators.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ImplementFixedTerm = []FixedTerm{
	new(Binding),
	new(Literal),
	new(OID),
}

ImplementFixedTerm is a list of types that implement FixedTerm. This serves as documentation and as a compile-time check.

View Source
var ImplementFreeTerm = []FreeTerm{
	new(DontCare),
	new(Variable),
}

ImplementFreeTerm is a list of types that implement FreeTerm. This serves as documentation and as a compile-time check.

ImplementOperator is a list of types that implement Operator. This serves as documentation and as a compile-time check.

Functions

This section is empty.

Types

type AggregateExpr

type AggregateExpr struct {
	Func parser.AggregateFunction
	Of   Expression
}

AggregateExpr is an Expression that is an aggregate calculation

func (*AggregateExpr) Key

func (a *AggregateExpr) Key(k *strings.Builder)

Key implements cmp.Key

func (*AggregateExpr) String

func (a *AggregateExpr) String() string

type Ask

type Ask struct {
	Out *Variable
}

Ask is an operator which generates a boolean output indicating if it received any rows from its input.

func (*Ask) Key

func (a *Ask) Key(k *strings.Builder)

Key implements cmp.Key

func (*Ask) String

func (a *Ask) String() string

type Binding

type Binding struct {
	Var *Variable
}

A Binding is a variable that will be filled in by values from an outer nested loop join. Unlike a Variable, Binding is a FixedTerm.

func (*Binding) Key

func (b *Binding) Key(buf *strings.Builder)

Key implements cmp.Key.

func (*Binding) String

func (b *Binding) String() string

String returns a string like "$foo".

type DistinctOp

type DistinctOp struct {
}

DistinctOp is an operator that will remove the duplicate rows from the results.

func (*DistinctOp) Key

func (d *DistinctOp) Key(k *strings.Builder)

Key implements cmp.Key

func (*DistinctOp) String

func (d *DistinctOp) String() string

type DontCare

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

DontCare is a FreeTerm representing a placeholder for a result to be discarded.

func (*DontCare) Key

func (d *DontCare) Key(b *strings.Builder)

Key implements cmp.Key.

func (*DontCare) String

func (d *DontCare) String() string

String returns "_".

type Enumerate

type Enumerate struct {
	// Output is a Variable or Binding that the values are associated with in
	// the results
	Output Term
	// Only Literals or OIDs are allowed in the list (Bindings).
	Values []FixedTerm
}

An Enumerate Operator emits a literal set of values.

func (*Enumerate) Key

func (op *Enumerate) Key(b *strings.Builder)

Key implements cmp.Key.

func (*Enumerate) String

func (op *Enumerate) String() string

String returns a string like "Enumerate ?foo {a, b, c}". If the set of values is too large, it returns something like "Enumerate ?foo {a, b, c, ...}" instead.

type ExprBinding

type ExprBinding struct {
	Expr Expression
	Out  *Variable
}

ExprBinding is a column in the Projection, it evaluates an expression and binds the result to a variable

func (*ExprBinding) Key

func (b *ExprBinding) Key(k *strings.Builder)

Key implements cmp.Key

func (*ExprBinding) String

func (b *ExprBinding) String() string

type Expression

type Expression interface {
	String() string
	cmp.Key
	// contains filtered or unexported methods
}

Expression represents an abstract calculable expression

type ExternalIDs

type ExternalIDs struct {
}

ExternalIDs is an operator that will fetch and add externalIDs to variable values. It takes a single input.

func (*ExternalIDs) Key

func (e *ExternalIDs) Key(k *strings.Builder)

Key implements cmp.Key

func (*ExternalIDs) String

func (e *ExternalIDs) String() string

type FixedTerm

type FixedTerm interface {
	Term
	// contains filtered or unexported methods
}

A FixedTerm is a Term that has a known value before the operator executes.

type FreeTerm

type FreeTerm interface {
	Term
	// contains filtered or unexported methods
}

A FreeTerm is a Term that has an unknown value when the operator executes. It represents a result from the operator.

type HashJoin

type HashJoin struct {
	// The variables that are compared for equality in both inputs.
	Variables   VarSet
	Specificity parser.MatchSpecificity
}

A HashJoin Operator takes two inputs and implements a join using a hash table.

func (*HashJoin) Key

func (op *HashJoin) Key(b *strings.Builder)

Key implements cmp.Key.

func (*HashJoin) String

func (op *HashJoin) String() string

type InferPO

type InferPO struct {
	ID        FreeTerm
	Subject   FreeTerm
	Predicate FixedTerm
	Object    FixedTerm
}

InferPO is an Operator that starts at the given object and transitively follows predicate edges backwards to yield all reachable subjects.

func (*InferPO) Key

func (op *InferPO) Key(b *strings.Builder)

Key implements cmp.Key.

func (*InferPO) String

func (op *InferPO) String() string

func (*InferPO) Terms

func (op *InferPO) Terms() []Term

Terms is a convenience method to fetch the ID, Subject, Predicate, Object in an iterable slice.

type InferSP

type InferSP struct {
	ID        FreeTerm
	Subject   FixedTerm
	Predicate FixedTerm
	Object    FreeTerm
}

InferSP is an Operator that finds all transitive paths from a subject using the given predicate edges.

func (*InferSP) Key

func (op *InferSP) Key(b *strings.Builder)

Key implements cmp.Key.

func (*InferSP) String

func (op *InferSP) String() string

func (*InferSP) Terms

func (op *InferSP) Terms() []Term

Terms is a convenience method to fetch the ID, Subject, Predicate, Object in an iterable slice.

type InferSPO

type InferSPO struct {
	ID        FreeTerm
	Subject   FixedTerm
	Predicate FixedTerm
	// It's a bit of an open question, but we think this may only be an OID or a
	// binding to an OID, never a literal or binding to a literal value.
	// -Diego 2018-06-21
	Object FixedTerm
}

InferSPO is an Operator that finds all transitive paths from subject to object using predicate edges.

func (*InferSPO) Key

func (op *InferSPO) Key(b *strings.Builder)

Key implements cmp.Key.

func (*InferSPO) String

func (op *InferSPO) String() string

func (*InferSPO) Terms

func (op *InferSPO) Terms() []Term

Terms is a convenience method to fetch the ID, Subject, Predicate, Object in an iterable slice.

type LimitAndOffsetOp

type LimitAndOffsetOp struct {
	Paging LimitOffset
}

LimitAndOffsetOp is an operator that will paginate the results.

func (*LimitAndOffsetOp) Key

func (lop *LimitAndOffsetOp) Key(k *strings.Builder)

Key implements cmp.Key

func (*LimitAndOffsetOp) String

func (lop *LimitAndOffsetOp) String() string

type LimitOffset

type LimitOffset struct {
	// Limit or Offset can be nil if not explicitly specified in the query.
	Limit  *uint64
	Offset *uint64
}

LimitOffset contains paging related values

func (*LimitOffset) Key

func (l *LimitOffset) Key(k *strings.Builder)

Key implements cmp.Key

func (*LimitOffset) String

func (l *LimitOffset) String() string

type Literal

type Literal struct {
	// Most KGObject types are allowed, but KID is not: that is represented as an
	// OID instead.
	Value rpc.KGObject
}

A Literal is a FixedTerm containing a literal value, like a particular float or string.

func (*Literal) Key

func (literal *Literal) Key(b *strings.Builder)

Key implements cmp.Key.

func (*Literal) String

func (literal *Literal) String() string

type LookupPO

type LookupPO struct {
	ID        FreeTerm
	Subject   FreeTerm
	Predicate FixedTerm
	Object    FixedTerm
}

LookupPO is an Operator that finds static facts with the given predicate and object.

func (*LookupPO) Key

func (op *LookupPO) Key(b *strings.Builder)

Key implements cmp.Key.

func (*LookupPO) String

func (op *LookupPO) String() string

func (*LookupPO) Terms

func (op *LookupPO) Terms() []Term

Terms is a convenience method to fetch the ID, Subject, Predicate, Object in an iterable slice.

type LookupPOCmp

type LookupPOCmp struct {
	ID        FreeTerm
	Subject   FreeTerm
	Predicate FixedTerm
	Object    *Variable
	Cmp       SelectClause
}

LookupPOCmp is an Operator that finds static facts with the given predicate and whose object is a literal value satisfying the given filter.

func (*LookupPOCmp) Key

func (op *LookupPOCmp) Key(b *strings.Builder)

Key implements cmp.Key.

func (*LookupPOCmp) String

func (op *LookupPOCmp) String() string

func (*LookupPOCmp) Terms

func (op *LookupPOCmp) Terms() []Term

Terms is a convenience method to fetch the ID, Subject, Predicate, Object in an iterable slice.

type LookupS

type LookupS struct {
	ID        FreeTerm
	Subject   FixedTerm
	Predicate FreeTerm
	Object    FreeTerm
}

LookupS is an Operator that finds static facts with the given subject.

func (*LookupS) Key

func (op *LookupS) Key(b *strings.Builder)

Key implements cmp.Key.

func (*LookupS) String

func (op *LookupS) String() string

func (*LookupS) Terms

func (op *LookupS) Terms() []Term

Terms is a convenience method to fetch the ID, Subject, Predicate, Object in an iterable slice.

type LookupSP

type LookupSP struct {
	ID        FreeTerm
	Subject   FixedTerm
	Predicate FixedTerm
	Object    FreeTerm
}

LookupSP is an Operator that finds static facts with the given subject and predicate.

func (*LookupSP) Key

func (op *LookupSP) Key(b *strings.Builder)

Key implements cmp.Key.

func (*LookupSP) String

func (op *LookupSP) String() string

func (*LookupSP) Terms

func (op *LookupSP) Terms() []Term

Terms is a convenience method to fetch the ID, Subject, Predicate, Object in an iterable slice.

type LookupSPO

type LookupSPO struct {
	ID        FreeTerm
	Subject   FixedTerm
	Predicate FixedTerm
	Object    FixedTerm
}

LookupSPO is an Operator that finds the(?) static fact with the given subject, predicate, and object.

func (*LookupSPO) Key

func (op *LookupSPO) Key(b *strings.Builder)

Key implements cmp.Key.

func (*LookupSPO) String

func (op *LookupSPO) String() string

func (*LookupSPO) Terms

func (op *LookupSPO) Terms() []Term

Terms is a convenience method to fetch the ID, Subject, Predicate, Object in an iterable slice.

type LoopJoin

type LoopJoin struct {
	// The variables that are compared for equality in both inputs.
	Variables   VarSet
	Specificity parser.MatchSpecificity
}

A LoopJoin Operator takes two inputs and implements a join using a nested loop. It passes results from the first input into queries on the second input; these will appear as Binding terms in the second input.

func (*LoopJoin) Key

func (op *LoopJoin) Key(b *strings.Builder)

Key implements cmp.Key.

func (*LoopJoin) String

func (op *LoopJoin) String() string

type OID

type OID struct {
	Value uint64
	// If not empty, this is a unique identifier for the same entity that's more
	// human-friendly, like "<foo>" or "rdfs:label".
	Hint string
}

An OID is a FixedTerm containing an opaque resource identifier.

func (*OID) Key

func (oid *OID) Key(b *strings.Builder)

Key implements cmp.Key. The key is based on oid.Value alone; the Hint does not affect it.

func (*OID) String

func (oid *OID) String() string

String returns oid.Hint if that's set; otherwise, it returns a string like "#1052".

type Operator

type Operator interface {
	String() string
	cmp.Key
	// contains filtered or unexported methods
}

Operator is a physical, executable operator.

type OrderByOp

type OrderByOp struct {
	OrderBy []OrderCondition
}

OrderByOp is an operator that will order the results based on the order condition.

func (*OrderByOp) Key

func (o *OrderByOp) Key(k *strings.Builder)

Key implements cmp.Key

func (*OrderByOp) String

func (o *OrderByOp) String() string

type OrderCondition

type OrderCondition struct {
	Direction SortDirection
	On        *Variable
}

OrderCondition describes a single expression in the order by cluase.

func (*OrderCondition) Key

func (o *OrderCondition) Key(k *strings.Builder)

Key implementes cmp.Key

func (*OrderCondition) String

func (o *OrderCondition) String() string

type Plan

type Plan struct {
	// Which operation to execute, including its scalar arguments.
	Operator Operator
	// The results that the operator takes as inputs, if any. For example, a
	// HashJoin takes two inputs, but lookups take none.
	Inputs []*Plan
	// The variables whose values are output by the plan node.
	Variables VarSet
}

A Plan is an tree of physical operators that Akutan can execute to answer a query.

func (*Plan) String

func (plan *Plan) String() string

String returns a multi-line indented human-readable string describing the execution plan.

type Projection

type Projection struct {
	// The list of expressions to project. If the query used SELECT ?someVar it
	// is converted into an ExprBinding of (?someVar AS ?someVar)
	Select []ExprBinding
	// contains the set of variables that'll be in the output.
	Variables VarSet
}

Projection is an Operator which takes input rows, evaluates them, and generates output rows. This is mapped from the SELECT keyword in the parser. For SELECT * WHERE ... queries there is no Projection in the operator tree. As the API returns all the variables in the ResultChunks, there's no need for one.

func (*Projection) Key

func (p *Projection) Key(k *strings.Builder)

Key implements the cmp.Key interface

func (*Projection) String

func (p *Projection) String() string

type SelectClause

type SelectClause struct {
	// A comparison OID such as query.OIDGreater, etc.
	Comparison rpc.Operator
	// Most comparisons take this one argument.
	Literal1 *Literal
	// The range-based comparisons need this second argument. Otherwise, it must
	// be nil.
	Literal2 *Literal
}

A SelectClause defines a filter in a Select.

func (SelectClause) Key

func (c SelectClause) Key(b *strings.Builder)

Key implements cmp.Key.

func (SelectClause) String

func (c SelectClause) String() string

type SelectLit

type SelectLit struct {
	// Which Variable to filter.
	Test *Variable
	// One or more ways to filter it.
	Clauses []SelectClause
}

A SelectLit Operator is a filter on a variable against one or more literals.

func (*SelectLit) Key

func (op *SelectLit) Key(b *strings.Builder)

Key implements cmp.Key.

func (*SelectLit) String

func (op *SelectLit) String() string

String returns a string like "SelectLit ?foo < 30".

type SelectVar

type SelectVar struct {
	// Which Variables to compare.
	Left  *Variable
	Right *Variable
	// The comparison operator.
	Operator rpc.Operator
}

A SelectVar Operator is a filter that compares the values of 2 variables.

func (*SelectVar) Key

func (op *SelectVar) Key(b *strings.Builder)

Key implements cmp.Key.

func (*SelectVar) String

func (op *SelectVar) String() string

String returns a string like "SelectVar ?src != ?dest".

type SortDirection

type SortDirection = parser.SortDirection

SortDirection is the direction that a sort should be in.

const (
	// SortAsc indicate an ascending sort, i.e. smaller values appear before
	// larger values.
	SortAsc SortDirection = parser.SortAsc
	// SortDesc indicate a descending sort, i.e. larger values appear
	// before smaller values.
	SortDesc SortDirection = parser.SortDesc
)

type Term

type Term interface {
	String() string
	cmp.Key
	// contains filtered or unexported methods
}

A Term is an argument to an Operator, such as a Variable or an OID. Every type of Term is either a FreeTerm or a FixedTerm.

type VarSet

type VarSet []*Variable

A VarSet is a set of variables. It's represented as an ordered slice of uniquely-named variables.

Example
vars := NewVarSet(map[string]*Variable{
	"person": &Variable{Name: "person"},
	"place":  &Variable{Name: "place"},
	"europe": &Variable{Name: "europe"},
})
// As it's a slice, you can for-range over a VarSet in order:
for _, v := range vars {
	fmt.Println(v)
}
Output:

?europe
?person
?place

func NewVarSet

func NewVarSet(in map[string]*Variable) VarSet

NewVarSet creates a new VarSet from the given variables. The key to 'in' should be the variable's Name.

func (VarSet) Contains

func (set VarSet) Contains(v *Variable) bool

Contains returns true if v is in the set, false otherwise.

func (VarSet) ContainsSet

func (set VarSet) ContainsSet(other VarSet) bool

ContainsSet return true if all variables in 'other' are in 'set', false otherwise.

func (VarSet) Equal

func (set VarSet) Equal(other VarSet) bool

Equal returns true if the two sets are made up of the same variable names, false otherwise.

func (VarSet) Intersect

func (set VarSet) Intersect(other VarSet) VarSet

Intersect returns a new set with the variables present in both 'set' and 'other'.

func (VarSet) Key

func (set VarSet) Key(b *strings.Builder)

Key implements cmp.Key.

func (VarSet) String

func (set VarSet) String() string

String returns a space-delimited ordered list of variable names.

func (VarSet) Sub

func (set VarSet) Sub(other VarSet) VarSet

Sub returns a new set with the variables present in 'set' but not 'other'.

func (VarSet) Union

func (set VarSet) Union(other VarSet) VarSet

Union returns a new set with the variables present in either 'set' or 'other'.

type Variable

type Variable struct {
	Name string
}

A Variable is a FreeTerm representing a placeholder for a named result.

func (*Variable) Key

func (v *Variable) Key(b *strings.Builder)

Key implements cmp.Key.

func (*Variable) String

func (v *Variable) String() string

String returns a string like "?foo".

type WildcardExpr

type WildcardExpr struct {
}

WildcardExpr represents a * Expression used in an aggregate expression.

func (WildcardExpr) Key

func (w WildcardExpr) Key(k *strings.Builder)

Key implements cmp.Key

func (WildcardExpr) String

func (w WildcardExpr) String() string

Jump to

Keyboard shortcuts

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