Documentation ¶
Overview ¶
Package plandef defines the output of the query planner. It defines all of Akutan's physical execution plan operators.
Index ¶
- Variables
- type AggregateExpr
- type Ask
- type Binding
- type DistinctOp
- type DontCare
- type Enumerate
- type ExprBinding
- type Expression
- type ExternalIDs
- type FixedTerm
- type FreeTerm
- type HashJoin
- type InferPO
- type InferSP
- type InferSPO
- type LimitAndOffsetOp
- type LimitOffset
- type Literal
- type LookupPO
- type LookupPOCmp
- type LookupS
- type LookupSP
- type LookupSPO
- type LoopJoin
- type OID
- type Operator
- type OrderByOp
- type OrderCondition
- type Plan
- type Projection
- type SelectClause
- type SelectLit
- type SelectVar
- type SortDirection
- type Term
- type VarSet
- func (set VarSet) Contains(v *Variable) bool
- func (set VarSet) ContainsSet(other VarSet) bool
- func (set VarSet) Equal(other VarSet) bool
- func (set VarSet) Intersect(other VarSet) VarSet
- func (set VarSet) Key(b *strings.Builder)
- func (set VarSet) String() string
- func (set VarSet) Sub(other VarSet) VarSet
- func (set VarSet) Union(other VarSet) VarSet
- type Variable
- type WildcardExpr
Examples ¶
Constants ¶
This section is empty.
Variables ¶
ImplementFixedTerm is a list of types that implement FixedTerm. This serves as documentation and as a compile-time check.
ImplementFreeTerm is a list of types that implement FreeTerm. This serves as documentation and as a compile-time check.
var ImplementOperator = []Operator{ new(HashJoin), new(LoopJoin), new(InferPO), new(InferSP), new(InferSPO), new(LookupPO), new(LookupPOCmp), new(LookupS), new(LookupSP), new(LookupSPO), new(SelectLit), new(SelectVar), new(Enumerate), new(ExternalIDs), new(Projection), new(OrderByOp), new(LimitAndOffsetOp), new(DistinctOp), }
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) 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.
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.
type DistinctOp ¶
type DistinctOp struct { }
DistinctOp is an operator that will remove the duplicate rows from the results.
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.
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.
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) String ¶
func (b *ExprBinding) String() string
type Expression ¶
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) 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.
type InferPO ¶
InferPO is an Operator that starts at the given object and transitively follows predicate edges backwards to yield all reachable subjects.
type InferSP ¶
InferSP is an Operator that finds all transitive paths from a subject using the given predicate edges.
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.
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) 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.
type LookupPO ¶
LookupPO is an Operator that finds static facts with the given predicate and object.
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) 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 LookupSP ¶
LookupSP is an Operator that finds static facts with the given subject and predicate.
type LookupSPO ¶
LookupSPO is an Operator that finds the(?) static fact with the given subject, predicate, and object.
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.
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.
type OrderByOp ¶
type OrderByOp struct {
OrderBy []OrderCondition
}
OrderByOp is an operator that will order the results based on the order condition.
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.
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) 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.
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.
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 ¶
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 ¶
NewVarSet creates a new VarSet from the given variables. The key to 'in' should be the variable's Name.
func (VarSet) ContainsSet ¶
ContainsSet return true if all variables in 'other' are in 'set', false otherwise.
func (VarSet) Equal ¶
Equal returns true if the two sets are made up of the same variable names, false otherwise.
func (VarSet) Intersect ¶
Intersect returns a new set with the variables present in both 'set' and 'other'.
type Variable ¶
type Variable struct {
Name string
}
A Variable is a FreeTerm representing a placeholder for a named result.
type WildcardExpr ¶
type WildcardExpr struct { }
WildcardExpr represents a * Expression used in an aggregate expression.
func (WildcardExpr) String ¶
func (w WildcardExpr) String() string