plan

package
v0.184.2 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: MIT Imports: 16 Imported by: 19

Documentation

Index

Constants

View Source
const AnyKind = "*** any procedure kind ***"
View Source
const (
	CollationKey = "collation"
)
View Source
const DefaultYieldName = "_result"

DefaultYieldName is the name of a result that doesn't have any name assigned.

View Source
const NextPlanNodeIDKey nodeIDKey = "NextPlanNodeID"
View Source
const ParallelMergeKey = "parallel-merge"
View Source
const ParallelRunKey = "parallel-run"

Variables

View Source
var DefaultTriggerSpec = AfterWatermarkTriggerSpec{}
View Source
var EmptyBounds = &Bounds{
	Start: values.Time(0),
	Stop:  values.Time(0),
}

EmptyBounds is a time range containing only a single point

Functions

func CheckRequiredAttributes added in v0.175.0

func CheckRequiredAttributes(node *PhysicalPlanNode) error

CheckRequiredAttributes will check that if the given node requires any attributes from its predecessors, then they are provided, either directly or because a predecessor passes on the attribute from one of its own predecessors. If all requirements are met, nil is returned, otherwise an error wil an appopriate diagnostic is produced.

func CheckSuccessorsMustRequire added in v0.175.0

func CheckSuccessorsMustRequire(node *PhysicalPlanNode) error

CheckSuccessorsMustRequire will return an error if the node has an output attribute that must be required by *all* successors, but there exists some node that does not require it.

E.g., the parallel-run attribute is like this in that it must be required by a merge node. This function will walk forward through successors to find the requiring node.

The desired effect here is that if an attribute must be required by successors, we walk forward through the graph and ensure that it is required on every branch that succeeds the given node, with ohly pass-through nodes in between.

func ClearRegisteredRules added in v0.67.0

func ClearRegisteredRules()

func ComputeBounds

func ComputeBounds(node Node) error

ComputeBounds computes the time bounds for a plan node from the bounds of its predecessors.

func Formatted

func Formatted(p *Spec, opts ...FormatOption) fmt.Formatter

Formatted accepts a plan.Spec and options, and returns a Formatter that can be used with the standard fmt package, e.g.,

fmt.Println(Formatted(plan, WithDetails())

func HasSideEffect added in v0.8.0

func HasSideEffect(spec ProcedureSpec) bool

func IndexOfNode added in v0.178.0

func IndexOfNode(node Node, nodes []Node) int

IndexOfNode is a utility function that will return the offset of the given node in the slice of nodes. This is useful to determine whether a node is the 1st or 2nd predecessor of some other node for example. Returns -1 if node not found.

func RegisterLogicalRules

func RegisterLogicalRules(rules ...Rule)

RegisterLogicalRules registers the rule created by createFn with the logical plan.

func RegisterParallelizeRules added in v0.156.0

func RegisterParallelizeRules(rules ...Rule)

RegisterParallelizationRule registers the rule created by createFn with the physical plan.

func RegisterPhysicalRules

func RegisterPhysicalRules(rules ...Rule)

RegisterPhysicalRules registers the rule created by createFn with the physical plan.

func RegisterProcedureSpec

func RegisterProcedureSpec(k ProcedureKind, c CreateProcedureSpec, qks ...flux.OperationKind)

RegisterProcedureSpec registers a new procedure with the specified kind. The call panics if the kind is not unique.

func RegisterProcedureSpecWithSideEffect

func RegisterProcedureSpecWithSideEffect(k ProcedureKind, c CreateProcedureSpec, qks ...flux.OperationKind)

RegisterProcedureSpecWithSideEffect registers a new procedure that produces side effects

func ReplaceNode added in v0.10.0

func ReplaceNode(oldNode, newNode Node)

ReplaceNode accepts two nodes and attaches all the predecessors of the old node to the new node.

S1   S2        S1   S2
  \ /
oldNode   =>   newNode
  / \            / \
P1   P2        P1   P2

As is convention, newNode will not have any successors attached. The planner will take care of this.

func SetTriggerSpec added in v0.22.0

func SetTriggerSpec(node Node) error

func ValidatePhysicalPlan added in v0.157.0

func ValidatePhysicalPlan(plan *Spec) error

func WalkPredecessors added in v0.10.0

func WalkPredecessors(roots []Node, visitFn func(node Node) error) error

WalkPredecessor visits every node in the plan rooted at `roots` in topological order, following predecessor links. If a cycle is detected, no node is visited and an error is returned.

func WalkSuccessors added in v0.10.0

func WalkSuccessors(roots []Node, visitFn func(node Node) error) error

WalkSuccessors visits every node in the plan rooted at `roots` in topological order, following successor links. If a cycle is detected, no node is visited and an error is returned.

Types

type Administration

type Administration interface {
	Now() time.Time
}

type AfterAtLeastCountTriggerSpec added in v0.22.0

type AfterAtLeastCountTriggerSpec struct {
	Count int
}

func (AfterAtLeastCountTriggerSpec) Kind added in v0.22.0

type AfterProcessingTimeTriggerSpec added in v0.22.0

type AfterProcessingTimeTriggerSpec struct {
	Duration flux.Duration
}

func (AfterProcessingTimeTriggerSpec) Kind added in v0.22.0

type AfterWatermarkTriggerSpec added in v0.22.0

type AfterWatermarkTriggerSpec struct {
	AllowedLateness flux.Duration
}

func (AfterWatermarkTriggerSpec) Kind added in v0.22.0

type Bounds

type Bounds struct {
	Start values.Time
	Stop  values.Time
}

Bounds is a range of time

func FromFluxBounds added in v0.153.0

func FromFluxBounds(bounds flux.Bounds) Bounds

func (*Bounds) Contains

func (b *Bounds) Contains(t values.Time) bool

Contains reports whether a given time is contained within the time range

func (*Bounds) Intersect

func (b *Bounds) Intersect(o *Bounds) *Bounds

Intersect returns the intersection of two bounds. It returns empty bounds if one of the input bounds are empty.

func (*Bounds) IsEmpty

func (b *Bounds) IsEmpty() bool

IsEmpty reports whether the given bounds contain at most a single point

func (*Bounds) Overlaps

func (b *Bounds) Overlaps(o *Bounds) bool

Overlaps reports whether two given bounds have overlapping time ranges

func (*Bounds) Shift

func (b *Bounds) Shift(d values.Duration) *Bounds

Shift moves the start and stop values of a time range by a specified duration

func (*Bounds) Union

func (b *Bounds) Union(o *Bounds) *Bounds

Union returns the smallest bounds which contain both input bounds. It returns empty bounds if one of the input bounds are empty.

type BoundsAwareProcedureSpec

type BoundsAwareProcedureSpec interface {
	TimeBounds(predecessorBounds *Bounds) *Bounds
}

BoundsAwareProcedureSpec is any procedure that modifies the time bounds of its data.

type CollationAttr added in v0.175.0

type CollationAttr struct {
	Columns []string
	Desc    bool
}

CollationAttr is a physical attribute that describes the collation of the rows within a table. Note: the collation attribute does not say anything about how the tables in a stream are ordered.

func (*CollationAttr) Key added in v0.175.0

func (ca *CollationAttr) Key() string

func (*CollationAttr) SatisfiedBy added in v0.175.0

func (ca *CollationAttr) SatisfiedBy(attr PhysicalAttr) bool

func (*CollationAttr) String added in v0.175.0

func (ca *CollationAttr) String() string

func (*CollationAttr) SuccessorsMustRequire added in v0.175.0

func (ca *CollationAttr) SuccessorsMustRequire() bool

type Cost

type Cost struct {
	Disk int64
	CPU  int64
	GPU  int64
	MEM  int64
	NET  int64
}

Cost stores various dimensions of the cost of a query plan

func Add

func Add(a Cost, b Cost) Cost

Add two cost structures together

type CreateProcedureSpec

type CreateProcedureSpec func(flux.OperationSpec, Administration) (ProcedureSpec, error)

CreateProcedureSpec creates a ProcedureSpec from an OperationSpec and Administration

type DefaultCost

type DefaultCost struct {
}

func (DefaultCost) Cost

func (c DefaultCost) Cost(inStats []Statistics) (Cost, Statistics)

type Detailer added in v0.50.0

type Detailer interface {
	PlanDetails() string
}

Detailer provides an optional interface that ProcedureSpecs can implement. Implementors of this interface will have their details appear in the formatted output for a plan if the WithDetails() option is set.

type FormatOption

type FormatOption func(*formatter)

func WithDetails added in v0.50.0

func WithDetails() FormatOption

WithDetails returns a FormatOption that can be used to provide extra details in a formatted plan.

type GeneratedYieldProcedureSpec

type GeneratedYieldProcedureSpec struct {
	DefaultCost
	Name string
}

GeneratedYieldProcedureSpec provides a special planner-generated yield for queries that don't have explicit calls to yield().

func (*GeneratedYieldProcedureSpec) Copy

func (*GeneratedYieldProcedureSpec) Kind

func (*GeneratedYieldProcedureSpec) YieldName

func (y *GeneratedYieldProcedureSpec) YieldName() string

type Location added in v0.134.0

type Location struct {
	Name   string
	Offset flux.Duration
}

func (Location) IsUTC added in v0.134.0

func (l Location) IsUTC() bool

func (Location) Load added in v0.134.0

func (l Location) Load() (interval.Location, error)

type LogicalNode added in v0.24.0

type LogicalNode struct {
	Spec   ProcedureSpec
	Source []interpreter.StackEntry
	// contains filtered or unexported fields
}

LogicalNode consists of the input and output edges and a procedure spec that describes what the node does.

func CreateLogicalNode

func CreateLogicalNode(id NodeID, spec ProcedureSpec) *LogicalNode

CreateLogicalNode creates a single logical plan node from a procedure spec. The newly created logical node has no incoming or outgoing edges.

func (*LogicalNode) AddPredecessors added in v0.24.0

func (e *LogicalNode) AddPredecessors(nodes ...Node)

func (*LogicalNode) AddSuccessors added in v0.24.0

func (e *LogicalNode) AddSuccessors(nodes ...Node)

func (*LogicalNode) Bounds added in v0.24.0

func (b *LogicalNode) Bounds() *Bounds

func (*LogicalNode) CallStack added in v0.83.0

func (lpn *LogicalNode) CallStack() []interpreter.StackEntry

CallStack returns the call stack that created this LogicalNode.

func (*LogicalNode) ClearPredecessors added in v0.24.0

func (e *LogicalNode) ClearPredecessors()

func (*LogicalNode) ClearSuccessors added in v0.24.0

func (e *LogicalNode) ClearSuccessors()

func (*LogicalNode) ID added in v0.24.0

func (lpn *LogicalNode) ID() NodeID

ID returns a human-readable identifier unique to this plan.

func (*LogicalNode) Kind added in v0.24.0

func (lpn *LogicalNode) Kind() ProcedureKind

Kind returns the kind of procedure performed by this plan node.

func (*LogicalNode) Predecessors added in v0.24.0

func (e *LogicalNode) Predecessors() []Node

func (*LogicalNode) ProcedureSpec added in v0.24.0

func (lpn *LogicalNode) ProcedureSpec() ProcedureSpec

ProcedureSpec returns the procedure spec for this plan node.

func (*LogicalNode) ReplaceSpec added in v0.24.0

func (lpn *LogicalNode) ReplaceSpec(newSpec ProcedureSpec) error

func (*LogicalNode) SetBounds added in v0.24.0

func (b *LogicalNode) SetBounds(bounds *Bounds)

func (*LogicalNode) ShallowCopy added in v0.24.0

func (lpn *LogicalNode) ShallowCopy() Node

func (*LogicalNode) Successors added in v0.24.0

func (e *LogicalNode) Successors() []Node

type LogicalOption

type LogicalOption interface {
	// contains filtered or unexported methods
}

LogicalOption is an option to configure the behavior of the logical plan.

func AddLogicalRules added in v0.26.0

func AddLogicalRules(rules ...Rule) LogicalOption

func DisableIntegrityChecks added in v0.10.0

func DisableIntegrityChecks() LogicalOption

DisableIntegrityChecks disables integrity checks in the logical planner.

func OnlyLogicalRules

func OnlyLogicalRules(rules ...Rule) LogicalOption

OnlyLogicalRules produces a logical plan option that forces only a set of particular rules to be applied.

func RemoveLogicalRules added in v0.48.0

func RemoveLogicalRules(rules ...string) LogicalOption

type LogicalPlanner

type LogicalPlanner interface {
	CreateInitialPlan(spec *operation.Spec) (*Spec, error)
	Plan(context.Context, *Spec) (*Spec, error)
}

LogicalPlanner translates a flux.Spec into a plan.Spec and applies any registered logical rules to the plan.

Logical planning should transform the plan in ways that are independent of actual physical algorithms used to implement operations, and independent of the actual data being processed.

func NewLogicalPlanner

func NewLogicalPlanner(options ...LogicalOption) LogicalPlanner

NewLogicalPlanner returns a new logical plan with the given options. The plan will be configured to apply any logical rules that have been registered.

type NarrowTransformationTriggerSpec added in v0.22.0

type NarrowTransformationTriggerSpec struct{}

func (NarrowTransformationTriggerSpec) Kind added in v0.22.0

type Node added in v0.24.0

type Node interface {
	// ID returns an identifier for this plan node.
	ID() NodeID

	// Bounds returns the time bounds for this plan node.
	Bounds() *Bounds

	// Predecessors returns plan nodes executed immediately before this node.
	Predecessors() []Node

	// Successors returns plan nodes executed immediately after this node.
	Successors() []Node

	// ProcedureSpec returns the specification of the procedure represented by this node.
	ProcedureSpec() ProcedureSpec

	// ReplaceSpec replaces the procedure spec of this node with another.
	ReplaceSpec(ProcedureSpec) error

	// Kind returns the type of procedure represented by this node.
	Kind() ProcedureKind

	// CallStack returns the list of StackEntry values that created this
	// Node. A Node may have no associated call stack. This happens
	// when a Node is constructed from a planner rule and not from a
	// source location.
	CallStack() []interpreter.StackEntry

	// Helper methods for manipulating a plan
	// These methods are used during planning
	SetBounds(bounds *Bounds)
	AddSuccessors(...Node)
	AddPredecessors(...Node)
	ClearSuccessors()
	ClearPredecessors()

	ShallowCopy() Node
}

Node defines the common interface for interacting with logical and physical plan nodes.

func MergeToLogicalNode added in v0.24.0

func MergeToLogicalNode(top, bottom Node, procSpec ProcedureSpec) (Node, error)

MergeToLogicalNode merges top and bottom plan nodes into a new plan node, with the given procedure spec.

V1     V2       V1            V2       <-- successors
  \   /
   top             mergedNode
    |      ==>         |
  bottom               W
    |
    W

The returned node will have its predecessors set to the predecessors of "bottom", however, it's successors will not be set---it will be the responsibility of the plan to attach the merged node to its successors.

func MergeToPhysicalNode added in v0.24.0

func MergeToPhysicalNode(top, bottom Node, procSpec PhysicalProcedureSpec) (Node, error)

func ReplacePhysicalNodes added in v0.179.0

func ReplacePhysicalNodes(ctx context.Context, oldOutputNode, oldInputNode Node, name string, newSpec PhysicalProcedureSpec) Node

ReplacePhysicalNodes accepts a connected group of nodes that has a single output and a single input, and replaces them with a single node with the predecessors of the old input node. Note that the planner has a convention of connecting successors itself (rather than having the rules doing it) so the old output's successors remain unconnected.

func SwapPlanNodes

func SwapPlanNodes(top, bottom Node) (Node, error)

SwapPlanNodes swaps two plan nodes and returns an equivalent sub-plan with the nodes swapped.

V1   V2        V1   V2
  \ /
   A              B
   |     ==>      |
   B          copy of A
   |              |
   W              W

Note that successors of the original top node will not be updated, and the returned plan node will have no successors. It will be the responsibility of the plan to attach the swapped nodes to successors.

type NodeID

type NodeID string

type OrFinallyTriggerSpec added in v0.22.0

type OrFinallyTriggerSpec struct {
	Main    TriggerSpec
	Finally TriggerSpec
}

func (OrFinallyTriggerSpec) Kind added in v0.22.0

type OutputAttributer added in v0.175.0

type OutputAttributer interface {
	OutputAttributes() PhysicalAttributes
}

OutputAttributer is an interface to be implemented by PhysicalProcedureSpec implementations that produce output that has particular attributes.

type ParallelMergeAttribute added in v0.157.0

type ParallelMergeAttribute struct {
	Factor int
}

ParallelMergeAttribute means that the node accepts parallel data, merges the streams, and produces non-parallel data that covers the entire data source.

func (ParallelMergeAttribute) Key added in v0.175.0

func (ParallelMergeAttribute) PlanDetails added in v0.174.0

func (a ParallelMergeAttribute) PlanDetails() string

func (ParallelMergeAttribute) SatisfiedBy added in v0.175.0

func (a ParallelMergeAttribute) SatisfiedBy(attr PhysicalAttr) bool

func (ParallelMergeAttribute) String added in v0.175.0

func (a ParallelMergeAttribute) String() string

func (ParallelMergeAttribute) SuccessorsMustRequire added in v0.157.0

func (ParallelMergeAttribute) SuccessorsMustRequire() bool

type ParallelRunAttribute added in v0.157.0

type ParallelRunAttribute struct {
	Factor int
}

ParallelRunAttribute means the node executes in parallel when present. It accepts parallel data (a subset of the source) and produces parallel data.

func (ParallelRunAttribute) Key added in v0.175.0

func (ParallelRunAttribute) SatisfiedBy added in v0.175.0

func (a ParallelRunAttribute) SatisfiedBy(attr PhysicalAttr) bool

func (ParallelRunAttribute) String added in v0.175.0

func (a ParallelRunAttribute) String() string

func (ParallelRunAttribute) SuccessorsMustRequire added in v0.157.0

func (ParallelRunAttribute) SuccessorsMustRequire() bool

SuccessorsMustRequire implements the PhysicalAttribute interface. if a node produces parallel data, then all successors must require parallel data, otherwise there will be a plan error.

type PassThroughAttributer added in v0.175.0

type PassThroughAttributer interface {
	PassThroughAttribute(attrKey string) bool
}

PassThroughAttributer is an interface to be implemented by PhysicalProcedureSpec implementations that allow attributes to propagate from input to output.

type Pattern

type Pattern interface {
	// Roots returns the list of procedure kinds that may appear
	// at the "root" of the pattern. "Root" here means a node with
	// some predecessors.
	Roots() []ProcedureKind
	// Match returns true when the given node and its predecessors match
	// with this pattern.
	Match(Node) bool
}

Pattern represents an operator tree pattern It can match itself against a query plan.

func AnyMultiSuccessor added in v0.178.0

func AnyMultiSuccessor() Pattern

AnyMultiSuccessor returns a pattern that matches any node with any number of successors

func AnySingleSuccessor added in v0.178.0

func AnySingleSuccessor() Pattern

AnySingleSuccessor returns a pattern that matches any node that has a single successor.

func MultiSuccessor added in v0.178.0

func MultiSuccessor(kind ProcedureKind, predecessors ...Pattern) Pattern

MultiSuccessor returns a pattern that can match a plan node with the given ProcedureKind and whose predecessors match the given predecessor patterns. The matched node may have any number of successors, including zero.

func MultiSuccessorOneOf added in v0.178.0

func MultiSuccessorOneOf(kinds []ProcedureKind, predecessors ...Pattern) Pattern

MultiSuccessorOneOf matches any plan node from a given set of ProcedureKind and whose predecessors match the given predecessor patterns. This is identical to MultiSuccessor, except for matching any pattern root from a set of ProcedureKinds.

func PhysPat added in v0.22.0

func PhysPat(pat Pattern) Pattern

PhysPat returns a pattern that matches a physical plan node with the given ProcedureKind and whose predecessors match the given predecessor patterns.

func SingleSuccessor added in v0.178.0

func SingleSuccessor(kind ProcedureKind, predecessors ...Pattern) Pattern

SingleSuccessor returns a pattern that can match a plan node with the given ProcedureKind and whose predecessors match the given predecessor patterns. The matched node must have exactly one successor.

For example, to construct a pattern that matches a sort node that succeeds a join:

 sort
  |
 join   <=>  join(A, B) |> sum()  <=>  MultiSuccessor(SortKind, SingleSuccessor(JoinKind, AnyMultiSuccessor(), AnyMultiSuccessor()))
/   \

A B

func SingleSuccessorOneOf added in v0.178.0

func SingleSuccessorOneOf(kinds []ProcedureKind, predecessors ...Pattern) Pattern

SingleSuccessorOneOf matches any plan node from a given set of ProcedureKind and whose predecessors match the given predecessor patterns. This is identical to SingleSuccessor, except for matching any pattern root from a set of ProcedureKinds.

type PhysicalAttr added in v0.157.0

type PhysicalAttr interface {
	String() string
	Key() string
	SuccessorsMustRequire() bool
	SatisfiedBy(attr PhysicalAttr) bool
}

PhysicalAttr represents an attribute (collation, parallel execution) of a plan node.

func GetOutputAttribute added in v0.175.0

func GetOutputAttribute(node Node, attrKey string) PhysicalAttr

GetOutputAttribute will return the attribute with the given key provided by the given plan node, traversing backwards through predecessors as needed for attributes that may pass through. E.g.,

sort |> filter

The "filter" node will still provide the collation attribute, even though it's the "sort" node that actually does the collating.

type PhysicalAttributes

type PhysicalAttributes map[string]PhysicalAttr

PhysicalAttributes encapsulates any physical attributes of the result produced by a physical plan node, such as collation, etc.

type PhysicalOneKindPattern added in v0.22.0

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

PhysicalOneKindPattern matches a physical operator pattern

func (PhysicalOneKindPattern) Match added in v0.22.0

func (p PhysicalOneKindPattern) Match(node Node) bool

func (PhysicalOneKindPattern) Roots added in v0.67.0

type PhysicalOption

type PhysicalOption interface {
	// contains filtered or unexported methods
}

PhysicalOption is an option to configure the behavior of the physical plan.

func AddParallelRules added in v0.156.0

func AddParallelRules(rules ...Rule) PhysicalOption

func DisableValidation added in v0.10.0

func DisableValidation() PhysicalOption

DisableValidation disables validation in the physical planner.

func OnlyPhysicalRules

func OnlyPhysicalRules(rules ...Rule) PhysicalOption

OnlyPhysicalRules produces a physical plan option that forces only a particular set of rules to be applied.

func RemovePhysicalRules added in v0.48.0

func RemovePhysicalRules(rules ...string) PhysicalOption

func WithDefaultMemoryLimit

func WithDefaultMemoryLimit(memBytes int64) PhysicalOption

WithDefaultMemoryLimit sets the default memory limit for plans generated by the plan. If the query spec explicitly sets a memory limit, that limit is used instead of the default.

type PhysicalPlanNode

type PhysicalPlanNode struct {
	Spec   PhysicalProcedureSpec
	Source []interpreter.StackEntry

	// The trigger spec defines how and when a transformation
	// sends its tables to downstream operators
	TriggerSpec TriggerSpec
	// contains filtered or unexported fields
}

PhysicalPlanNode represents a physical operation in a plan.

func CreatePhysicalNode

func CreatePhysicalNode(id NodeID, spec PhysicalProcedureSpec) *PhysicalPlanNode

CreatePhysicalNode creates a single physical plan node from a procedure spec. The newly created physical node has no incoming or outgoing edges.

func CreateUniquePhysicalNode added in v0.93.0

func CreateUniquePhysicalNode(ctx context.Context, prefix string, spec PhysicalProcedureSpec) *PhysicalPlanNode

func (*PhysicalPlanNode) AddPredecessors

func (e *PhysicalPlanNode) AddPredecessors(nodes ...Node)

func (*PhysicalPlanNode) AddSuccessors

func (e *PhysicalPlanNode) AddSuccessors(nodes ...Node)

func (*PhysicalPlanNode) Bounds

func (b *PhysicalPlanNode) Bounds() *Bounds

func (*PhysicalPlanNode) CallStack added in v0.83.0

func (ppn *PhysicalPlanNode) CallStack() []interpreter.StackEntry

func (*PhysicalPlanNode) ClearPredecessors

func (e *PhysicalPlanNode) ClearPredecessors()

func (*PhysicalPlanNode) ClearSuccessors

func (e *PhysicalPlanNode) ClearSuccessors()

func (*PhysicalPlanNode) Cost

func (ppn *PhysicalPlanNode) Cost(inStats []Statistics) (cost Cost, outStats Statistics)

Cost provides the self-cost (i.e., does not include the cost of its predecessors) for this plan node. Caller must provide statistics of predecessors to this node.

func (*PhysicalPlanNode) ID

func (ppn *PhysicalPlanNode) ID() NodeID

ID returns a human-readable id for this plan node.

func (*PhysicalPlanNode) Kind

func (ppn *PhysicalPlanNode) Kind() ProcedureKind

Kind returns the procedure kind for this plan node.

func (*PhysicalPlanNode) Predecessors

func (e *PhysicalPlanNode) Predecessors() []Node

func (*PhysicalPlanNode) ProcedureSpec

func (ppn *PhysicalPlanNode) ProcedureSpec() ProcedureSpec

ProcedureSpec returns the procedure spec for this plan node.

func (*PhysicalPlanNode) ReplaceSpec

func (ppn *PhysicalPlanNode) ReplaceSpec(newSpec ProcedureSpec) error

func (*PhysicalPlanNode) SetBounds

func (b *PhysicalPlanNode) SetBounds(bounds *Bounds)

func (*PhysicalPlanNode) ShallowCopy

func (ppn *PhysicalPlanNode) ShallowCopy() Node

func (*PhysicalPlanNode) Successors

func (e *PhysicalPlanNode) Successors() []Node

type PhysicalPlanner

type PhysicalPlanner interface {
	Plan(ctx context.Context, lplan *Spec) (*Spec, error)
}

PhysicalPlanner performs transforms a logical plan to a physical plan, by applying any registered physical rules.

func NewPhysicalPlanner

func NewPhysicalPlanner(options ...PhysicalOption) PhysicalPlanner

NewPhysicalPlanner creates a new physical plan with the specified options. The new plan will be configured to apply any physical rules that have been registered.

type PhysicalProcedureSpec

type PhysicalProcedureSpec interface {
	Kind() ProcedureKind
	Copy() ProcedureSpec
	Cost(inStats []Statistics) (cost Cost, outStats Statistics)
}

PhysicalProcedureSpec is similar to its logical counterpart but must provide a method to determine cost.

type Planner added in v0.24.0

type Planner interface {
	Plan(context.Context, *operation.Spec) (*Spec, error)
}

type PlannerBuilder added in v0.24.0

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

PlannerBuilder provides clients with an easy way to create planners.

func (*PlannerBuilder) AddLogicalOptions added in v0.24.0

func (pb *PlannerBuilder) AddLogicalOptions(lopt ...LogicalOption)

AddLogicalOptions lets callers specify attributes of the logical planner that will be part of the created planner.

func (*PlannerBuilder) AddPhysicalOptions added in v0.26.0

func (pb *PlannerBuilder) AddPhysicalOptions(popt ...PhysicalOption)

AddPhysicalOptions lets callers specify attributes of the physical planner that will be part of the created planner.

func (PlannerBuilder) Build added in v0.24.0

func (pb PlannerBuilder) Build() Planner

Build builds a planner with specified attributes.

type PostPhysicalValidator

type PostPhysicalValidator interface {
	PostPhysicalValidate(id NodeID) error
}

PostPhysicalValidator provides an interface that can be implemented by PhysicalProcedureSpecs for any validation checks to be performed post-physical planning.

type ProcedureKind

type ProcedureKind string

ProcedureKind denotes the kind of operation

type ProcedureSpec

type ProcedureSpec interface {
	Kind() ProcedureKind
	Copy() ProcedureSpec
}

ProcedureSpec specifies a query operation

type RepeatedTriggerSpec added in v0.22.0

type RepeatedTriggerSpec struct {
	Trigger TriggerSpec
}

func (RepeatedTriggerSpec) Kind added in v0.22.0

type RequiredAttributer added in v0.175.0

type RequiredAttributer interface {
	RequiredAttributes() []PhysicalAttributes
}

RequiredAttributer is an interface to be implemented by PhysicalProcedureSpec implementations that require physical attributes to be provided by inputs. The return value here is a slice, since each input may be required to have a different set of attributes.

type Rule

type Rule interface {
	// Name of this rule (must be unique).
	Name() string

	// Pattern for this rule to match against.
	Pattern() Pattern

	// Rewrite an operation into an equivalent one.
	// The returned node is the new root of the sub tree.
	// The boolean return value should be true if anything changed during the rewrite.
	Rewrite(context.Context, Node) (Node, bool, error)
}

Rule is transformation rule for a query operation

type Spec added in v0.24.0

type Spec struct {
	// Roots are the "sink" nodes in the plan, which have no successors.
	Roots     map[Node]struct{}
	Resources flux.ResourceManagement
	Now       time.Time
}

Spec holds the result nodes of a query plan with associated metadata

func NewPlanSpec

func NewPlanSpec() *Spec

NewPlanSpec initializes a new query plan

func (*Spec) BottomUpWalk added in v0.24.0

func (plan *Spec) BottomUpWalk(f func(Node) error) error

BottomUpWalk will execute f for each plan node in the Spec, starting from the sources, and only visiting a node after all its predecessors have been visited.

func (*Spec) CheckIntegrity added in v0.24.0

func (plan *Spec) CheckIntegrity() error

CheckIntegrity checks the integrity of the plan, i.e.:

  • node A is predecessor of B iff B is successor of A;
  • there is no cycle.

This check only detects this problem (N2 is predecessor of R, but not viceversa):

N1 <----> R
          |
N2 <-------

And this one (R is successor of N2, but not viceversa):

N1 <-------
|         |--> R
N2 --------

But not this one, because N2 is not reachable from R (root):

N1 <-------
          |--> R
N2 --------

func (*Spec) Replace added in v0.24.0

func (plan *Spec) Replace(root, with Node)

Replace replaces one of the root nodes of the query plan

func (*Spec) TopDownWalk added in v0.24.0

func (plan *Spec) TopDownWalk(f func(node Node) error) error

TopDownWalk will execute f for each plan node in the Spec. It always visits a node before visiting its predecessors.

func (*Spec) TopologicalWalk added in v0.24.0

func (plan *Spec) TopologicalWalk(visitFn func(node Node) error) error

TopologicalWalk visits every node in the plan in topological order. If a cycle is detected, no node is visited and an error is returned.

type Statistics

type Statistics struct {
	Cardinality      int64
	GroupCardinality int64
}

type TriggerAwareProcedureSpec added in v0.22.0

type TriggerAwareProcedureSpec interface {
	TriggerSpec() TriggerSpec
}

type TriggerKind added in v0.22.0

type TriggerKind int
const (
	NarrowTransformation TriggerKind = iota
	AfterWatermark
	Repeated
	AfterProcessingTime
	AfterAtLeastCount
	OrFinally
)

type TriggerSpec added in v0.22.0

type TriggerSpec interface {
	Kind() TriggerKind
}

type UnionKindPattern added in v0.67.0

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

UnionKindPattern matches any one of a set of procedures that have a specified predecessor pattern.

For example, UnionKindPattern( { Proc1Kind, Proc2Kind }, { Pat1, Pat2 } ) will match either Proc1Kind { Pat1, Pat2 } or Proc2Kind { Pat1, Pat2 }

         [ ProcedureKind ]
         /       |  ...  \
pattern1     pattern2  ... patternK

func (UnionKindPattern) Match added in v0.67.0

func (ukp UnionKindPattern) Match(node Node) bool

func (UnionKindPattern) Roots added in v0.67.0

func (ukp UnionKindPattern) Roots() []ProcedureKind

type WindowSpec

type WindowSpec struct {
	Every    flux.Duration
	Period   flux.Duration
	Offset   flux.Duration
	Location Location
}

func (WindowSpec) LoadLocation added in v0.134.0

func (w WindowSpec) LoadLocation() (interval.Location, error)

type YieldProcedureSpec

type YieldProcedureSpec interface {
	YieldName() string
}

YieldProcedureSpec is a special procedure that has the side effect of returning a result to the client.

Directories

Path Synopsis
Package plantest contains utilities for testing each query planning phase
Package plantest contains utilities for testing each query planning phase

Jump to

Keyboard shortcuts

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