stmt

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StateRepoSource represents from state persist repo.
	StateRepoSource = iota + 1
	// StateMachineSource represents from state machine in current memory.
	StateMachineSource
)

Variables

This section is empty.

Functions

func BinaryOPString

func BinaryOPString(op BinaryOP) string

BinaryOPString returns the binary operator's string value

func Marshal

func Marshal(expr Expr) []byte

Marshal returns json of expr using custom json marshal

Types

type BinaryExpr

type BinaryExpr struct {
	Left, Right Expr
	Operator    BinaryOP
}

BinaryExpr represents an operations with two expressions

func (*BinaryExpr) Rewrite

func (e *BinaryExpr) Rewrite() string

Rewrite rewrites the binary expr after parse

type BinaryOP

type BinaryOP int

BinaryOP represents binary operation type

const (
	AND BinaryOP = iota + 1
	OR

	ADD
	SUB
	MUL
	DIV

	UNKNOWN
)

type Broker added in v0.2.4

type Broker struct {
	Type  BrokerOpType
	Value string
}

Broker represent broker statement.

func (*Broker) StatementType added in v0.2.4

func (q *Broker) StatementType() StatementType

StatementType returns broker query type.

type BrokerOpType added in v0.2.4

type BrokerOpType int

BrokerOpType represents broker related operation.

const (
	// BrokerOpUnknown represents unknown operation.
	BrokerOpUnknown BrokerOpType = iota
	// BrokerOpCreate represents create broker.
	BrokerOpCreate
	// BrokerOpShow represent show broker.
	BrokerOpShow
	// BrokerOpDelete represents delete broker.
	BrokerOpDelete
)

type CallExpr

type CallExpr struct {
	FuncType function.FuncType
	Params   []Expr
}

CallExpr represents a function call expression

func (*CallExpr) Rewrite

func (e *CallExpr) Rewrite() string

Rewrite rewrites the call expr after parse

type EqualsExpr

type EqualsExpr struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

EqualsExpr represents an equals expression

func (*EqualsExpr) Rewrite

func (e *EqualsExpr) Rewrite() string

Rewrite rewrites the equals expr after parse

func (*EqualsExpr) TagKey

func (e *EqualsExpr) TagKey() string

TagKey returns the equals filter's tag key

type Expr

type Expr interface {
	// Rewrite rewrites the expr after parse
	Rewrite() string
}

Expr represents a interface for all expression types

func Unmarshal

func Unmarshal(value []byte) (Expr, error)

Unmarshal parses value to expr

type FieldExpr

type FieldExpr struct {
	Name string `json:"name"`
}

FieldExpr represents a field name for select list

func (*FieldExpr) Rewrite

func (e *FieldExpr) Rewrite() string

Rewrite rewrites the field expr after parse

type InExpr

type InExpr struct {
	Key    string   `json:"key"`
	Values []string `json:"values"`
}

InExpr represents an in expression

func (*InExpr) Rewrite

func (e *InExpr) Rewrite() string

Rewrite rewrites the in expr after parse

func (*InExpr) TagKey

func (e *InExpr) TagKey() string

TagKey returns the in filter's tag key

type LikeExpr

type LikeExpr struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

LikeExpr represents a like expression

func (*LikeExpr) Rewrite

func (e *LikeExpr) Rewrite() string

Rewrite rewrites the like expr after parse

func (*LikeExpr) TagKey

func (e *LikeExpr) TagKey() string

TagKey returns the like filter's tag key

type Limit added in v0.2.4

type Limit struct {
	Type  LimitOpType
	Limit string
}

Limit represents limit statement.

func (*Limit) StatementType added in v0.2.4

func (q *Limit) StatementType() StatementType

StatementType returns limit type.

type LimitOpType added in v0.2.4

type LimitOpType int
const (
	SetLimit LimitOpType = iota + 1
	ShowLimit
)

type Metadata

type Metadata struct {
	MetadataType MetadataType
	Type         string     // root/broker/master/storage will be used.
	Source       SourceType // source(from state repo or state manager).
	ClusterName  string     // storage/broker will be used.
}

Metadata represent show metadata lin query language.

func (*Metadata) StatementType

func (m *Metadata) StatementType() StatementType

StatementType returns metadata lin query language statement type.

type MetadataType

type MetadataType int

MetadataType represents metadata type.

const (
	// MetadataTypes represents all metadata types.
	MetadataTypes MetadataType = iota + 1
	// BrokerMetadata represent broker metadata.
	BrokerMetadata
	// MasterMetadata represent master metadata.
	MasterMetadata
	// StorageMetadata represent storage metadata.
	StorageMetadata
	// RootMetadata represent root metadata.
	RootMetadata
)

type MetricMetadata

type MetricMetadata struct {
	Namespace  string             // namespace
	MetricName string             // like table name
	Type       MetricMetadataType // metadata suggest type
	TagKey     string
	Prefix     string
	Condition  Expr // tag filter condition expression
	Limit      int  // result set limit
}

MetricMetadata represents search metric metadata statement

func (*MetricMetadata) MarshalJSON

func (q *MetricMetadata) MarshalJSON() ([]byte, error)

MarshalJSON returns json data of query

func (*MetricMetadata) StatementType

func (q *MetricMetadata) StatementType() StatementType

StatementType returns metadata query type.

func (*MetricMetadata) UnmarshalJSON

func (q *MetricMetadata) UnmarshalJSON(value []byte) error

UnmarshalJSON parses json data to metadata

type MetricMetadataType

type MetricMetadataType uint8

MetricMetadataType represents metric metadata suggest type

const (
	Namespace MetricMetadataType = iota + 1
	Metric
	TagKey
	TagValue
	Field
)

Defines all types of metric metadata suggest

func (MetricMetadataType) String

func (m MetricMetadataType) String() string

String returns string value of metadata type

type NotExpr

type NotExpr struct {
	Expr Expr
}

NotExpr represents a not expression

func (*NotExpr) Rewrite

func (e *NotExpr) Rewrite() string

Rewrite rewrites the not expr after parse

type NumberLiteral

type NumberLiteral struct {
	Val float64 `json:"val"`
}

NumberLiteral represents a number.

func (*NumberLiteral) Rewrite

func (e *NumberLiteral) Rewrite() string

Rewrite rewrites the number literal after parse

type OrderByExpr

type OrderByExpr struct {
	Expr Expr // support field name/function for select field item.
	Desc bool
}

OrderByExpr represents order by expr item.

func (*OrderByExpr) Rewrite

func (e *OrderByExpr) Rewrite() string

Rewrite rewrites the order by expr after parse

type ParenExpr

type ParenExpr struct {
	Expr Expr
}

ParenExpr represents a parenthesized expression

func (*ParenExpr) Rewrite

func (e *ParenExpr) Rewrite() string

Rewrite rewrites the paren expr after parse

type Query

type Query struct {
	Explain     bool   // need explain query execute stat
	Namespace   string // namespace
	MetricName  string // like table name
	SelectItems []Expr // select list, such as field, function call, math expression etc.
	AllFields   bool   // select all fields under metric
	Condition   Expr   // tag filter condition expression

	// broker plan maybe reset
	TimeRange       timeutil.TimeRange // query time range
	Interval        timeutil.Interval  // down sampling storage interval
	StorageInterval timeutil.Interval  // down sampling storage interval, data find
	IntervalRatio   int                // down sampling interval ratio(query interval/storage Interval)
	AutoGroupByTime bool               // auto fix group by interval based on query time range

	GroupBy      []string // group by tag keys
	OrderByItems []Expr   // order by field expr list
	Limit        int      // num. of time series list for result
}

Query represents search statement

func (*Query) HasGroupBy

func (q *Query) HasGroupBy() bool

HasGroupBy returns whether query has grouping tag keys

func (*Query) MarshalJSON

func (q *Query) MarshalJSON() ([]byte, error)

MarshalJSON returns json data of query

func (*Query) StatementType

func (q *Query) StatementType() StatementType

StatementType returns metric query type.

func (*Query) UnmarshalJSON

func (q *Query) UnmarshalJSON(value []byte) error

UnmarshalJSON parses json data to query

type RegexExpr

type RegexExpr struct {
	Key    string `json:"key"`
	Regexp string `json:"regexp"`
}

RegexExpr represents a regular expression

func (*RegexExpr) Rewrite

func (e *RegexExpr) Rewrite() string

Rewrite rewrites the regex expr after parse

func (*RegexExpr) TagKey

func (e *RegexExpr) TagKey() string

TagKey returns the regex filter's tag key

type Request

type Request struct {
	RequestID string
}

Request represents show request statement.

func (*Request) StatementType

func (q *Request) StatementType() StatementType

StatementType returns request statement type.

type Schema

type Schema struct {
	Type SchemaType
	// create stmt: value is database json config.
	// drop stmt: value is database name.
	Value string
}

Schema represents show all database schemas statement.

func (*Schema) StatementType

func (q *Schema) StatementType() StatementType

StatementType returns schema query type.

type SchemaType

type SchemaType int
const (
	DatabaseNameSchemaType SchemaType = iota + 1
	DatabaseSchemaType
	CreateDatabaseSchemaType
	DropDatabaseSchemaType
)

type SelectItem

type SelectItem struct {
	Expr  Expr
	Alias string
}

SelectItem represents a select item from select statement

func (*SelectItem) Rewrite

func (e *SelectItem) Rewrite() string

Rewrite rewrites the select item expr after parse

type SourceType

type SourceType int

SourceType represents metadata source.

type State

type State struct {
	Type        StateType
	StorageName string
	Database    string

	MetricNames []string
}

State represents show state statement.

func (*State) StatementType

func (q *State) StatementType() StatementType

StatementType returns state query type.

type StateType

type StateType uint8

StateType represents state statement type.

const (
	// Master represents show master statement.
	Master StateType = iota + 1
	// RootAlive represents show root alive(node)  statement.
	RootAlive
	// BrokerAlive represents show broker alive(node)  statement.
	BrokerAlive
	// StorageAlive represents show storage alive(node) statement.
	StorageAlive
	// Replication represents show replication statement.
	Replication
	// RootMetric represents show current root's metric statement
	RootMetric
	// BrokerMetric represents show current broker's metric statement
	BrokerMetric
	// StorageMetric represents show current storage's metric statement
	StorageMetric
	// MemoryDatabase represents show memory database statement.
	MemoryDatabase
)

type Statement

type Statement interface {
	// StatementType returns statement type.
	StatementType() StatementType
}

Statement represents LinDB query language statement

type StatementType

type StatementType int
const (
	UseStatement StatementType = iota + 1
	MetadataStatement
	SchemaStatement
	StorageStatement
	StateStatement
	MetricMetadataStatement
	QueryStatement
	RequestStatement
	BrokerStatement
	LimitStatement
)

type Storage

type Storage struct {
	Type  StorageOpType
	Value string
}

Storage represent storage statement.

func (*Storage) StatementType

func (q *Storage) StatementType() StatementType

StatementType returns storage query type.

type StorageOpType

type StorageOpType int

StorageOpType represents storage related operation.

const (
	// StorageOpUnknown represents unknown operation.
	StorageOpUnknown StorageOpType = iota
	// StorageOpCreate represents create storage.
	StorageOpCreate
	// StorageOpShow represent show storage.
	StorageOpShow
	// StorageOpDelete represents delete storage.
	StorageOpDelete
	// StorageOpRecover represents recover storage metadata.
	StorageOpRecover
)

type TagFilter

type TagFilter interface {
	Expr
	// TagKey returns the filter's tag key
	TagKey() string
}

TagFilter represents tag filter for searching time series

type Use

type Use struct {
	Name string
}

Use represents use statement.

func (*Use) StatementType

func (q *Use) StatementType() StatementType

StatementType returns use query type.

Jump to

Keyboard shortcuts

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