parser

package
v1.25.5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ADD = 57368
View Source
const AT = 57385
View Source
const AVG = 57388
View Source
const BLANK = 57347
View Source
const BOOL = 57402
View Source
const BOTTOMK = 57389
View Source
const BY = 57403
View Source
const COLON = 57348
View Source
const COMMA = 57349
View Source
const COMMENT = 57350
View Source
const COUNT = 57390
View Source
const COUNT_VALUES = 57391
View Source
const DIV = 57369
View Source
const DURATION = 57351
View Source
const END = 57413
View Source
const EOF = 57352
View Source
const EQL = 57346
View Source
const EQLC = 57370
View Source
const EQL_REGEX = 57371
View Source
const ERROR = 57353
View Source
const GROUP = 57392
View Source
const GROUP_LEFT = 57404
View Source
const GROUP_RIGHT = 57405
View Source
const GTE = 57372
View Source
const GTR = 57373
View Source
const IDENTIFIER = 57354
View Source
const IGNORING = 57406
View Source
const LAND = 57374
View Source
const LEFT_BRACE = 57355
View Source
const LEFT_BRACKET = 57356
View Source
const LEFT_PAREN = 57357
View Source
const LOR = 57375
View Source
const LSS = 57376
View Source
const LTE = 57377
View Source
const LUNLESS = 57378
View Source
const MAX = 57393
View Source
const METRIC_IDENTIFIER = 57358
View Source
const MIN = 57394
View Source
const MOD = 57379
View Source
const MUL = 57380
View Source
const NEQ = 57381
View Source
const NEQ_REGEX = 57382
View Source
const NUMBER = 57359
View Source
const OFFSET = 57407
View Source
const ON = 57408
View Source
const POW = 57383
View Source
const QUANTILE = 57395
View Source
const RIGHT_BRACE = 57360
View Source
const RIGHT_BRACKET = 57361
View Source
const RIGHT_PAREN = 57362
View Source
const SEMICOLON = 57363
View Source
const SPACE = 57364
View Source
const START = 57412
View Source
const START_EXPRESSION = 57418
View Source
const START_METRIC = 57416
View Source
const START_METRIC_SELECTOR = 57419
View Source
const START_SERIES_DESCRIPTION = 57417
View Source
const STDDEV = 57396
View Source
const STDVAR = 57397
View Source
const STRING = 57365
View Source
const SUB = 57384
View Source
const SUM = 57398
View Source
const TIMES = 57366
View Source
const TOPK = 57399
View Source
const WITHOUT = 57409

Variables

View Source
var Functions = map[string]*Function{
	"abs": {
		Name:       "abs",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"absent": {
		Name:       "absent",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"absent_over_time": {
		Name:       "absent_over_time",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"avg_over_time": {
		Name:       "avg_over_time",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"ceil": {
		Name:       "ceil",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"changes": {
		Name:       "changes",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"clamp_max": {
		Name:       "clamp_max",
		ArgTypes:   []ValueType{ValueTypeVector, ValueTypeScalar},
		ReturnType: ValueTypeVector,
	},
	"clamp_min": {
		Name:       "clamp_min",
		ArgTypes:   []ValueType{ValueTypeVector, ValueTypeScalar},
		ReturnType: ValueTypeVector,
	},
	"count_over_time": {
		Name:       "count_over_time",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"days_in_month": {
		Name:       "days_in_month",
		ArgTypes:   []ValueType{ValueTypeVector},
		Variadic:   1,
		ReturnType: ValueTypeVector,
	},
	"day_of_month": {
		Name:       "day_of_month",
		ArgTypes:   []ValueType{ValueTypeVector},
		Variadic:   1,
		ReturnType: ValueTypeVector,
	},
	"day_of_week": {
		Name:       "day_of_week",
		ArgTypes:   []ValueType{ValueTypeVector},
		Variadic:   1,
		ReturnType: ValueTypeVector,
	},
	"delta": {
		Name:       "delta",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"deriv": {
		Name:       "deriv",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"exp": {
		Name:       "exp",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"floor": {
		Name:       "floor",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"histogram_quantile": {
		Name:       "histogram_quantile",
		ArgTypes:   []ValueType{ValueTypeScalar, ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"holt_winters": {
		Name:       "holt_winters",
		ArgTypes:   []ValueType{ValueTypeMatrix, ValueTypeScalar, ValueTypeScalar},
		ReturnType: ValueTypeVector,
	},
	"hour": {
		Name:       "hour",
		ArgTypes:   []ValueType{ValueTypeVector},
		Variadic:   1,
		ReturnType: ValueTypeVector,
	},
	"idelta": {
		Name:       "idelta",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"increase": {
		Name:       "increase",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"irate": {
		Name:       "irate",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"label_replace": {
		Name:       "label_replace",
		ArgTypes:   []ValueType{ValueTypeVector, ValueTypeString, ValueTypeString, ValueTypeString, ValueTypeString},
		ReturnType: ValueTypeVector,
	},
	"label_join": {
		Name:       "label_join",
		ArgTypes:   []ValueType{ValueTypeVector, ValueTypeString, ValueTypeString, ValueTypeString},
		Variadic:   -1,
		ReturnType: ValueTypeVector,
	},
	"ln": {
		Name:       "ln",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"log10": {
		Name:       "log10",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"log2": {
		Name:       "log2",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"max_over_time": {
		Name:       "max_over_time",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"min_over_time": {
		Name:       "min_over_time",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"minute": {
		Name:       "minute",
		ArgTypes:   []ValueType{ValueTypeVector},
		Variadic:   1,
		ReturnType: ValueTypeVector,
	},
	"month": {
		Name:       "month",
		ArgTypes:   []ValueType{ValueTypeVector},
		Variadic:   1,
		ReturnType: ValueTypeVector,
	},
	"predict_linear": {
		Name:       "predict_linear",
		ArgTypes:   []ValueType{ValueTypeMatrix, ValueTypeScalar},
		ReturnType: ValueTypeVector,
	},
	"quantile_over_time": {
		Name:       "quantile_over_time",
		ArgTypes:   []ValueType{ValueTypeScalar, ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"rate": {
		Name:       "rate",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"resets": {
		Name:       "resets",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"round": {
		Name:       "round",
		ArgTypes:   []ValueType{ValueTypeVector, ValueTypeScalar},
		Variadic:   1,
		ReturnType: ValueTypeVector,
	},
	"scalar": {
		Name:       "scalar",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeScalar,
	},
	"sort": {
		Name:       "sort",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"sort_desc": {
		Name:       "sort_desc",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"sqrt": {
		Name:       "sqrt",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"stddev_over_time": {
		Name:       "stddev_over_time",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"stdvar_over_time": {
		Name:       "stdvar_over_time",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"sum_over_time": {
		Name:       "sum_over_time",
		ArgTypes:   []ValueType{ValueTypeMatrix},
		ReturnType: ValueTypeVector,
	},
	"time": {
		Name:       "time",
		ArgTypes:   []ValueType{},
		ReturnType: ValueTypeScalar,
	},
	"timestamp": {
		Name:       "timestamp",
		ArgTypes:   []ValueType{ValueTypeVector},
		ReturnType: ValueTypeVector,
	},
	"vector": {
		Name:       "vector",
		ArgTypes:   []ValueType{ValueTypeScalar},
		ReturnType: ValueTypeVector,
	},
	"year": {
		Name:       "year",
		ArgTypes:   []ValueType{ValueTypeVector},
		Variadic:   1,
		ReturnType: ValueTypeVector,
	},
}

Functions is a list of all functions supported by PromQL, including their types.

View Source
var ItemTypeStr = map[ItemType]string{
	LEFT_PAREN:    "(",
	RIGHT_PAREN:   ")",
	LEFT_BRACE:    "{",
	RIGHT_BRACE:   "}",
	LEFT_BRACKET:  "[",
	RIGHT_BRACKET: "]",
	COMMA:         ",",
	EQL:           "=",
	COLON:         ":",
	SEMICOLON:     ";",
	BLANK:         "_",
	TIMES:         "x",
	SPACE:         "<space>",

	SUB:       "-",
	ADD:       "+",
	MUL:       "*",
	MOD:       "%",
	DIV:       "/",
	EQLC:      "==",
	NEQ:       "!=",
	LTE:       "<=",
	LSS:       "<",
	GTE:       ">=",
	GTR:       ">",
	EQL_REGEX: "=~",
	NEQ_REGEX: "!~",
	POW:       "^",
}

ItemTypeStr is the default string representations for common Items. It does not imply that those are the only character sequences that can be lexed to such an Item.

Functions

func DocumentedType

func DocumentedType(t ValueType) string

DocumentedType returns the internal type to the equivalent user facing terminology as defined in the documentation.

func Inspect

func Inspect(node Node, f inspector)

Inspect traverses an AST in depth-first order: It starts by calling f(node, path); node must not be nil. If f returns a nil error, Inspect invokes f for all the non-nil children of node, recursively.

func MustLabelMatcher

func MustLabelMatcher(mt labels.MatchType, name, val string) *labels.Matcher

func ParseMetric

func ParseMetric(input string) (m labels.Labels, err error)

ParseMetric parses the input into a metric

func ParseMetricSelector

func ParseMetricSelector(input string) (m []*labels.Matcher, err error)

ParseMetricSelector parses the provided textual metric selector into a list of label matchers.

func Tree

func Tree(node Node) string

Tree returns a string of the tree structure of the given node.

func Walk

func Walk(v Visitor, node Node, path []Node) error

Walk traverses an AST in depth-first order: It starts by calling v.Visit(node, path); node must not be nil. If the visitor w returned by v.Visit(node, path) is not nil and the visitor returns no error, Walk is invoked recursively with visitor w for each of the non-nil children of node, followed by a call of w.Visit(nil), returning an error As the tree is descended the path of previous nodes is provided.

Types

type AggregateExpr

type AggregateExpr struct {
	Op       ItemType // The used aggregation operation.
	Expr     Expr     // The Vector expression over which is aggregated.
	Param    Expr     // Parameter used by some aggregators.
	Grouping []string // The labels by which to group the Vector.
	Without  bool     // Whether to drop the given labels rather than keep them.
	PosRange PositionRange
}

AggregateExpr represents an aggregation operation on a Vector.

func (*AggregateExpr) PositionRange

func (e *AggregateExpr) PositionRange() PositionRange

func (*AggregateExpr) PromQLExpr

func (*AggregateExpr) PromQLExpr()

func (*AggregateExpr) String

func (node *AggregateExpr) String() string

func (*AggregateExpr) Type

func (e *AggregateExpr) Type() ValueType

type BinaryExpr

type BinaryExpr struct {
	Op       ItemType // The operation of the expression.
	LHS, RHS Expr     // The operands on the respective sides of the operator.

	// The matching behavior for the operation if both operands are Vectors.
	// If they are not this field is nil.
	VectorMatching *VectorMatching

	// If a comparison operator, return 0/1 rather than filtering.
	ReturnBool bool
}

BinaryExpr represents a binary expression between two child expressions.

func (*BinaryExpr) PositionRange

func (e *BinaryExpr) PositionRange() PositionRange

func (*BinaryExpr) PromQLExpr

func (*BinaryExpr) PromQLExpr()

func (*BinaryExpr) String

func (node *BinaryExpr) String() string

func (*BinaryExpr) Type

func (e *BinaryExpr) Type() ValueType

type Call

type Call struct {
	Func *Function   // The function that was called.
	Args Expressions // Arguments used in the call.

	PosRange PositionRange
}

Call represents a function call.

func (*Call) PositionRange

func (e *Call) PositionRange() PositionRange

func (*Call) PromQLExpr

func (*Call) PromQLExpr()

func (*Call) String

func (node *Call) String() string

func (*Call) Type

func (e *Call) Type() ValueType

type EvalStmt

type EvalStmt struct {
	Expr Expr // Expression to be evaluated.

	// The time boundaries for the evaluation. If Start equals End an instant
	// is evaluated.
	Start, End time.Time
	// Time between two evaluated instants for the range [Start:End].
	Interval time.Duration
}

EvalStmt holds an expression and information on the range it should be evaluated on.

func (*EvalStmt) PositionRange

func (e *EvalStmt) PositionRange() PositionRange

func (*EvalStmt) PromQLStmt

func (*EvalStmt) PromQLStmt()

func (*EvalStmt) String

func (node *EvalStmt) String() string

type Expr

type Expr interface {
	Node

	// Type returns the type the expression evaluates to. It does not perform
	// in-depth checks as this is done at parsing-time.
	Type() ValueType
	// PromQLExpr ensures that no other types accidentally implement the interface.
	PromQLExpr()
}

Expr is a generic interface for all expression types.

func ParseExpr

func ParseExpr(input string) (expr Expr, err error)

ParseExpr returns the expression parsed from the input.

type Expressions

type Expressions []Expr

Expressions is a list of expression nodes that implements Node.

func (Expressions) PositionRange

func (e Expressions) PositionRange() PositionRange

func (Expressions) String

func (es Expressions) String() (s string)

type Function

type Function struct {
	Name       string
	ArgTypes   []ValueType
	Variadic   int
	ReturnType ValueType
}

Function represents a function of the expression language and is used by function nodes.

func MustGetFunction

func MustGetFunction(name string) *Function

type Item

type Item struct {
	Typ ItemType // The type of this Item.
	Pos Pos      // The starting position, in bytes, of this Item in the input string.
	Val string   // The value of this Item.
}

Item represents a token or text string returned from the scanner.

func (*Item) PositionRange

func (i *Item) PositionRange() PositionRange

Item implements the Node interface. This makes it possible to call mergeRanges on them.

func (Item) String

func (i Item) String() string

String returns a descriptive string for the Item.

type ItemType

type ItemType int

func (ItemType) IsAggregator

func (i ItemType) IsAggregator() bool

IsAggregator returns true if the Item belongs to the aggregator functions. Returns false otherwise

func (ItemType) IsAggregatorWithParam

func (i ItemType) IsAggregatorWithParam() bool

IsAggregatorWithParam returns true if the Item is an aggregator that takes a parameter. Returns false otherwise

func (ItemType) IsComparisonOperator

func (i ItemType) IsComparisonOperator() bool

IsComparisonOperator returns true if the Item corresponds to a comparison operator. Returns false otherwise.

func (ItemType) IsKeyword

func (i ItemType) IsKeyword() bool

IsKeyword returns true if the Item corresponds to a keyword. Returns false otherwise.

func (ItemType) IsOperator

func (i ItemType) IsOperator() bool

IsOperator returns true if the Item corresponds to a arithmetic or set operator. Returns false otherwise.

func (ItemType) IsSetOperator

func (i ItemType) IsSetOperator() bool

IsSetOperator returns whether the Item corresponds to a set operator.

func (ItemType) String

func (i ItemType) String() string

type Lexer

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

Lexer holds the state of the scanner.

func Lex

func Lex(input string) *Lexer

Lex creates a new scanner for the input string.

func (*Lexer) NextItem

func (l *Lexer) NextItem(itemp *Item)

NextItem writes the next item to the provided address.

type MatrixSelector

type MatrixSelector struct {
	// It is safe to assume that this is an VectorSelector
	// if the parser hasn't returned an error.
	VectorSelector Expr
	Range          time.Duration

	EndPos Pos
}

MatrixSelector represents a Matrix selection.

func (*MatrixSelector) PositionRange

func (e *MatrixSelector) PositionRange() PositionRange

func (*MatrixSelector) PromQLExpr

func (*MatrixSelector) PromQLExpr()

func (*MatrixSelector) String

func (node *MatrixSelector) String() string

func (*MatrixSelector) Type

func (e *MatrixSelector) Type() ValueType

type Node

type Node interface {
	// String representation of the node that returns the given node when parsed
	// as part of a valid query.
	String() string

	// PositionRange returns the position of the AST Node in the query string.
	PositionRange() PositionRange
}

Node is a generic interface for all nodes in an AST.

Whenever numerous nodes are listed such as in a switch-case statement or a chain of function definitions (e.g. String(), PromQLExpr(), etc.) convention is to list them as follows:

  • Statements
  • statement types (alphabetical)
  • ...
  • Expressions
  • expression types (alphabetical)
  • ...

func Children

func Children(node Node) []Node

Children returns a list of all child nodes of a syntax tree node.

type NumberLiteral

type NumberLiteral struct {
	Val float64

	PosRange PositionRange
}

NumberLiteral represents a number.

func (*NumberLiteral) PositionRange

func (e *NumberLiteral) PositionRange() PositionRange

func (*NumberLiteral) PromQLExpr

func (*NumberLiteral) PromQLExpr()

func (*NumberLiteral) String

func (node *NumberLiteral) String() string

func (*NumberLiteral) Type

func (e *NumberLiteral) Type() ValueType

type ParenExpr

type ParenExpr struct {
	Expr     Expr
	PosRange PositionRange
}

ParenExpr wraps an expression so it cannot be disassembled as a consequence of operator precedence.

func (*ParenExpr) PositionRange

func (e *ParenExpr) PositionRange() PositionRange

func (*ParenExpr) PromQLExpr

func (*ParenExpr) PromQLExpr()

func (*ParenExpr) String

func (node *ParenExpr) String() string

func (*ParenExpr) Type

func (e *ParenExpr) Type() ValueType

type ParseErr

type ParseErr struct {
	PositionRange PositionRange
	Err           error
	Query         string

	// LineOffset is an additional line offset to be added. Only used inside unit tests.
	LineOffset int
}

ParseErr wraps a parsing error with line and position context.

func (*ParseErr) Error

func (e *ParseErr) Error() string

type ParseErrors

type ParseErrors []ParseErr

func (ParseErrors) Error

func (errs ParseErrors) Error() string

Since producing multiple error messages might look weird when combined with error wrapping, only the first error produced by the parser is included in the error string. If getting the full error list is desired, it is recommended to typecast the error returned by the parser to ParseErrors and work with the underlying slice.

type Pos

type Pos int

Pos is the position in a string. Negative numbers indicate undefined positions.

type PositionRange

type PositionRange struct {
	Start Pos
	End   Pos
}

PositionRange describes a position in the input string of the parser.

type SequenceValue

type SequenceValue struct {
	Value   float64
	Omitted bool
}

SequenceValue is an omittable value in a sequence of time series values.

func ParseSeriesDesc

func ParseSeriesDesc(input string) (labels labels.Labels, values []SequenceValue, err error)

ParseSeriesDesc parses the description of a time series.

func (SequenceValue) String

func (v SequenceValue) String() string

type Statement

type Statement interface {
	Node

	// PromQLStmt ensures that no other type accidentally implements the interface
	// nolint:unused
	PromQLStmt()
}

Statement is a generic interface for all statements.

type StepInvariantExpr

type StepInvariantExpr struct {
	Expr Expr
}

StepInvariantExpr represents a query which evaluates to the same result irrespective of the evaluation time given the raw samples from TSDB remain unchanged. Currently this is only used for engine optimisations and the parser does not produce this.

func (*StepInvariantExpr) PositionRange

func (e *StepInvariantExpr) PositionRange() PositionRange

func (*StepInvariantExpr) PromQLExpr

func (*StepInvariantExpr) PromQLExpr()

func (*StepInvariantExpr) String

func (e *StepInvariantExpr) String() string

func (*StepInvariantExpr) Type

func (e *StepInvariantExpr) Type() ValueType

type StringLiteral

type StringLiteral struct {
	Val      string
	PosRange PositionRange
}

StringLiteral represents a string.

func (*StringLiteral) PositionRange

func (e *StringLiteral) PositionRange() PositionRange

func (*StringLiteral) PromQLExpr

func (*StringLiteral) PromQLExpr()

func (*StringLiteral) String

func (node *StringLiteral) String() string

func (*StringLiteral) Type

func (e *StringLiteral) Type() ValueType

type SubqueryExpr

type SubqueryExpr struct {
	Expr  Expr
	Range time.Duration
	// OriginalOffset is the actual offset that was set in the query.
	// This never changes.
	OriginalOffset time.Duration
	// Offset is the offset used during the query execution
	// which is calculated using the original offset, at modifier time,
	// eval time, and subquery offsets in the AST tree.
	Offset     time.Duration
	Timestamp  *int64
	StartOrEnd ItemType // Set when @ is used with start() or end()
	Step       time.Duration

	EndPos Pos
}

SubqueryExpr represents a subquery.

func (*SubqueryExpr) PositionRange

func (e *SubqueryExpr) PositionRange() PositionRange

func (*SubqueryExpr) PromQLExpr

func (*SubqueryExpr) PromQLExpr()

func (*SubqueryExpr) String

func (node *SubqueryExpr) String() string

func (*SubqueryExpr) Type

func (e *SubqueryExpr) Type() ValueType

type TestStmt

type TestStmt func(context.Context) error

TestStmt is an internal helper statement that allows execution of an arbitrary function during handling. It is used to test the Engine.

func (TestStmt) PositionRange

func (TestStmt) PositionRange() PositionRange

func (TestStmt) PromQLStmt

func (TestStmt) PromQLStmt()

func (TestStmt) String

func (TestStmt) String() string

type UnaryExpr

type UnaryExpr struct {
	Op   ItemType
	Expr Expr

	StartPos Pos
}

UnaryExpr represents a unary operation on another expression. Currently unary operations are only supported for Scalars.

func (*UnaryExpr) PositionRange

func (e *UnaryExpr) PositionRange() PositionRange

func (*UnaryExpr) PromQLExpr

func (*UnaryExpr) PromQLExpr()

func (*UnaryExpr) String

func (node *UnaryExpr) String() string

func (*UnaryExpr) Type

func (e *UnaryExpr) Type() ValueType

type Value

type Value interface {
	Type() ValueType
	String() string
}

Value is a generic interface for values resulting from a query evaluation.

type ValueType

type ValueType string

ValueType describes a type of a value.

const (
	ValueTypeNone   ValueType = "none"
	ValueTypeVector ValueType = "vector"
	ValueTypeScalar ValueType = "scalar"
	ValueTypeMatrix ValueType = "matrix"
	ValueTypeString ValueType = "string"
)

The valid value types.

type VectorMatchCardinality

type VectorMatchCardinality int

VectorMatchCardinality describes the cardinality relationship of two Vectors in a binary operation.

const (
	CardOneToOne VectorMatchCardinality = iota
	CardManyToOne
	CardOneToMany
	CardManyToMany
)

func (VectorMatchCardinality) String

func (vmc VectorMatchCardinality) String() string

type VectorMatching

type VectorMatching struct {
	// The cardinality of the two Vectors.
	Card VectorMatchCardinality
	// MatchingLabels contains the labels which define equality of a pair of
	// elements from the Vectors.
	MatchingLabels []string
	// On includes the given label names from matching,
	// rather than excluding them.
	On bool
	// Include contains additional labels that should be included in
	// the result from the side with the lower cardinality.
	Include []string
}

VectorMatching describes how elements from two Vectors in a binary operation are supposed to be matched.

type VectorSelector

type VectorSelector struct {
	Name string
	// OriginalOffset is the actual offset that was set in the query.
	// This never changes.
	OriginalOffset time.Duration
	// Offset is the offset used during the query execution
	// which is calculated using the original offset, at modifier time,
	// eval time, and subquery offsets in the AST tree.
	Offset        time.Duration
	Timestamp     *int64
	StartOrEnd    ItemType // Set when @ is used with start() or end()
	LabelMatchers []*labels.Matcher

	// The unexpanded seriesSet populated at query preparation time.
	UnexpandedSeriesSet storage.SeriesSet
	Series              []storage.Series

	PosRange PositionRange
}

VectorSelector represents a Vector selection.

func (*VectorSelector) PositionRange

func (e *VectorSelector) PositionRange() PositionRange

func (*VectorSelector) PromQLExpr

func (*VectorSelector) PromQLExpr()

func (*VectorSelector) String

func (node *VectorSelector) String() string

func (*VectorSelector) Type

func (e *VectorSelector) Type() ValueType

type Visitor

type Visitor interface {
	Visit(node Node, path []Node) (w Visitor, err error)
}

Visitor allows visiting a Node and its child nodes. The Visit method is invoked for each node with the path leading to the node provided additionally. If the result visitor w is not nil and no error, Walk visits each of the children of node with the visitor w, followed by a call of w.Visit(nil, nil).

Jump to

Keyboard shortcuts

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