planparserv2

package
v0.10.3-0...-930112e Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

README

Generate Parser with Antlr4

Install Antlr4

Please follow install antlr4 to install the antlr tool.

The version of antlr tool: 4.13.2.

Code Generate

After you install the antlr4, you can generate the parser code in golang with:

go generate

All generated code will be under directory generated.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPlanNodeIdentical

func CheckPlanNodeIdentical(node1, node2 *planpb.PlanNode) bool

func CheckPredicatesIdentical

func CheckPredicatesIdentical(expr, other *planpb.Expr) bool

CheckPredicatesIdentical check if two exprs are identical.

func CheckQueryInfoIdentical

func CheckQueryInfoIdentical(info1, info2 *planpb.QueryInfo) bool

func CheckVectorANNSIdentical

func CheckVectorANNSIdentical(node1, node2 *planpb.VectorANNS) bool

func ConvertToGenericValue

func ConvertToGenericValue(templateName string, templateValue *schemapb.TemplateValue) (*planpb.GenericValue, error)

func CreateRequeryPlan

func CreateRequeryPlan(pkField *schemapb.FieldSchema, ids *schemapb.IDs) *planpb.PlanNode

func CreateRetrievePlan

func CreateRetrievePlan(schema *typeutil.SchemaHelper, exprStr string, exprTemplateValues map[string]*schemapb.TemplateValue) (*planpb.PlanNode, error)

func CreateSearchPlan

func CreateSearchPlan(schema *typeutil.SchemaHelper, exprStr string, vectorFieldName string, queryInfo *planpb.QueryInfo, exprTemplateValues map[string]*schemapb.TemplateValue) (*planpb.PlanNode, error)

func FillBinaryArithOpEvalRangeExpressionValue

func FillBinaryArithOpEvalRangeExpressionValue(expr *planpb.BinaryArithOpEvalRangeExpr, templateValues map[string]*planpb.GenericValue) error

func FillBinaryRangeExpressionValue

func FillBinaryRangeExpressionValue(expr *planpb.BinaryRangeExpr, templateValues map[string]*planpb.GenericValue) error

func FillExpressionValue

func FillExpressionValue(expr *planpb.Expr, templateValues map[string]*planpb.GenericValue) error

func FillJSONContainsExpressionValue

func FillJSONContainsExpressionValue(expr *planpb.JSONContainsExpr, templateValues map[string]*planpb.GenericValue) error

func FillTermExpressionValue

func FillTermExpressionValue(expr *planpb.TermExpr, templateValues map[string]*planpb.GenericValue) error

func FillUnaryRangeExpressionValue

func FillUnaryRangeExpressionValue(expr *planpb.UnaryRangeExpr, templateValues map[string]*planpb.GenericValue) error

func HandleCompare

func HandleCompare(op int, left, right *ExprWithType) (*planpb.Expr, error)

func IsAlwaysTruePlan

func IsAlwaysTruePlan(plan *planpb.PlanNode) bool

func IsArray

func IsArray(n *planpb.GenericValue) bool

func IsBool

func IsBool(n *planpb.GenericValue) bool

func IsFloating

func IsFloating(n *planpb.GenericValue) bool

func IsInteger

func IsInteger(n *planpb.GenericValue) bool

func IsNumber

func IsNumber(n *planpb.GenericValue) bool

func IsString

func IsString(n *planpb.GenericValue) bool

func NewBool

func NewBool(value bool) *planpb.GenericValue

func NewFloat

func NewFloat(value float64) *planpb.GenericValue

func NewInt

func NewInt(value int64) *planpb.GenericValue

func NewString

func NewString(value string) *planpb.GenericValue

func ParseExpr

func ParseExpr(schema *typeutil.SchemaHelper, exprStr string, exprTemplateValues map[string]*schemapb.TemplateValue) (*planpb.Expr, error)

func ParseIdentifier

func ParseIdentifier(schema *typeutil.SchemaHelper, identifier string, checkFunc func(*planpb.Expr) error) error

func ShowExpr

func ShowExpr(expr *planpb.Expr)

ShowExpr print the expr tree, used for debugging, not safe.

func UnmarshalExpressionValues

func UnmarshalExpressionValues(input map[string]*schemapb.TemplateValue) (map[string]*planpb.GenericValue, error)

Types

type ExprWithType

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

func Add

func Add(a, b *planpb.GenericValue) *ExprWithType

func And

func And(a, b *planpb.GenericValue) (*ExprWithType, error)

func BitAnd

func BitAnd(a, b *planpb.GenericValue) (*ExprWithType, error)

func BitNot

func BitNot(a *planpb.GenericValue) (*ExprWithType, error)

func BitOr

func BitOr(a, b *planpb.GenericValue) (*ExprWithType, error)

func BitXor

func BitXor(a, b *planpb.GenericValue) (*ExprWithType, error)

func Divide

func Divide(a, b *planpb.GenericValue) (*ExprWithType, error)

func Equal

func Equal(a, b *planpb.GenericValue) *ExprWithType

func Greater

func Greater(a, b *planpb.GenericValue) *ExprWithType

func GreaterEqual

func GreaterEqual(a, b *planpb.GenericValue) *ExprWithType

func Less

func Less(a, b *planpb.GenericValue) *ExprWithType

func LessEqual

func LessEqual(a, b *planpb.GenericValue) *ExprWithType

func Modulo

func Modulo(a, b *planpb.GenericValue) (*ExprWithType, error)

func Multiply

func Multiply(a, b *planpb.GenericValue) *ExprWithType

func Negative

func Negative(a *planpb.GenericValue) *ExprWithType

func Not

func NotEqual

func NotEqual(a, b *planpb.GenericValue) *ExprWithType

func Or

func Or(a, b *planpb.GenericValue) (*ExprWithType, error)

func Power

func Power(a, b *planpb.GenericValue) *ExprWithType

func ShiftLeft

func ShiftLeft(a, b *planpb.GenericValue) (*ExprWithType, error)

func ShiftRight

func ShiftRight(a, b *planpb.GenericValue) (*ExprWithType, error)

func Subtract

func Subtract(a, b *planpb.GenericValue) *ExprWithType

type LogicalExprVisitor

type LogicalExprVisitor interface {
	VisitExpr(expr *planpb.Expr) interface{}
	VisitTermExpr(expr *planpb.TermExpr) interface{}
	VisitUnaryExpr(expr *planpb.UnaryExpr) interface{}
	VisitBinaryExpr(expr *planpb.BinaryExpr) interface{}
	VisitCompareExpr(expr *planpb.CompareExpr) interface{}
	VisitUnaryRangeExpr(expr *planpb.UnaryRangeExpr) interface{}
	VisitBinaryRangeExpr(expr *planpb.BinaryRangeExpr) interface{}
	VisitBinaryArithOpEvalRangeExpr(expr *planpb.BinaryArithOpEvalRangeExpr) interface{}
	VisitBinaryArithExpr(expr *planpb.BinaryArithExpr) interface{}
	VisitValueExpr(expr *planpb.ValueExpr) interface{}
	VisitColumnExpr(expr *planpb.ColumnExpr) interface{}
}

func NewShowExprVisitor

func NewShowExprVisitor() LogicalExprVisitor

type ParserVisitor

type ParserVisitor struct {
	parser.BasePlanVisitor
	// contains filtered or unexported fields
}

func NewParserVisitor

func NewParserVisitor(schema *typeutil.SchemaHelper) *ParserVisitor

func (*ParserVisitor) VisitAddSub

func (v *ParserVisitor) VisitAddSub(ctx *parser.AddSubContext) interface{}

VisitAddSub translates expr to arithmetic plan.

func (*ParserVisitor) VisitArray

func (v *ParserVisitor) VisitArray(ctx *parser.ArrayContext) interface{}

func (*ParserVisitor) VisitArrayLength

func (v *ParserVisitor) VisitArrayLength(ctx *parser.ArrayLengthContext) interface{}

func (*ParserVisitor) VisitBitAnd

func (v *ParserVisitor) VisitBitAnd(ctx *parser.BitAndContext) interface{}

VisitBitAnd not supported.

func (*ParserVisitor) VisitBitOr

func (v *ParserVisitor) VisitBitOr(ctx *parser.BitOrContext) interface{}

VisitBitOr unsupported.

func (*ParserVisitor) VisitBitXor

func (v *ParserVisitor) VisitBitXor(ctx *parser.BitXorContext) interface{}

VisitBitXor not supported.

func (*ParserVisitor) VisitBoolean

func (v *ParserVisitor) VisitBoolean(ctx *parser.BooleanContext) interface{}

VisitBoolean translates expr to GenericValue.

func (*ParserVisitor) VisitCall

func (v *ParserVisitor) VisitCall(ctx *parser.CallContext) interface{}

VisitCall parses the expr to call plan.

func (*ParserVisitor) VisitEmptyArray

func (v *ParserVisitor) VisitEmptyArray(ctx *parser.EmptyArrayContext) interface{}

func (*ParserVisitor) VisitEquality

func (v *ParserVisitor) VisitEquality(ctx *parser.EqualityContext) interface{}

VisitEquality translates expr to compare/range plan.

func (*ParserVisitor) VisitExists

func (v *ParserVisitor) VisitExists(ctx *parser.ExistsContext) interface{}

func (*ParserVisitor) VisitFloating

func (v *ParserVisitor) VisitFloating(ctx *parser.FloatingContext) interface{}

VisitFloating translates expr to GenericValue.

func (*ParserVisitor) VisitIdentifier

func (v *ParserVisitor) VisitIdentifier(ctx *parser.IdentifierContext) interface{}

VisitIdentifier translates expr to column plan.

func (*ParserVisitor) VisitInteger

func (v *ParserVisitor) VisitInteger(ctx *parser.IntegerContext) interface{}

VisitInteger translates expr to GenericValue.

func (*ParserVisitor) VisitJSONContains

func (v *ParserVisitor) VisitJSONContains(ctx *parser.JSONContainsContext) interface{}

func (*ParserVisitor) VisitJSONContainsAll

func (v *ParserVisitor) VisitJSONContainsAll(ctx *parser.JSONContainsAllContext) interface{}

func (*ParserVisitor) VisitJSONContainsAny

func (v *ParserVisitor) VisitJSONContainsAny(ctx *parser.JSONContainsAnyContext) interface{}

func (*ParserVisitor) VisitJSONIdentifier

func (v *ParserVisitor) VisitJSONIdentifier(ctx *parser.JSONIdentifierContext) interface{}

func (*ParserVisitor) VisitLike

func (v *ParserVisitor) VisitLike(ctx *parser.LikeContext) interface{}

VisitLike handles match operations.

func (*ParserVisitor) VisitLogicalAnd

func (v *ParserVisitor) VisitLogicalAnd(ctx *parser.LogicalAndContext) interface{}

VisitLogicalAnd apply logical and to two boolean expressions.

func (*ParserVisitor) VisitLogicalOr

func (v *ParserVisitor) VisitLogicalOr(ctx *parser.LogicalOrContext) interface{}

VisitLogicalOr apply logical or to two boolean expressions.

func (*ParserVisitor) VisitMulDivMod

func (v *ParserVisitor) VisitMulDivMod(ctx *parser.MulDivModContext) interface{}

VisitMulDivMod translates expr to arithmetic plan.

func (*ParserVisitor) VisitParens

func (v *ParserVisitor) VisitParens(ctx *parser.ParensContext) interface{}

VisitParens unpack the parentheses.

func (*ParserVisitor) VisitPower

func (v *ParserVisitor) VisitPower(ctx *parser.PowerContext) interface{}

VisitPower parses power expression.

func (*ParserVisitor) VisitRange

func (v *ParserVisitor) VisitRange(ctx *parser.RangeContext) interface{}

VisitRange translates expr to range plan.

func (*ParserVisitor) VisitRelational

func (v *ParserVisitor) VisitRelational(ctx *parser.RelationalContext) interface{}

VisitRelational translates expr to range/compare plan.

func (*ParserVisitor) VisitReverseRange

func (v *ParserVisitor) VisitReverseRange(ctx *parser.ReverseRangeContext) interface{}

VisitReverseRange parses the expression like "1 > a > 0".

func (*ParserVisitor) VisitShift

func (v *ParserVisitor) VisitShift(ctx *parser.ShiftContext) interface{}

VisitShift unsupported.

func (*ParserVisitor) VisitString

func (v *ParserVisitor) VisitString(ctx *parser.StringContext) interface{}

VisitString translates expr to GenericValue.

func (*ParserVisitor) VisitTemplateVariable

func (v *ParserVisitor) VisitTemplateVariable(ctx *parser.TemplateVariableContext) interface{}

func (*ParserVisitor) VisitTerm

func (v *ParserVisitor) VisitTerm(ctx *parser.TermContext) interface{}

VisitTerm translates expr to term plan.

func (*ParserVisitor) VisitTextMatch

func (v *ParserVisitor) VisitTextMatch(ctx *parser.TextMatchContext) interface{}

func (*ParserVisitor) VisitUnary

func (v *ParserVisitor) VisitUnary(ctx *parser.UnaryContext) interface{}

VisitUnary unpack the +expr to expr.

type ShowExprVisitor

type ShowExprVisitor struct{}

func (*ShowExprVisitor) VisitBinaryArithExpr

func (v *ShowExprVisitor) VisitBinaryArithExpr(expr *planpb.BinaryArithExpr) interface{}

func (*ShowExprVisitor) VisitBinaryArithOpEvalRangeExpr

func (v *ShowExprVisitor) VisitBinaryArithOpEvalRangeExpr(expr *planpb.BinaryArithOpEvalRangeExpr) interface{}

func (*ShowExprVisitor) VisitBinaryExpr

func (v *ShowExprVisitor) VisitBinaryExpr(expr *planpb.BinaryExpr) interface{}

func (*ShowExprVisitor) VisitBinaryRangeExpr

func (v *ShowExprVisitor) VisitBinaryRangeExpr(expr *planpb.BinaryRangeExpr) interface{}

func (*ShowExprVisitor) VisitCallExpr

func (v *ShowExprVisitor) VisitCallExpr(expr *planpb.CallExpr) interface{}

func (*ShowExprVisitor) VisitColumnExpr

func (v *ShowExprVisitor) VisitColumnExpr(expr *planpb.ColumnExpr) interface{}

func (*ShowExprVisitor) VisitCompareExpr

func (v *ShowExprVisitor) VisitCompareExpr(expr *planpb.CompareExpr) interface{}

func (*ShowExprVisitor) VisitExpr

func (v *ShowExprVisitor) VisitExpr(expr *planpb.Expr) interface{}

func (*ShowExprVisitor) VisitTermExpr

func (v *ShowExprVisitor) VisitTermExpr(expr *planpb.TermExpr) interface{}

func (*ShowExprVisitor) VisitUnaryExpr

func (v *ShowExprVisitor) VisitUnaryExpr(expr *planpb.UnaryExpr) interface{}

func (*ShowExprVisitor) VisitUnaryRangeExpr

func (v *ShowExprVisitor) VisitUnaryRangeExpr(expr *planpb.UnaryRangeExpr) interface{}

func (*ShowExprVisitor) VisitValueExpr

func (v *ShowExprVisitor) VisitValueExpr(expr *planpb.ValueExpr) interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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