query

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2018 License: AGPL-3.0, AGPL-3.0-or-later Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableParameter = "table"
)

Variables

View Source
var (
	MinTime = Time{
		Absolute: time.Unix(0, math.MinInt64),
	}
	MaxTime = Time{
		Absolute: time.Unix(0, math.MaxInt64),
	}
	Now = Time{
		IsRelative: true,
	}
)
View Source
var DefaultTrigger = AfterWatermarkTriggerSpec{}
View Source
var TableObjectType = semantic.NewObjectType(map[string]semantic.Type{
	tableIDKey:   semantic.String,
	tableKindKey: semantic.String,

	tableSpecKey: semantic.EmptyObject,

	tableParentsKey: semantic.NewArrayType(semantic.EmptyObject),
})

Functions

func BuiltIns added in v0.0.6

func DefaultFunctionSignature added in v0.0.5

func DefaultFunctionSignature() semantic.FunctionSignature

DefaultFunctionSignature returns a FunctionSignature for standard functions which accept a table piped argument. It is safe to modify the returned signature.

func FinalizeRegistration added in v0.0.5

func FinalizeRegistration()

FinalizeRegistration must be called to complete registration. Future calls to RegisterFunction or RegisterBuiltIn will panic.

func FmtJSON added in v0.0.4

func FmtJSON(f *formatter)

func Formatted

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

func NumberOfOperations

func NumberOfOperations() int

func RegisterBuiltIn added in v0.0.4

func RegisterBuiltIn(name, script string)

RegisterBuiltIn adds any variable declarations in the script to the builtin scope.

func RegisterFunction added in v0.0.4

func RegisterFunction(name string, c CreateOperationSpec, sig semantic.FunctionSignature)

RegisterFunction adds a new builtin top level function.

func RegisterOpSpec

func RegisterOpSpec(k OperationKind, c NewOperationSpec)

RegisterOpSpec registers an operation spec with a given kind. If the kind has already been registered the call panics.

TODO:(nathanielc) make this part of RegisterMethod/RegisterFunction

Types

type Administration added in v0.0.4

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

func (*Administration) AddParent added in v0.0.4

func (a *Administration) AddParent(np TableObject)

AddParent instructs the evaluation Context that a new edge should be created from the parent to the current operation. Duplicate parents will be removed, so the caller need not concern itself with which parents have already been added.

func (*Administration) AddParentFromArgs added in v0.0.5

func (a *Administration) AddParentFromArgs(args Arguments) error

AddParentFromArgs reads the args for the `table` argument and adds the value as a parent.

type AfterAtLeastCountTriggerSpec

type AfterAtLeastCountTriggerSpec struct {
	Count int
}

func (AfterAtLeastCountTriggerSpec) Kind

type AfterProcessingTimeTriggerSpec

type AfterProcessingTimeTriggerSpec struct {
	Duration Duration
}

func (AfterProcessingTimeTriggerSpec) Kind

type AfterWatermarkTriggerSpec

type AfterWatermarkTriggerSpec struct {
	AllowedLateness Duration
}

func (AfterWatermarkTriggerSpec) Kind

type Arguments added in v0.0.4

type Arguments struct {
	interpreter.Arguments
}

func (Arguments) GetDuration added in v0.0.4

func (a Arguments) GetDuration(name string) (Duration, bool, error)

func (Arguments) GetRequiredDuration added in v0.0.4

func (a Arguments) GetRequiredDuration(name string) (Duration, error)

func (Arguments) GetRequiredTime added in v0.0.4

func (a Arguments) GetRequiredTime(name string) (Time, error)

func (Arguments) GetTime added in v0.0.4

func (a Arguments) GetTime(name string) (Time, bool, error)

type CreateOperationSpec

type CreateOperationSpec func(args Arguments, a *Administration) (OperationSpec, error)

type Domain added in v0.0.6

type Domain interface {
	interpreter.Domain
	ToSpec() *Spec
}

func NewDomain added in v0.0.6

func NewDomain() Domain

type Duration

type Duration time.Duration

Duration is a marshalable duration type. TODO make this the real duration parsing not just time.ParseDuration

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(data []byte) error

type Edge

type Edge struct {
	Parent OperationID `json:"parent"`
	Child  OperationID `json:"child"`
}

Edge is a data flow relationship between a parent and a child

type FormatOption

type FormatOption func(*formatter)

TODO(nathanielc): Add better options for formatting plans as Graphviz dot format.

type NewOperationSpec added in v0.0.4

type NewOperationSpec func() OperationSpec

type Operation

type Operation struct {
	ID   OperationID   `json:"id"`
	Spec OperationSpec `json:"spec"`
}

Operation denotes a single operation in a query.

func (Operation) MarshalJSON

func (o Operation) MarshalJSON() ([]byte, error)

func (*Operation) UnmarshalJSON

func (o *Operation) UnmarshalJSON(data []byte) error

type OperationID

type OperationID string

OperationID is a unique ID within a query for the operation.

type OperationKind

type OperationKind string

OperationKind denotes the kind of operations.

type OperationSpec

type OperationSpec interface {
	// Kind returns the kind of the operation.
	Kind() OperationKind
}

OperationSpec specifies an operation as part of a query.

type Option added in v0.0.5

type Option func(*options)

func Verbose added in v0.0.5

func Verbose(v bool) Option

type OrFinallyTriggerSpec

type OrFinallyTriggerSpec struct {
	Main    TriggerSpec
	Finally TriggerSpec
}

func (OrFinallyTriggerSpec) Kind

type Priority added in v0.0.3

type Priority int32

Priority is an integer that represents the query priority. Any positive 32bit integer value may be used. Special constants are provided to represent the extreme high and low priorities.

const (
	// High is the highest possible priority = 0
	High Priority = 0
	// Low is the lowest possible priority = MaxInt32
	Low Priority = math.MaxInt32
)

func (Priority) MarshalText added in v0.0.3

func (p Priority) MarshalText() ([]byte, error)

func (*Priority) UnmarshalText added in v0.0.3

func (p *Priority) UnmarshalText(txt []byte) error

type RepeatedTriggerSpec

type RepeatedTriggerSpec struct {
	Trigger TriggerSpec
}

func (RepeatedTriggerSpec) Kind

type ResourceManagement added in v0.0.3

type ResourceManagement struct {
	// Priority or the query.
	// Queries with a lower value will move to the front of the priority queue.
	// A zero value indicates the highest priority.
	Priority Priority `json:"priority"`
	// ConcurrencyQuota is the number of concurrency workers allowed to process this query.
	// A zero value indicates the planner can pick the optimal concurrency.
	ConcurrencyQuota int `json:"concurrency_quota"`
	// MemoryBytesQuota is the number of bytes of RAM this query may consume.
	// There is a small amount of overhead memory being consumed by a query that will not be counted towards this limit.
	// A zero value indicates unlimited.
	MemoryBytesQuota int64 `json:"memory_bytes_quota"`
}

ResourceManagement defines how the query should consume avaliable resources.

type Spec added in v0.0.4

type Spec struct {
	Operations []*Operation       `json:"operations"`
	Edges      []Edge             `json:"edges"`
	Resources  ResourceManagement `json:"resources"`
	// contains filtered or unexported fields
}

Spec specifies a query.

func Compile added in v0.0.4

func Compile(ctx context.Context, q string, opts ...Option) (*Spec, error)

Compile evaluates an IFQL script producing a query Spec.

func (*Spec) Children added in v0.0.4

func (q *Spec) Children(id OperationID) []*Operation

Children returns a list of children for a given operation. If the query is invalid no children will be returned.

func (*Spec) Functions added in v0.0.4

func (q *Spec) Functions() ([]string, error)

Functions return the names of all functions used in the plan

func (*Spec) Parents added in v0.0.4

func (q *Spec) Parents(id OperationID) []*Operation

Parents returns a list of parents for a given operation. If the query is invalid no parents will be returned.

func (*Spec) Validate added in v0.0.4

func (q *Spec) Validate() error

Validate ensures the query is a valid DAG.

func (*Spec) Walk added in v0.0.4

func (q *Spec) Walk(f func(o *Operation) error) error

Walk calls f on each operation exactly once. The function f will be called on an operation only after all of its parents have already been passed to f.

type TableObject added in v0.0.6

type TableObject struct {
	interpreter.Object
}

func NewTableObject added in v0.0.6

func NewTableObject(t interpreter.Object) (TableObject, error)

func (TableObject) ID added in v0.0.6

func (t TableObject) ID() OperationID

func (TableObject) Kind added in v0.0.6

func (t TableObject) Kind() OperationKind

func (TableObject) Operation added in v0.0.6

func (t TableObject) Operation() *Operation

func (TableObject) Spec added in v0.0.6

func (t TableObject) Spec() OperationSpec

func (TableObject) String added in v0.0.6

func (t TableObject) String() string

func (TableObject) ToSpec added in v0.0.6

func (t TableObject) ToSpec() *Spec

type Time

type Time struct {
	IsRelative bool
	Relative   time.Duration
	Absolute   time.Time
}

Time represents either a relavite or absolute time. If Time is its zero value then it represents a time.Time{}. To represent the now time you must set IsRelative to true.

func ToQueryTime added in v0.0.4

func ToQueryTime(value interpreter.Value) (Time, error)

func (Time) IsZero

func (t Time) IsZero() bool

func (Time) MarshalText

func (t Time) MarshalText() ([]byte, error)

func (Time) Time

func (t Time) Time(now time.Time) time.Time

Time returns the time specified relative to now.

func (*Time) UnmarshalText

func (t *Time) UnmarshalText(data []byte) error

type TriggerKind

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

type TriggerSpec

type TriggerSpec interface {
	Kind() TriggerKind
}

Directories

Path Synopsis
storage
Package storage is a generated protocol buffer package.
Package storage is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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