Documentation
¶
Overview ¶
Package plan implements the flux query planner to plan execution of a query spec.
Index ¶
- Constants
- Variables
- func Formatted(p PlanReader, opts ...FormatOption) fmt.Formatter
- func RegisterProcedureSpec(k ProcedureKind, c CreateProcedureSpec, qks ...query.OperationKind)
- func RegisterRewriteRule(r RewriteRule)
- type Administration
- type AggregateProcedureSpec
- type BoundedProcedureSpec
- type BoundsSpec
- type CreateProcedureSpec
- type FormatOption
- type LogicalPlanSpec
- type LogicalPlanner
- type Option
- type ParentAwareProcedureSpec
- type PlanReader
- type PlanRewriter
- type PlanSpec
- type Planner
- type Procedure
- type ProcedureID
- type ProcedureKind
- type ProcedureSpec
- type PushDownProcedureSpec
- type PushDownRule
- type RewriteRule
- type Shard
- type ShardMap
- type Storage
- type TimeRange
- type WindowSpec
- type YieldProcedureSpec
- type YieldSpec
Constants ¶
const DefaultYieldName = "_result"
DefaultYieldName is the yield name to use in cases where no explicit yield name was specified.
Variables ¶
var ( MinTime = values.ConvertTime(query.MinTime.Absolute) MaxTime = values.ConvertTime(query.MaxTime.Absolute) )
var EmptyBoundsSpec = &BoundsSpec{ Start: values.Time(0), Stop: values.Time(0), }
var NilUUID uuid.UUID
var RootUUID = NilUUID
Functions ¶
func Formatted ¶
func Formatted(p PlanReader, opts ...FormatOption) fmt.Formatter
func RegisterProcedureSpec ¶
func RegisterProcedureSpec(k ProcedureKind, c CreateProcedureSpec, qks ...query.OperationKind)
RegisterProcedureSpec registers a new procedure with the specified kind. The call panics if the kind is not unique.
func RegisterRewriteRule ¶
func RegisterRewriteRule(r RewriteRule)
Types ¶
type Administration ¶
type Administration interface {
ConvertID(query.OperationID) ProcedureID
}
type AggregateProcedureSpec ¶
type AggregateProcedureSpec interface {
// AggregateMethod specifies which aggregate method to push down to the storage layer.
AggregateMethod() string
// ReAggregateSpec specifies an aggregate procedure to use when aggregating the individual pushed down results.
ReAggregateSpec() ProcedureSpec
}
type BoundedProcedureSpec ¶
type BoundsSpec ¶
func ToBoundsSpec ¶
func (*BoundsSpec) Contains ¶
func (b *BoundsSpec) Contains(t values.Time) bool
Contains reports whether a given time is contained within the range a given BoundsSpec represents
func (*BoundsSpec) Intersect ¶
func (b *BoundsSpec) Intersect(o *BoundsSpec) *BoundsSpec
Intersect returns the intersection of two bounds (the range over which they overlap). If either of the bounds have zeroes, it will return a zero-valued BoundsSpec. If there is no intersection, EmptyBoundsSpec is returned. Intersect with EmptyBoundsSpec will always return EmptyBoundsSpec.
func (*BoundsSpec) IsEmpty ¶
func (b *BoundsSpec) IsEmpty() bool
IsEmpty reports whether the given bounds are empty, i.e., if start >= stop.
func (*BoundsSpec) Overlaps ¶
func (b *BoundsSpec) Overlaps(o *BoundsSpec) bool
Overlaps reports whether two given bounds have overlapping time ranges.
func (*BoundsSpec) Union ¶
func (b *BoundsSpec) Union(o *BoundsSpec) *BoundsSpec
Union returns the union of two time bounds (the smallest bounds which contain both input bounds) If either of the bounds have zeroes, Union will return a zero-valued BoundsSpec. Union with EmptyBoundsSpec always returns EmptyBoundsSpec.
type CreateProcedureSpec ¶
type CreateProcedureSpec func(query.OperationSpec, Administration) (ProcedureSpec, error)
type FormatOption ¶
type FormatOption func(*formatter)
TODO(nathanielc): Add better options for formatting plans as Graphviz dot format.
func UseIDs ¶
func UseIDs() FormatOption
type LogicalPlanSpec ¶
type LogicalPlanSpec struct {
Procedures map[ProcedureID]*Procedure
Order []ProcedureID
Resources query.ResourceManagement
Now time.Time
}
func (*LogicalPlanSpec) Do ¶
func (lp *LogicalPlanSpec) Do(f func(pr *Procedure))
type LogicalPlanner ¶
type LogicalPlanner interface {
Plan(*query.Spec) (*LogicalPlanSpec, error)
}
func NewLogicalPlanner ¶
func NewLogicalPlanner() LogicalPlanner
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is an option to configure the behavior of the planner.
func WithDefaultMemoryLimit ¶
WithDefaultMemoryLimit sets the default memory limit for plans generated by the planner. If the query spec explicitly sets a memory limit, that limit is used instead of the default.
type ParentAwareProcedureSpec ¶
type ParentAwareProcedureSpec interface {
ParentChanged(old, new ProcedureID)
}
type PlanReader ¶
type PlanReader interface {
Do(func(*Procedure))
// contains filtered or unexported methods
}
type PlanRewriter ¶
type PlanSpec ¶
type PlanSpec struct {
// Now represents the relative current time of the plan.
Now time.Time
// Procedures is a set of all operations
Procedures map[ProcedureID]*Procedure
Order []ProcedureID
// Results is a list of datasets that are the result of the plan
Results map[string]YieldSpec
Resources query.ResourceManagement
}
type Planner ¶
type Planner interface {
// Plan create a plan from the logical plan and available storage.
Plan(p *LogicalPlanSpec, s Storage) (*PlanSpec, error)
}
func NewPlanner ¶
NewPlanner constructs a new physical planner while applying the given options.
type Procedure ¶
type Procedure struct {
ID ProcedureID
Parents []ProcedureID
Children []ProcedureID
Spec ProcedureSpec
Bounds *BoundsSpec
// contains filtered or unexported fields
}
func (*Procedure) DoChildren ¶
type ProcedureID ¶
var ZeroProcedureID ProcedureID
func ProcedureIDForDuplicate ¶
func ProcedureIDForDuplicate(id ProcedureID) ProcedureID
func ProcedureIDFromOperationID ¶
func ProcedureIDFromOperationID(id query.OperationID) ProcedureID
func ProcedureIDFromParentID ¶
func ProcedureIDFromParentID(id ProcedureID) ProcedureID
func (ProcedureID) String ¶
func (id ProcedureID) String() string
type ProcedureSpec ¶
type ProcedureSpec interface {
// Kind returns the kind of the procedure.
Kind() ProcedureKind
Copy() ProcedureSpec
}
ProcedureSpec specifies an operation as part of a query.
type PushDownProcedureSpec ¶
type PushDownProcedureSpec interface {
PushDownRules() []PushDownRule
PushDown(root *Procedure, dup func() *Procedure)
}
type PushDownRule ¶
type PushDownRule struct {
Root ProcedureKind
Through []ProcedureKind
Match func(ProcedureSpec) bool
}
TODO(nathanielc): make this more formal using commute/associative properties
type RewriteRule ¶
type RewriteRule interface {
Root() ProcedureKind
Rewrite(*Procedure, PlanRewriter) error
}
type WindowSpec ¶
type YieldProcedureSpec ¶
type YieldProcedureSpec interface {
YieldName() string
}
type YieldSpec ¶
type YieldSpec struct {
ID ProcedureID
}
YieldSpec defines how data should be yielded.