logical

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTagNotDefined              = errors.New("tag is not defined")
	ErrFieldNotDefined            = errors.New("field is not defined")
	ErrUnsupportedConditionOp     = errors.New("unsupported condition operation")
	ErrUnsupportedConditionValue  = errors.New("unsupported condition value type")
	ErrInvalidCriteriaType        = errors.New("invalid criteria type")
	ErrIncompatibleQueryCondition = errors.New("incompatible query condition type")
	ErrIndexNotDefined            = errors.New("index is not define for the tag")
	ErrMultipleGlobalIndexes      = errors.New("multiple global indexes are not supported")
	ErrInvalidData                = errors.New("data is invalid")
)
View Source
var (
	ErrNotRangeOperation        = errors.New("this is not an range operation")
	ErrEmptyTree                = errors.New("tree is empty")
	ErrInvalidLogicalExpression = errors.New("invalid logical expression")
)
View Source
var BypassFilter = new(emptyFilter)
View Source
var DefaultLimit uint32 = 20
View Source
var ErrUnsupportedLogicalOperation = errors.New("unsupported logical operation")

Functions

func BuildLocalFilter added in v0.2.0

func BuildLocalFilter(criteria *model_v1.Criteria, schema Schema, entityDict map[string]int, entity tsdb.Entity) (index.Filter, []tsdb.Entity, error)

func ExecuteForShard added in v0.2.0

func ExecuteForShard(series tsdb.SeriesList, timeRange timestamp.TimeRange,
	builders ...SeekerBuilder,
) ([]tsdb.Iterator, []io.Closer, error)

ExecuteForShard fetches elements from series within a single shard. A list of series must be prepared in advanced with the help of Entity. The result is a list of element set, where the order of inner list is kept as what the users specify in the seekerBuilder. This method is used by the underlying tableScan and localIndexScan plans.

func Format

func Format(p Plan) string

func FormatTagRefs added in v0.2.0

func FormatTagRefs(sep string, exprGroup ...[]*TagRef) string

func ProjectItem added in v0.2.0

func ProjectItem(ec executor.ExecutionContext, item tsdb.Item, projectionFieldRefs [][]*TagRef) ([]*modelv1.TagFamily, error)

ProjectItem parses the item within the StreamExecutionContext. projectionFieldRefs must be prepared before calling this method, projectionFieldRefs should be a list of tag list where the inner list must exist in the same tag family. Strict order can be guaranteed in the result.

func SortedByIndex

func SortedByIndex(elements []*streamv1.Element, tagFamilyIdx, tagIdx int, sortDirection modelv1.Sort) bool

SortedByIndex is used to test whether the given entities are sorted by the sortDirection The given entities MUST satisfy both the positive check and the negative check for the reversed direction

func SortedByTimestamp

func SortedByTimestamp(elements []*streamv1.Element, sortDirection modelv1.Sort) bool

func StringSlicesEqual added in v0.2.0

func StringSlicesEqual(a, b []string) bool

Types

type CommonSchema added in v0.2.0

type CommonSchema struct {
	Group      *commonv1.Group
	IndexRules []*databasev1.IndexRule
	TagMap     map[string]*TagSpec
	EntityList []string
}

func (*CommonSchema) CreateRef added in v0.2.0

func (cs *CommonSchema) CreateRef(tags ...[]*Tag) ([][]*TagRef, error)

CreateRef create TagRef to the given tags. The family name of the tag is actually not used since the uniqueness of the tag names can be guaranteed across families.

func (*CommonSchema) IndexDefined added in v0.2.0

func (cs *CommonSchema) IndexDefined(tagName string) (bool, *databasev1.IndexRule)

IndexDefined checks whether the field given is indexed

func (*CommonSchema) IndexRuleDefined added in v0.2.0

func (cs *CommonSchema) IndexRuleDefined(indexRuleName string) (bool, *databasev1.IndexRule)

func (*CommonSchema) ProjTags added in v0.2.0

func (cs *CommonSchema) ProjTags(refs ...[]*TagRef) *CommonSchema

func (*CommonSchema) RegisterTag added in v0.2.0

func (cs *CommonSchema) RegisterTag(tagFamilyIdx, tagIdx int, spec *databasev1.TagSpec)

registerTag registers the tag spec with given tagFamilyName, tagName and indexes.

func (*CommonSchema) ShardNumber added in v0.2.0

func (cs *CommonSchema) ShardNumber() uint32

type ComparableExpr

type ComparableExpr interface {
	LiteralExpr
	Compare(LiteralExpr) (int, bool)
	BelongTo(LiteralExpr) bool
	Contains(LiteralExpr) bool
}

type Comparator added in v0.2.0

type Comparator func(a, b tsdb.Item) bool

func CreateComparator added in v0.2.0

func CreateComparator(sortDirection modelv1.Sort) Comparator

type Expr

type Expr interface {
	fmt.Stringer
	DataType() int32
	Equal(Expr) bool
}

func Int

func Int(num int64) Expr

func Ints

func Ints(ints ...int64) Expr

func Strs

func Strs(strs ...string) Expr

type Field

type Field struct {
	Name string
}

func NewField

func NewField(name string) *Field

type FieldKey added in v0.2.0

type FieldKey struct {
	*database_v1.IndexRule
}

func (FieldKey) ToIndex added in v0.2.0

func (fk FieldKey) ToIndex(seriesID common.SeriesID) index.FieldKey

type FieldRef

type FieldRef struct {
	// Field defines the name of the Field
	Field *Field
	// spec contains the index of the key in the measureSchema, as well as the underlying FieldSpec
	Spec *FieldSpec
}

FieldRef is the reference to the field also it holds the definition (derived from measureSchema) of the field

func (*FieldRef) DataType

func (f *FieldRef) DataType() int32

func (*FieldRef) Equal

func (f *FieldRef) Equal(expr Expr) bool

func (*FieldRef) Resolve

func (f *FieldRef) Resolve(s Schema) error

func (*FieldRef) String

func (f *FieldRef) String() string

type FieldSpec added in v0.2.0

type FieldSpec struct {
	FieldIdx int
	Spec     *databasev1.FieldSpec
}

type GlobalIndexError added in v0.2.0

type GlobalIndexError struct {
	IndexRule *database_v1.IndexRule
	Expr      LiteralExpr
}

func (*GlobalIndexError) Error added in v0.2.0

func (g *GlobalIndexError) Error() string

type ItemIterator

type ItemIterator interface {
	HasNext() bool
	Next() tsdb.Item
}

func NewItemIter

func NewItemIter(iters []tsdb.Iterator, c Comparator) ItemIterator

type Limit

type Limit struct {
	*Parent
	LimitNum uint32
}

func (*Limit) Analyze added in v0.2.0

func (l *Limit) Analyze(s Schema) (Plan, error)

func (*Limit) Children added in v0.2.0

func (l *Limit) Children() []Plan

func (*Limit) Execute added in v0.2.0

func (*Limit) Schema added in v0.2.0

func (l *Limit) Schema() Schema

func (*Limit) String added in v0.2.0

func (l *Limit) String() string

type LiteralExpr

type LiteralExpr interface {
	Expr
	Bytes() [][]byte
}

func ID

func ID(id string) LiteralExpr

func Str

func Str(str string) LiteralExpr

type Offset

type Offset struct {
	*Parent
	// contains filtered or unexported fields
}

func (*Offset) Analyze added in v0.2.0

func (l *Offset) Analyze(s Schema) (Plan, error)

func (*Offset) Children added in v0.2.0

func (l *Offset) Children() []Plan

func (*Offset) Execute added in v0.2.0

func (*Offset) Schema added in v0.2.0

func (l *Offset) Schema() Schema

func (*Offset) String added in v0.2.0

func (l *Offset) String() string

type OrderBy

type OrderBy struct {
	// orderByIndex describes the indexRule used to sort the elements/
	// It can be null since by default we may sort by created-time.
	Index *databasev1.IndexRule
	// while orderBySort describes the Sort direction
	Sort modelv1.Sort
	// contains filtered or unexported fields
}

func (*OrderBy) Equal added in v0.2.0

func (o *OrderBy) Equal(other interface{}) bool

func (*OrderBy) String added in v0.2.0

func (o *OrderBy) String() string

type Parent added in v0.2.0

type Parent struct {
	UnresolvedInput UnresolvedPlan
	Input           Plan
}

type Plan

type Plan interface {
	fmt.Stringer
	Children() []Plan
	Schema() Schema
}

type RangeOpts added in v0.2.0

type RangeOpts struct {
	Upper         ComparableExpr
	Lower         ComparableExpr
	IncludesUpper bool
	IncludesLower bool
}

type ResolvableExpr

type ResolvableExpr interface {
	Expr
	Resolve(Schema) error
}

type Schema

type Schema interface {
	Scope() tsdb.Entry
	EntityList() []string
	IndexDefined(tagName string) (bool, *databasev1.IndexRule)
	IndexRuleDefined(string) (bool, *databasev1.IndexRule)
	CreateTagRef(tags ...[]*Tag) ([][]*TagRef, error)
	CreateFieldRef(fields ...*Field) ([]*FieldRef, error)
	ProjTags(refs ...[]*TagRef) Schema
	ProjFields(refs ...*FieldRef) Schema
	Equal(Schema) bool
	ShardNumber() uint32
	TraceIDFieldName() string
}

type SeekerBuilder added in v0.2.0

type SeekerBuilder func(builder tsdb.SeekerBuilder)

type Tag

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

func NewTag

func NewTag(family, name string) *Tag

func NewTags

func NewTags(family string, tagNames ...string) []*Tag

NewTags create an array of Tag within a TagFamily

func (*Tag) GetCompoundName

func (t *Tag) GetCompoundName() string

GetCompoundName is only used for error message

func (*Tag) GetFamilyName

func (t *Tag) GetFamilyName() string

func (*Tag) GetTagName

func (t *Tag) GetTagName() string

type TagFilter

type TagFilter interface {
	fmt.Stringer
	Match(tagFamilies []*model_v1.TagFamily) (bool, error)
}

func BuildTagFilter added in v0.2.0

func BuildTagFilter(criteria *model_v1.Criteria, entityDict map[string]int, schema Schema, hasGlobalIndex bool) (TagFilter, error)

type TagRef

type TagRef struct {
	// Tag defines the family name and name of the Tag
	Tag *Tag
	// spec contains the index of the key in the streamSchema/measureSchema, as well as the underlying tagSpec
	Spec *TagSpec
}

TagRef is the reference to the field also it holds the definition (derived from the streamSchema, measureSchema) of the tag

func NewSearchableTagRef

func NewSearchableTagRef(tagName string) *TagRef

NewSearchableTagRef is a short-handed method for creating a TagRef to the tag in the searchable family

func NewTagRef

func NewTagRef(familyName, tagName string) *TagRef

func (*TagRef) DataType

func (f *TagRef) DataType() int32

func (*TagRef) Equal

func (f *TagRef) Equal(expr Expr) bool

func (*TagRef) Resolve

func (f *TagRef) Resolve(s Schema) error

func (*TagRef) String

func (f *TagRef) String() string

type TagSpec added in v0.2.0

type TagSpec struct {
	// Idx is defined as
	// 1) the field index based on the (stream/measure) schema for the underlying plans which
	//    directly interact with the database and index modules,
	// 2) the projection index given by the users for those plans which can only access the data from parent plans,
	//    e.g. orderBy plan uses this projection index to access the data entities (normally a projection view)
	//    from the parent plan.
	TagFamilyIdx int
	TagIdx       int
	Spec         *databasev1.TagSpec
}

func (*TagSpec) Equal added in v0.2.0

func (fs *TagSpec) Equal(other *TagSpec) bool

type UnresolvedOrderBy

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

func NewOrderBy added in v0.2.0

func NewOrderBy(indexRuleName string, sort modelv1.Sort) *UnresolvedOrderBy

func (*UnresolvedOrderBy) Analyze added in v0.2.0

func (u *UnresolvedOrderBy) Analyze(s Schema) (*OrderBy, error)

type UnresolvedPlan

type UnresolvedPlan interface {
	Analyze(Schema) (Plan, error)
}

func NewLimit added in v0.2.0

func NewLimit(input UnresolvedPlan, num uint32) UnresolvedPlan

func NewOffset added in v0.2.0

func NewOffset(input UnresolvedPlan, num uint32) UnresolvedPlan

Directories

Path Synopsis
Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements.
Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements.

Jump to

Keyboard shortcuts

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