Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
8f5bf467
M
milvus
项目概览
milvus
/
milvus
11 个月 前同步成功
通知
261
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8f5bf467
编写于
10月 13, 2021
作者:
D
dragondriver
提交者:
GitHub
10月 13, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix golint warning of plan_parser.go (#9827)
Signed-off-by:
N
dragondriver
<
jiquan.long@zilliz.com
>
上级
e97b62cf
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
25 addition
and
25 deletion
+25
-25
internal/proxy/plan_parser.go
internal/proxy/plan_parser.go
+17
-17
internal/proxy/plan_parser_test.go
internal/proxy/plan_parser_test.go
+5
-5
internal/proxy/task.go
internal/proxy/task.go
+3
-3
未找到文件。
internal/proxy/plan_parser.go
浏览文件 @
8f5bf467
...
...
@@ -23,7 +23,7 @@ import (
"github.com/milvus-io/milvus/internal/util/typeutil"
)
type
P
arserContext
struct
{
type
p
arserContext
struct
{
schema
*
typeutil
.
SchemaHelper
}
...
...
@@ -179,7 +179,7 @@ func parseExpr(schema *typeutil.SchemaHelper, exprStr string) (*planpb.Expr, err
return
nil
,
optimizer
.
err
}
pc
:=
P
arserContext
{
schema
}
pc
:=
p
arserContext
{
schema
}
expr
,
err
:=
pc
.
handleExpr
(
&
ast
.
Node
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -270,7 +270,7 @@ func parseBoolNode(nodeRaw *ant_ast.Node) *ant_ast.BoolNode {
}
}
func
(
pc
*
P
arserContext
)
createCmpExpr
(
left
,
right
ant_ast
.
Node
,
operator
string
)
(
*
planpb
.
Expr
,
error
)
{
func
(
pc
*
p
arserContext
)
createCmpExpr
(
left
,
right
ant_ast
.
Node
,
operator
string
)
(
*
planpb
.
Expr
,
error
)
{
if
boolNode
:=
parseBoolNode
(
&
left
);
boolNode
!=
nil
{
left
=
boolNode
}
...
...
@@ -347,11 +347,11 @@ func (pc *ParserContext) createCmpExpr(left, right ant_ast.Node, operator string
return
expr
,
nil
}
func
(
pc
*
P
arserContext
)
handleCmpExpr
(
node
*
ant_ast
.
BinaryNode
)
(
*
planpb
.
Expr
,
error
)
{
func
(
pc
*
p
arserContext
)
handleCmpExpr
(
node
*
ant_ast
.
BinaryNode
)
(
*
planpb
.
Expr
,
error
)
{
return
pc
.
createCmpExpr
(
node
.
Left
,
node
.
Right
,
node
.
Operator
)
}
func
(
pc
*
P
arserContext
)
handleLogicalExpr
(
node
*
ant_ast
.
BinaryNode
)
(
*
planpb
.
Expr
,
error
)
{
func
(
pc
*
p
arserContext
)
handleLogicalExpr
(
node
*
ant_ast
.
BinaryNode
)
(
*
planpb
.
Expr
,
error
)
{
op
:=
getLogicalOpType
(
node
.
Operator
)
if
op
==
planpb
.
BinaryExpr_Invalid
{
return
nil
,
fmt
.
Errorf
(
"invalid logical operator(%s)"
,
node
.
Operator
)
...
...
@@ -379,7 +379,7 @@ func (pc *ParserContext) handleLogicalExpr(node *ant_ast.BinaryNode) (*planpb.Ex
return
expr
,
nil
}
func
(
pc
*
P
arserContext
)
handleArrayExpr
(
node
*
ant_ast
.
Node
,
dataType
schemapb
.
DataType
)
([]
*
planpb
.
GenericValue
,
error
)
{
func
(
pc
*
p
arserContext
)
handleArrayExpr
(
node
*
ant_ast
.
Node
,
dataType
schemapb
.
DataType
)
([]
*
planpb
.
GenericValue
,
error
)
{
arrayNode
,
ok2
:=
(
*
node
)
.
(
*
ant_ast
.
ArrayNode
)
if
!
ok2
{
return
nil
,
fmt
.
Errorf
(
"right operand of the InExpr must be array"
)
...
...
@@ -397,7 +397,7 @@ func (pc *ParserContext) handleArrayExpr(node *ant_ast.Node, dataType schemapb.D
return
arr
,
nil
}
func
(
pc
*
P
arserContext
)
handleInExpr
(
node
*
ant_ast
.
BinaryNode
)
(
*
planpb
.
Expr
,
error
)
{
func
(
pc
*
p
arserContext
)
handleInExpr
(
node
*
ant_ast
.
BinaryNode
)
(
*
planpb
.
Expr
,
error
)
{
if
node
.
Operator
!=
"in"
&&
node
.
Operator
!=
"not in"
{
return
nil
,
fmt
.
Errorf
(
"invalid operator(%s)"
,
node
.
Operator
)
}
...
...
@@ -429,7 +429,7 @@ func (pc *ParserContext) handleInExpr(node *ant_ast.BinaryNode) (*planpb.Expr, e
return
expr
,
nil
}
func
(
pc
*
P
arserContext
)
combineUnaryRangeExpr
(
a
,
b
*
planpb
.
UnaryRangeExpr
)
*
planpb
.
Expr
{
func
(
pc
*
p
arserContext
)
combineUnaryRangeExpr
(
a
,
b
*
planpb
.
UnaryRangeExpr
)
*
planpb
.
Expr
{
if
a
.
Op
==
planpb
.
OpType_LessEqual
||
a
.
Op
==
planpb
.
OpType_LessThan
{
a
,
b
=
b
,
a
}
...
...
@@ -451,7 +451,7 @@ func (pc *ParserContext) combineUnaryRangeExpr(a, b *planpb.UnaryRangeExpr) *pla
return
expr
}
func
(
pc
*
P
arserContext
)
handleMultiCmpExpr
(
node
*
ant_ast
.
BinaryNode
)
(
*
planpb
.
Expr
,
error
)
{
func
(
pc
*
p
arserContext
)
handleMultiCmpExpr
(
node
*
ant_ast
.
BinaryNode
)
(
*
planpb
.
Expr
,
error
)
{
exprs
:=
[]
*
planpb
.
Expr
{}
curNode
:=
node
...
...
@@ -511,7 +511,7 @@ func (pc *ParserContext) handleMultiCmpExpr(node *ant_ast.BinaryNode) (*planpb.E
return
combinedExpr
,
nil
}
func
(
pc
*
P
arserContext
)
handleBinaryExpr
(
node
*
ant_ast
.
BinaryNode
)
(
*
planpb
.
Expr
,
error
)
{
func
(
pc
*
p
arserContext
)
handleBinaryExpr
(
node
*
ant_ast
.
BinaryNode
)
(
*
planpb
.
Expr
,
error
)
{
switch
node
.
Operator
{
case
"<"
,
"<="
,
">"
,
">="
:
return
pc
.
handleMultiCmpExpr
(
node
)
...
...
@@ -525,7 +525,7 @@ func (pc *ParserContext) handleBinaryExpr(node *ant_ast.BinaryNode) (*planpb.Exp
return
nil
,
fmt
.
Errorf
(
"unsupported binary operator %s"
,
node
.
Operator
)
}
func
(
pc
*
P
arserContext
)
createNotExpr
(
childExpr
*
planpb
.
Expr
)
(
*
planpb
.
Expr
,
error
)
{
func
(
pc
*
p
arserContext
)
createNotExpr
(
childExpr
*
planpb
.
Expr
)
(
*
planpb
.
Expr
,
error
)
{
expr
:=
&
planpb
.
Expr
{
Expr
:
&
planpb
.
Expr_UnaryExpr
{
UnaryExpr
:
&
planpb
.
UnaryExpr
{
...
...
@@ -537,7 +537,7 @@ func (pc *ParserContext) createNotExpr(childExpr *planpb.Expr) (*planpb.Expr, er
return
expr
,
nil
}
func
(
pc
*
P
arserContext
)
handleLeafValue
(
nodeRaw
*
ant_ast
.
Node
,
dataType
schemapb
.
DataType
)
(
gv
*
planpb
.
GenericValue
,
err
error
)
{
func
(
pc
*
p
arserContext
)
handleLeafValue
(
nodeRaw
*
ant_ast
.
Node
,
dataType
schemapb
.
DataType
)
(
gv
*
planpb
.
GenericValue
,
err
error
)
{
switch
node
:=
(
*
nodeRaw
)
.
(
type
)
{
case
*
ant_ast
.
FloatNode
:
if
typeutil
.
IsFloatingType
(
dataType
)
{
...
...
@@ -591,13 +591,13 @@ func (pc *ParserContext) handleLeafValue(nodeRaw *ant_ast.Node, dataType schemap
return
gv
,
nil
}
func
(
pc
*
P
arserContext
)
handleIdentifier
(
node
*
ant_ast
.
IdentifierNode
)
(
*
schemapb
.
FieldSchema
,
error
)
{
func
(
pc
*
p
arserContext
)
handleIdentifier
(
node
*
ant_ast
.
IdentifierNode
)
(
*
schemapb
.
FieldSchema
,
error
)
{
fieldName
:=
node
.
Value
field
,
err
:=
pc
.
schema
.
GetFieldFromName
(
fieldName
)
return
field
,
err
}
func
(
pc
*
P
arserContext
)
handleUnaryExpr
(
node
*
ant_ast
.
UnaryNode
)
(
*
planpb
.
Expr
,
error
)
{
func
(
pc
*
p
arserContext
)
handleUnaryExpr
(
node
*
ant_ast
.
UnaryNode
)
(
*
planpb
.
Expr
,
error
)
{
switch
node
.
Operator
{
case
"!"
,
"not"
:
subExpr
,
err
:=
pc
.
handleExpr
(
&
node
.
Node
)
...
...
@@ -610,7 +610,7 @@ func (pc *ParserContext) handleUnaryExpr(node *ant_ast.UnaryNode) (*planpb.Expr,
}
}
func
(
pc
*
P
arserContext
)
handleExpr
(
nodeRaw
*
ant_ast
.
Node
)
(
*
planpb
.
Expr
,
error
)
{
func
(
pc
*
p
arserContext
)
handleExpr
(
nodeRaw
*
ant_ast
.
Node
)
(
*
planpb
.
Expr
,
error
)
{
switch
node
:=
(
*
nodeRaw
)
.
(
type
)
{
case
*
ant_ast
.
IdentifierNode
,
*
ant_ast
.
FloatNode
,
...
...
@@ -630,7 +630,7 @@ func (pc *ParserContext) handleExpr(nodeRaw *ant_ast.Node) (*planpb.Expr, error)
}
}
func
C
reateQueryPlan
(
schemaPb
*
schemapb
.
CollectionSchema
,
exprStr
string
,
vectorFieldName
string
,
queryInfo
*
planpb
.
QueryInfo
)
(
*
planpb
.
PlanNode
,
error
)
{
func
c
reateQueryPlan
(
schemaPb
*
schemapb
.
CollectionSchema
,
exprStr
string
,
vectorFieldName
string
,
queryInfo
*
planpb
.
QueryInfo
)
(
*
planpb
.
PlanNode
,
error
)
{
schema
,
err
:=
typeutil
.
CreateSchemaHelper
(
schemaPb
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -665,7 +665,7 @@ func CreateQueryPlan(schemaPb *schemapb.CollectionSchema, exprStr string, vector
return
planNode
,
nil
}
func
C
reateExprPlan
(
schemaPb
*
schemapb
.
CollectionSchema
,
exprStr
string
)
(
*
planpb
.
PlanNode
,
error
)
{
func
c
reateExprPlan
(
schemaPb
*
schemapb
.
CollectionSchema
,
exprStr
string
)
(
*
planpb
.
PlanNode
,
error
)
{
schema
,
err
:=
typeutil
.
CreateSchemaHelper
(
schemaPb
)
if
err
!=
nil
{
return
nil
,
err
...
...
internal/proxy/plan_parser_test.go
浏览文件 @
8f5bf467
...
...
@@ -175,7 +175,7 @@ func TestParsePlanNode_Naive(t *testing.T) {
// TODO: change it to better solution
for
offset
,
exprStr
:=
range
exprStrs
{
fmt
.
Printf
(
"case %d: %s
\n
"
,
offset
,
exprStr
)
planProto
,
err
:=
C
reateQueryPlan
(
schema
,
exprStr
,
"FloatVectorField"
,
queryInfo
)
planProto
,
err
:=
c
reateQueryPlan
(
schema
,
exprStr
,
"FloatVectorField"
,
queryInfo
)
assert
.
Nil
(
t
,
err
)
dbgStr
:=
proto
.
MarshalTextString
(
planProto
)
println
(
dbgStr
)
...
...
@@ -211,7 +211,7 @@ func TestExprPlan_Str(t *testing.T) {
}
// without filter
planProto
,
err
:=
C
reateQueryPlan
(
schema
,
""
,
"fakevec"
,
queryInfo
)
planProto
,
err
:=
c
reateQueryPlan
(
schema
,
""
,
"fakevec"
,
queryInfo
)
assert
.
Nil
(
t
,
err
)
dbgStr
:=
proto
.
MarshalTextString
(
planProto
)
println
(
dbgStr
)
...
...
@@ -224,7 +224,7 @@ func TestExprPlan_Str(t *testing.T) {
for
offset
,
exprStr
:=
range
exprStrs
{
fmt
.
Printf
(
"case %d: %s
\n
"
,
offset
,
exprStr
)
planProto
,
err
:=
C
reateQueryPlan
(
schema
,
exprStr
,
"fakevec"
,
queryInfo
)
planProto
,
err
:=
c
reateQueryPlan
(
schema
,
exprStr
,
"fakevec"
,
queryInfo
)
assert
.
Nil
(
t
,
err
)
dbgStr
:=
proto
.
MarshalTextString
(
planProto
)
println
(
dbgStr
)
...
...
@@ -273,7 +273,7 @@ func TestExprMultiRange_Str(t *testing.T) {
for
offset
,
exprStr
:=
range
exprStrs
{
fmt
.
Printf
(
"case %d: %s
\n
"
,
offset
,
exprStr
)
planProto
,
err
:=
C
reateQueryPlan
(
schema
,
exprStr
,
"fakevec"
,
queryInfo
)
planProto
,
err
:=
c
reateQueryPlan
(
schema
,
exprStr
,
"fakevec"
,
queryInfo
)
assert
.
Nil
(
t
,
err
)
dbgStr
:=
proto
.
MarshalTextString
(
planProto
)
println
(
dbgStr
)
...
...
@@ -308,7 +308,7 @@ func TestExprFieldCompare_Str(t *testing.T) {
for
offset
,
exprStr
:=
range
exprStrs
{
fmt
.
Printf
(
"case %d: %s
\n
"
,
offset
,
exprStr
)
planProto
,
err
:=
C
reateQueryPlan
(
schema
,
exprStr
,
"fakevec"
,
queryInfo
)
planProto
,
err
:=
c
reateQueryPlan
(
schema
,
exprStr
,
"fakevec"
,
queryInfo
)
assert
.
Nil
(
t
,
err
)
dbgStr
:=
proto
.
MarshalTextString
(
planProto
)
println
(
dbgStr
)
...
...
internal/proxy/task.go
浏览文件 @
8f5bf467
...
...
@@ -1551,7 +1551,7 @@ func (st *searchTask) PreExecute(ctx context.Context) error {
zap
.
String
(
"anns field"
,
annsField
),
zap
.
Any
(
"query info"
,
queryInfo
))
plan
,
err
:=
C
reateQueryPlan
(
schema
,
st
.
query
.
Dsl
,
annsField
,
queryInfo
)
plan
,
err
:=
c
reateQueryPlan
(
schema
,
st
.
query
.
Dsl
,
annsField
,
queryInfo
)
if
err
!=
nil
{
log
.
Debug
(
"failed to create query plan"
,
zap
.
Error
(
err
),
...
...
@@ -2243,7 +2243,7 @@ func (qt *queryTask) PreExecute(ctx context.Context) error {
return
fmt
.
Errorf
(
errMsg
)
}
plan
,
err
:=
C
reateExprPlan
(
schema
,
qt
.
query
.
Expr
)
plan
,
err
:=
c
reateExprPlan
(
schema
,
qt
.
query
.
Expr
)
if
err
!=
nil
{
return
err
}
...
...
@@ -4644,7 +4644,7 @@ func getPrimaryKeysFromExpr(schema *schemapb.CollectionSchema, expr string) (res
return
}
plan
,
err
:=
C
reateExprPlan
(
schema
,
expr
)
plan
,
err
:=
c
reateExprPlan
(
schema
,
expr
)
if
err
!=
nil
{
return
res
,
fmt
.
Errorf
(
"failed to create expr plan, expr = %s"
,
expr
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录