plan

package
v0.0.0-...-f5b6858 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: MIT Imports: 7 Imported by: 5

Documentation

Overview

Package plan implements the flux query planner to plan execution of a query spec.

Index

Constants

View Source
const DefaultYieldName = "_result"

DefaultYieldName is the yield name to use in cases where no explicit yield name was specified.

Variables

View Source
var (
	MinTime = values.ConvertTime(query.MinTime.Absolute)
	MaxTime = values.ConvertTime(query.MaxTime.Absolute)
)
View Source
var EmptyBoundsSpec = &BoundsSpec{
	Start: values.Time(0),
	Stop:  values.Time(0),
}
View Source
var NilUUID uuid.UUID
View Source
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 BoundedProcedureSpec interface {
	TimeBounds() query.Bounds
}

type BoundsSpec

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

func ToBoundsSpec

func ToBoundsSpec(bounds query.Bounds, now time.Time) (*BoundsSpec, error)

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

func WithDefaultMemoryLimit(memBytes int64) Option

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 PlanRewriter interface {
	IsolatePath(parent, child *Procedure) (*Procedure, error)
	RemoveBranch(pr *Procedure) error
	AddChild(parent *Procedure, childSpec ProcedureSpec)
}

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
}

func (*PlanSpec) Do

func (p *PlanSpec) Do(f func(pr *Procedure))

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

func NewPlanner(opts ...Option) Planner

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) Child

func (p *Procedure) Child(i int) *Procedure

func (*Procedure) Copy

func (p *Procedure) Copy() *Procedure

func (*Procedure) DoChildren

func (p *Procedure) DoChildren(f func(pr *Procedure))

func (*Procedure) DoParents

func (p *Procedure) DoParents(f func(pr *Procedure))

type ProcedureID

type ProcedureID uuid.UUID
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 ProcedureKind

type ProcedureKind string

ProcedureKind denotes the kind of operations.

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 Shard

type Shard struct {
	Node  string
	Range TimeRange
}

type ShardMap

type ShardMap map[string][]Shard

ShardMap is a mapping of database names to list of shards for that database.

type Storage

type Storage interface {
	ShardMapping() ShardMap
}

type TimeRange

type TimeRange struct {
	Start time.Time
	Stop  time.Time
}

type WindowSpec

type WindowSpec struct {
	Every  query.Duration
	Period query.Duration
	Round  query.Duration
	Start  query.Time
}

type YieldProcedureSpec

type YieldProcedureSpec interface {
	YieldName() string
}

type YieldSpec

type YieldSpec struct {
	ID ProcedureID
}

YieldSpec defines how data should be yielded.

Directories

Path Synopsis
Package plantest contains utilities for testing the query planning phase.
Package plantest contains utilities for testing the query planning phase.

Jump to

Keyboard shortcuts

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