logical

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Apache Software Foundation (ASF) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Apache Software Foundation (ASF) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Apache Software Foundation (ASF) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Apache Software Foundation (ASF) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTagNotDefined              = errors.New("tag is not defined")
	ErrFieldNotDefined            = errors.New("field is not defined")
	ErrInvalidConditionType       = errors.New("invalid pair 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")
)
View Source
var (
	DefaultLimit uint32 = 100
)
View Source
var ErrInvalidData = errors.New("data is invalid")

Functions

func Format

func Format(p Plan) string

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

Types

type ComparableExpr

type ComparableExpr interface {
	Expr
	Compare(tagValue *modelv1.TagValue) (int, bool)
	BelongTo(tagValue *modelv1.TagValue) bool
}

type Expr

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

func Eq

func Eq(l, r Expr) Expr

func Ge

func Ge(l, r Expr) Expr

func Gt

func Gt(l, r Expr) Expr

func Having

func Having(l, r Expr) Expr

func ID

func ID(id string) Expr

func Int

func Int(num int64) Expr

func Ints

func Ints(ints ...int64) Expr

func Le

func Le(l, r Expr) Expr

func Lt

func Lt(l, r Expr) Expr

func Ne

func Ne(l, r Expr) Expr

func NotHaving

func NotHaving(l, r Expr) Expr

func Str

func Str(str string) Expr

func Strs

func Strs(strs ...string) Expr

type Field

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

func NewField

func NewField(name string) *Field

type FieldRef

type FieldRef struct {

	// spec contains the index of the key in the measureSchema, as well as the underlying FieldSpec
	Spec *fieldSpec
	// contains filtered or unexported fields
}

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 ItemIterator

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

func NewItemIter

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

type LiteralExpr

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

type MeasureAnalyzer

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

func CreateMeasureAnalyzerFromMetaService

func CreateMeasureAnalyzerFromMetaService(metaSvc metadata.Service) (*MeasureAnalyzer, error)

func (*MeasureAnalyzer) Analyze

func (a *MeasureAnalyzer) Analyze(_ context.Context, criteria *measurev1.QueryRequest, metadata *commonv1.Metadata, s Schema) (Plan, error)

func (*MeasureAnalyzer) BuildMeasureSchema

func (a *MeasureAnalyzer) BuildMeasureSchema(ctx context.Context, metadata *commonv1.Metadata) (Schema, error)

type Plan

type Plan interface {
	fmt.Stringer
	Type() PlanType
	Equal(Plan) bool
	Children() []Plan
	Schema() Schema
}

func NewTagFilter

func NewTagFilter(s Schema, parent Plan, tagFilters []*binaryExpr) Plan

type PlanType

type PlanType uint8
const (
	PlanLimit PlanType = iota
	PlanOffset
	PlanLocalIndexScan
	PlanGlobalIndexScan
	PlanGroupBy
	PlanAggregation
	PlanTop
	PlanTagFilter
)

type ResolvableExpr

type ResolvableExpr interface {
	Expr
	Resolve(Schema) error
}

type Schema

type Schema interface {
	Scope() tsdb.Entry
	EntityList() []string
	IndexDefined(*Tag) (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 StreamAnalyzer

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

func CreateStreamAnalyzerFromMetaService

func CreateStreamAnalyzerFromMetaService(metaSvc metadata.Service) (*StreamAnalyzer, error)

func (*StreamAnalyzer) Analyze

func (a *StreamAnalyzer) Analyze(_ context.Context, criteria *streamv1.QueryRequest, metadata *commonv1.Metadata, s Schema) (Plan, error)

func (*StreamAnalyzer) BuildStreamSchema

func (a *StreamAnalyzer) BuildStreamSchema(ctx context.Context, metadata *commonv1.Metadata) (Schema, error)

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 TagRef

type TagRef struct {

	// spec contains the index of the key in the streamSchema/measureSchema, as well as the underlying tagSpec
	Spec *tagSpec
	// contains filtered or unexported fields
}

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 TopElement

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

func NewTopElement

func NewTopElement(dp *measurev1.DataPoint, value int64) TopElement

func (TopElement) Val

func (e TopElement) Val() int64

type TopQueue

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

func NewTopQueue

func NewTopQueue(n int, reverted bool) *TopQueue

func (*TopQueue) Elements

func (s *TopQueue) Elements() []TopElement

func (*TopQueue) Equal

func (s *TopQueue) Equal(other *TopQueue) bool

func (*TopQueue) Insert

func (s *TopQueue) Insert(element TopElement) bool

func (*TopQueue) Purge

func (s *TopQueue) Purge()

func (TopQueue) String

func (s TopQueue) String() string

type UnresolvedOrderBy

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

func OrderBy

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

type UnresolvedPlan

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

func Aggregation

func Aggregation(input UnresolvedPlan, aggrField *Field, aggrFunc modelv1.AggregationFunction, isGroup bool) UnresolvedPlan

func GlobalIndexScan

func GlobalIndexScan(metadata *commonv1.Metadata, conditions []Expr, projection ...[]*Tag) UnresolvedPlan

GlobalIndexScan is a short-handed method for composing a globalIndexScan plan

func GroupBy

func GroupBy(input UnresolvedPlan, groupBy [][]*Tag, groupByEntity bool) UnresolvedPlan

func Limit

func Limit(input UnresolvedPlan, num uint32) UnresolvedPlan

func MeasureIndexScan

func MeasureIndexScan(startTime, endTime time.Time, metadata *commonv1.Metadata, conditions []Expr, entity tsdb.Entity,
	projectionTags [][]*Tag, projectionFields []*Field, groupByEntity bool, unresolvedOrderBy *UnresolvedOrderBy) UnresolvedPlan

func MeasureLimit

func MeasureLimit(input UnresolvedPlan, offset, limit uint32) UnresolvedPlan

func Offset

func Offset(input UnresolvedPlan, num uint32) UnresolvedPlan

func TagFilter

func TagFilter(startTime, endTime time.Time, metadata *commonv1.Metadata, conditions []Expr, entity tsdb.Entity,
	orderBy *UnresolvedOrderBy, projection ...[]*Tag) UnresolvedPlan

Jump to

Keyboard shortcuts

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