Documentation
¶
Overview ¶
Package logical implements the executable operations. It also provides Analyzers to parse logical expressions to operations, and wire them to executable tree or execution plan.
Index ¶
- Variables
- func ApplyRules(plan Plan, rules ...OptimizeRule) error
- func FormatTagRefs(sep string, exprGroup ...[]*TagRef) string
- func ParseEntities(op modelv1.LogicalExpression_LogicalOp, input []*modelv1.TagValue, ...) [][]*modelv1.TagValue
- func StringSlicesEqual(a, b []string) bool
- func ToTags(projection *modelv1.TagProjection) [][]*Tag
- type BytesLiteral
- type CommonSchema
- func (cs *CommonSchema) CreateRef(tags ...[]*Tag) ([][]*TagRef, error)
- func (cs *CommonSchema) IndexDefined(tagName string) (bool, *databasev1.IndexRule)
- func (cs *CommonSchema) IndexRuleDefined(indexRuleName string) (bool, *databasev1.IndexRule)
- func (cs *CommonSchema) ProjTags(refs ...[]*TagRef) *CommonSchema
- type ComparableExpr
- type Expr
- type Field
- type FieldRef
- type FieldSpec
- type IndexChecker
- type LiteralExpr
- type OptimizeRule
- type OrderBy
- type Parent
- type Plan
- type PushDownMaxSize
- type PushDownOrder
- type Schema
- type Sorter
- type Tag
- type TagFamilies
- type TagFamiliesForWrite
- type TagFilter
- type TagRef
- type TagSpec
- type TagSpecMap
- type TagSpecRegistry
- type TagValueIndexAccessor
- type UnresolvedPlan
- type VolumeLimiter
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedConditionOp indicates an unsupported condition operation. ErrUnsupportedConditionOp = errors.New("unsupported condition operation") // ErrUnsupportedConditionValue indicates an unsupported condition value type. ErrUnsupportedConditionValue = errors.New("unsupported condition value type") // ErrInvalidCriteriaType indicates an invalid criteria type. ErrInvalidCriteriaType = errors.New("invalid criteria type") // ErrInvalidLogicalExpression indicates an invalid logical expression. ErrInvalidLogicalExpression = errors.New("invalid logical expression") )
var DummyFilter = new(dummyTagFilter)
DummyFilter matches any predicate.
Functions ¶
func ApplyRules ¶ added in v0.3.0
func ApplyRules(plan Plan, rules ...OptimizeRule) error
ApplyRules apply OptimizeRules to a Plan.
func FormatTagRefs ¶ added in v0.2.0
FormatTagRefs outputs formatted tag refs.
func ParseEntities ¶ added in v0.7.0
func ParseEntities(op modelv1.LogicalExpression_LogicalOp, input []*modelv1.TagValue, left, right [][]*modelv1.TagValue) [][]*modelv1.TagValue
ParseEntities merges entities based on the logical operation.
func StringSlicesEqual ¶ added in v0.2.0
StringSlicesEqual reports whether a and b are the same length and contain the same strings. A nil argument is equivalent to an empty slice.
func ToTags ¶ added in v0.3.0
func ToTags(projection *modelv1.TagProjection) [][]*Tag
ToTags converts a projection spec to Tag sets.
Types ¶
type BytesLiteral ¶ added in v0.7.0
type BytesLiteral struct {
// contains filtered or unexported fields
}
BytesLiteral represents a wrapper for a slice of bytes.
func NewBytesLiteral ¶ added in v0.7.0
func NewBytesLiteral(bb []byte) *BytesLiteral
NewBytesLiteral creates a new instance of BytesLiteral with the provided slice of bytes.
func (*BytesLiteral) Bytes ¶ added in v0.7.0
func (b *BytesLiteral) Bytes() [][]byte
Bytes returns a 2D slice of bytes where the inner slice contains the byte slice stored in the BytesLiteral.
func (*BytesLiteral) DataType ¶ added in v0.7.0
func (b *BytesLiteral) DataType() int32
DataType returns the data type of BytesLiteral.
func (*BytesLiteral) Elements ¶ added in v0.7.0
func (b *BytesLiteral) Elements() []string
Elements returns a slice containing the string representation of the byte slice.
func (*BytesLiteral) Equal ¶ added in v0.7.0
func (b *BytesLiteral) Equal(expr Expr) bool
Equal checks if the current BytesLiteral is equal to the provided Expr.
func (*BytesLiteral) String ¶ added in v0.7.0
func (b *BytesLiteral) String() string
String converts the BytesLiteral's slice of bytes to a string representation.
type CommonSchema ¶ added in v0.2.0
type CommonSchema struct {
TagSpecMap
IndexRules []*databasev1.IndexRule
EntityList []string
}
CommonSchema represents a sharable fields between independent schemas. It provides common access methods at the same time.
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)
IndexRuleDefined return the IndexRule by its name.
func (*CommonSchema) ProjTags ¶ added in v0.2.0
func (cs *CommonSchema) ProjTags(refs ...[]*TagRef) *CommonSchema
ProjTags inits a dictionary for getting TagSpec by tag's name.
type ComparableExpr ¶
type ComparableExpr interface {
LiteralExpr
Compare(LiteralExpr) (int, bool)
BelongTo(LiteralExpr) bool
Contains(LiteralExpr) bool
}
ComparableExpr allows comparing Expr and Expr arrays.
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) Elements ¶ added in v0.7.0
Elements returns a slice containing the string representation of FieldRef.
type FieldSpec ¶ added in v0.2.0
type FieldSpec struct {
Spec *databasev1.FieldSpec
FieldIdx int
}
FieldSpec is the reference to the field. It also holds the definition of the field.
type IndexChecker ¶ added in v0.3.0
type IndexChecker interface {
IndexDefined(tagName string) (bool, *databasev1.IndexRule)
IndexRuleDefined(ruleName string) (bool, *databasev1.IndexRule)
}
IndexChecker allows checking the existence of a specific index rule.
type LiteralExpr ¶
LiteralExpr allows getting raw data represented as bytes.
type OptimizeRule ¶ added in v0.3.0
OptimizeRule allows optimizing a Plan based on a rule.
type OrderBy ¶
type OrderBy struct {
Index *databasev1.IndexRule
Sort modelv1.Sort
// contains filtered or unexported fields
}
OrderBy is the sorting operator.
func ParseOrderBy ¶ added in v0.3.0
ParseOrderBy parses an OrderBy from a Schema.
type Parent ¶ added in v0.2.0
type Parent struct {
UnresolvedInput UnresolvedPlan
Input Plan
}
Parent refers to a parent node in the execution tree(plan).
type PushDownMaxSize ¶ added in v0.3.0
type PushDownMaxSize struct {
// contains filtered or unexported fields
}
PushDownMaxSize pushes down the max volume to a Plan.
func NewPushDownMaxSize ¶ added in v0.3.0
func NewPushDownMaxSize(maxVal int) PushDownMaxSize
NewPushDownMaxSize returns a new PushDownMaxSize.
type PushDownOrder ¶ added in v0.3.0
type PushDownOrder struct {
// contains filtered or unexported fields
}
PushDownOrder pushes down the order to a Plan.
func NewPushDownOrder ¶ added in v0.3.0
func NewPushDownOrder(order *modelv1.QueryOrder) PushDownOrder
NewPushDownOrder returns a new PushDownOrder.
type Schema ¶
type Schema interface {
TagSpecRegistry
IndexChecker
EntityList() []string
CreateTagRef(tags ...[]*Tag) ([][]*TagRef, error)
CreateFieldRef(fields ...*Field) ([]*FieldRef, error)
ProjTags(refs ...[]*TagRef) Schema
ProjFields(refs ...*FieldRef) Schema
Equal(Schema) bool
}
Schema allows retrieving schemas in a convenient way.
type Tag ¶
type Tag struct {
// contains filtered or unexported fields
}
Tag represents the combination of tag family and tag name. It's a tag's identity.
func (*Tag) GetCompoundName ¶
GetCompoundName is only used for error message.
func (*Tag) GetFamilyName ¶
GetFamilyName returns the tag family name.
type TagFamilies ¶ added in v0.3.0
TagFamilies wraps a slice of TagFamily.
func (TagFamilies) GetTagValue ¶ added in v0.3.0
func (tfs TagFamilies) GetTagValue(tagFamilyIdx, tagIdx int) *modelv1.TagValue
GetTagValue gets TagValue from the underlying TagFamily slice.
type TagFamiliesForWrite ¶ added in v0.3.0
type TagFamiliesForWrite []*modelv1.TagFamilyForWrite
TagFamiliesForWrite wraps a slice of TagFamilyForWrite.
func (TagFamiliesForWrite) GetTagValue ¶ added in v0.3.0
func (tffws TagFamiliesForWrite) GetTagValue(tagFamilyIdx, tagIdx int) *modelv1.TagValue
GetTagValue gets TagValue from the underlying TagFamilyForWrite slice.
type TagFilter ¶
type TagFilter interface {
fmt.Stringer
Match(accessor TagValueIndexAccessor, registry TagSpecRegistry) (bool, error)
}
TagFilter allows matching a tag based on a predicate.
func BuildSimpleTagFilter ¶ added in v0.3.0
BuildSimpleTagFilter returns a TagFilter without any local-index, global index, sharding key support.
func BuildTagFilter ¶ added in v0.2.0
func BuildTagFilter(criteria *modelv1.Criteria, entityDict map[string]int, indexChecker IndexChecker, hasGlobalIndex bool) (TagFilter, error)
BuildTagFilter returns a TagFilter if predicates doesn't match any indices.
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 tag also it holds the definition (derived from the streamSchema, measureSchema) of the tag.
func NewSearchableTagRef ¶
NewSearchableTagRef is a short-handed method for creating a TagRef to the tag in the searchable family.
func (*TagRef) Elements ¶ added in v0.7.0
Elements returns a slice containing the string representation of TagRef.
type TagSpec ¶ added in v0.2.0
type TagSpec struct {
Spec *databasev1.TagSpec
TagFamilyIdx int
TagIdx int
}
TagSpec wraps offsets to access a tag in the raw data swiftly.
type TagSpecMap ¶ added in v0.3.0
TagSpecMap is a map of TapSpec implements TagSpecRegistry.
func (TagSpecMap) FindTagSpecByName ¶ added in v0.3.0
func (tagSpecMap TagSpecMap) FindTagSpecByName(name string) *TagSpec
FindTagSpecByName finds TagSpec by its name in the registry.
func (TagSpecMap) RegisterTag ¶ added in v0.3.0
func (tagSpecMap TagSpecMap) RegisterTag(tagFamilyIdx, tagIdx int, spec *databasev1.TagSpec)
RegisterTag registers the tag spec with given tagFamilyName, tagName and indexes.
func (TagSpecMap) RegisterTagFamilies ¶ added in v0.3.0
func (tagSpecMap TagSpecMap) RegisterTagFamilies(tagFamilies []*databasev1.TagFamilySpec)
RegisterTagFamilies registers the tag specs with a given slice of TagFamilySpec.
type TagSpecRegistry ¶ added in v0.3.0
TagSpecRegistry enables to find TagSpec by its name.
type TagValueIndexAccessor ¶ added in v0.3.0
TagValueIndexAccessor provides accessor to get TagValue by two indexes, i.e. tagFamilyIndex and tagIndex. It works like a matrix.
type UnresolvedPlan ¶
UnresolvedPlan denotes an logical expression. It could be analyzed to a Plan(executable operation) with the Schema.
type VolumeLimiter ¶ added in v0.3.0
VolumeLimiter controls the volume of a Plan's output.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package measure implements execution operations for querying measure data.
|
Package measure implements execution operations for querying measure data. |
|
Package stream implements execution operations for querying stream data.
|
Package stream implements execution operations for querying stream data. |