sqe

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const MaxRecursionDeepness = 2501

MaxRecursionDeepness is the limit we impose on the number of direct ORs expression. It's possible to have more than that, just not in a single successive sequence or `1 or 2 or 3 ...`. This is to avoid first a speed problem where parsing start to be

Variables

View Source
var ErrStopVisit = errors.New("stop")
View Source
var NoOpFieldTransformer noOpTransformer

Functions

func ExtractAllKeys

func ExtractAllKeys(expression Expression) (out []string)

FindAllFieldNames returns all used field names in the AST. There is **NO** ordering on the elements, i.e. they might not come in the same order specified in the AST.

func KeysApply added in v1.6.0

func KeysApply(expr Expression, blockKeys KeysQuerier) bool

func RoaringBitmapsApply added in v1.5.0

func RoaringBitmapsApply(expr Expression, bitmaps map[string]*roaring64.Bitmap) *roaring64.Bitmap

func TransformExpression

func TransformExpression(expr Expression, transformer FieldTransformer) error

Types

type AndExpression

type AndExpression struct {
	Children []Expression
}

func (*AndExpression) GetChildren added in v1.5.0

func (e *AndExpression) GetChildren() []Expression

func (*AndExpression) Visit

func (e *AndExpression) Visit(ctx context.Context, visitor Visitor) error

type DepthFirstVisitor

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

func NewDepthFirstVisitor

func NewDepthFirstVisitor(beforeVisit, afterVisit OnExpression) *DepthFirstVisitor

func (*DepthFirstVisitor) Visit_And

func (v *DepthFirstVisitor) Visit_And(ctx context.Context, e *AndExpression) error

func (*DepthFirstVisitor) Visit_KeyTerm

func (v *DepthFirstVisitor) Visit_KeyTerm(ctx context.Context, e *KeyTerm) error

func (*DepthFirstVisitor) Visit_Not

func (v *DepthFirstVisitor) Visit_Not(ctx context.Context, e *NotExpression) error

func (*DepthFirstVisitor) Visit_Or

func (v *DepthFirstVisitor) Visit_Or(ctx context.Context, e *OrExpression) error

func (*DepthFirstVisitor) Visit_Parenthesis

func (v *DepthFirstVisitor) Visit_Parenthesis(ctx context.Context, e *ParenthesisExpression) error

type Expression

type Expression interface {
	Visit(ctx context.Context, visitor Visitor) error
}

func Parse

func Parse(ctx context.Context, input string) (expr Expression, err error)

type FieldTransformer

type FieldTransformer interface {
	// TransformFieldName receives the field name and allow receiver of the invocation to update its name. The field's
	// name is updated if the invocation returns a nil error.
	TransformFieldName(field string) (string, error)

	// TransformStringLiteral receives the field name (the updated one from a prior invocation of `TransformFieldName`)
	// and a string literal (either a direct one or a sub-element from a `StringList`) and allows transformation of the
	// `StringLiteral` value in place.
	TransformStringLiteral(field string, value *StringLiteral) error
}

type HasChildrenExpression added in v1.5.0

type HasChildrenExpression interface {
	GetChildren() []Expression
}

type KeyTerm

type KeyTerm struct {
	Value *StringLiteral
}

func (*KeyTerm) Visit

func (e *KeyTerm) Visit(ctx context.Context, visitor Visitor) error

type KeysQuerier added in v1.6.0

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

func NewFromIndexKeys added in v1.6.0

func NewFromIndexKeys(indexKeys *pbindex.Keys) KeysQuerier

type NotExpression

type NotExpression struct {
	Child Expression
}

func (*NotExpression) Visit

func (e *NotExpression) Visit(ctx context.Context, visitor Visitor) error

type OnExpression

type OnExpression func(ctx context.Context, expr Expression) error

type OrExpression

type OrExpression struct {
	Children []Expression
}

func (*OrExpression) GetChildren added in v1.5.0

func (e *OrExpression) GetChildren() []Expression

func (*OrExpression) Visit

func (e *OrExpression) Visit(ctx context.Context, visitor Visitor) error

type ParenthesisExpression

type ParenthesisExpression struct {
	Child Expression
}

func (*ParenthesisExpression) Visit

func (e *ParenthesisExpression) Visit(ctx context.Context, visitor Visitor) error

type ParseError

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

func (*ParseError) Error

func (e *ParseError) Error() string

type Parser

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

func NewParser

func NewParser(reader io.Reader) (*Parser, error)

func (*Parser) Parse

func (p *Parser) Parse(ctx context.Context) (out Expression, err error)

type StringLiteral

type StringLiteral struct {
	Value       string
	QuotingChar string
}

func (*StringLiteral) Literal

func (e *StringLiteral) Literal() string

func (*StringLiteral) SetValue

func (e *StringLiteral) SetValue(value string)

func (*StringLiteral) String

func (e *StringLiteral) String() string

type Visitor

type Visitor interface {
	Visit_And(ctx context.Context, expr *AndExpression) error
	Visit_Or(ctx context.Context, expr *OrExpression) error
	Visit_Parenthesis(ctx context.Context, expr *ParenthesisExpression) error
	Visit_Not(ctx context.Context, expr *NotExpression) error
	Visit_KeyTerm(ctx context.Context, expr *KeyTerm) error
}

Jump to

Keyboard shortcuts

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