Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
5acc9681
M
milvus
项目概览
milvus
/
milvus
11 个月 前同步成功
通知
260
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,发现更多精彩内容 >>
提交
5acc9681
编写于
12月 26, 2020
作者:
B
bigsheeper
提交者:
yefu.chen
12月 26, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix search error about metric type
Signed-off-by:
N
bigsheeper
<
yihao.dai@zilliz.com
>
上级
d599407e
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
166 addition
and
121 deletion
+166
-121
internal/core/src/segcore/plan_c.cpp
internal/core/src/segcore/plan_c.cpp
+6
-0
internal/core/src/segcore/plan_c.h
internal/core/src/segcore/plan_c.h
+3
-0
internal/core/src/segcore/reduce_c.cpp
internal/core/src/segcore/reduce_c.cpp
+6
-1
internal/core/src/segcore/segment_c.cpp
internal/core/src/segcore/segment_c.cpp
+5
-0
internal/proto/internal_msg.proto
internal/proto/internal_msg.proto
+1
-0
internal/proto/internalpb/internal_msg.pb.go
internal/proto/internalpb/internal_msg.pb.go
+125
-116
internal/proxy/task.go
internal/proxy/task.go
+10
-4
internal/querynode/plan.go
internal/querynode/plan.go
+7
-0
internal/querynode/plan_test.go
internal/querynode/plan_test.go
+2
-0
internal/querynode/search_service.go
internal/querynode/search_service.go
+1
-0
未找到文件。
internal/core/src/segcore/plan_c.cpp
浏览文件 @
5acc9681
...
...
@@ -75,6 +75,12 @@ GetTopK(CPlan plan) {
return
res
;
}
const
char
*
GetMetricType
(
CPlan
plan
)
{
auto
query_plan
=
static_cast
<
milvus
::
query
::
Plan
*>
(
plan
);
return
strdup
(
query_plan
->
plan_node_
->
query_info_
.
metric_type_
.
c_str
());
}
void
DeletePlan
(
CPlan
cPlan
)
{
auto
plan
=
(
milvus
::
query
::
Plan
*
)
cPlan
;
...
...
internal/core/src/segcore/plan_c.h
浏览文件 @
5acc9681
...
...
@@ -35,6 +35,9 @@ GetNumOfQueries(CPlaceholderGroup placeholder_group);
int64_t
GetTopK
(
CPlan
plan
);
const
char
*
GetMetricType
(
CPlan
plan
);
void
DeletePlan
(
CPlan
plan
);
...
...
internal/core/src/segcore/reduce_c.cpp
浏览文件 @
5acc9681
...
...
@@ -64,6 +64,11 @@ struct SearchResultPair {
return
(
distance_
<
pair
.
distance_
);
}
bool
operator
>
(
const
SearchResultPair
&
pair
)
const
{
return
(
distance_
>
pair
.
distance_
);
}
void
reset_distance
()
{
distance_
=
search_result_
->
result_distances_
[
offset_
];
...
...
@@ -89,7 +94,7 @@ GetResultData(std::vector<std::vector<int64_t>>& search_records,
AssertInfo
(
topk
>
0
,
"topK must greater than 0"
);
for
(
int
i
=
0
;
i
<
topk
;
++
i
)
{
result_pairs
[
0
].
reset_distance
();
std
::
sort
(
result_pairs
.
begin
(),
result_pairs
.
end
());
std
::
sort
(
result_pairs
.
begin
(),
result_pairs
.
end
()
,
std
::
greater
<>
()
);
auto
&
result_pair
=
result_pairs
[
0
];
auto
index
=
result_pair
.
index_
;
is_selected
[
index
]
=
true
;
...
...
internal/core/src/segcore/segment_c.cpp
浏览文件 @
5acc9681
...
...
@@ -140,6 +140,11 @@ Search(CSegmentBase c_segment,
auto
status
=
CStatus
();
try
{
auto
res
=
segment
->
Search
(
plan
,
placeholder_groups
.
data
(),
timestamps
,
num_groups
,
*
query_result
);
if
(
plan
->
plan_node_
->
query_info_
.
metric_type_
!=
"IP"
)
{
for
(
auto
&
dis
:
query_result
->
result_distances_
)
{
dis
*=
-
1
;
}
}
status
.
error_code
=
Success
;
status
.
error_msg
=
""
;
}
catch
(
std
::
exception
&
e
)
{
...
...
internal/proto/internal_msg.proto
浏览文件 @
5acc9681
...
...
@@ -259,6 +259,7 @@ message SearchResult {
uint64
timestamp
=
6
;
int64
result_channelID
=
7
;
repeated
bytes
hits
=
8
;
string
metric_type
=
9
;
}
message
TimeTickMsg
{
...
...
internal/proto/internalpb/internal_msg.pb.go
浏览文件 @
5acc9681
此差异已折叠。
点击以展开。
internal/proxy/task.go
浏览文件 @
5acc9681
...
...
@@ -487,6 +487,7 @@ func (qt *QueryTask) PostExecute() error {
Hits
:
make
([][]
byte
,
0
),
}
const
minFloat32
=
-
1
*
float32
(
math
.
MaxFloat32
)
for
i
:=
0
;
i
<
nq
;
i
++
{
locs
:=
make
([]
int
,
availableQueryNodeNum
)
reducedHits
:=
&
servicepb
.
Hits
{
...
...
@@ -496,18 +497,18 @@ func (qt *QueryTask) PostExecute() error {
}
for
j
:=
0
;
j
<
topk
;
j
++
{
choice
,
m
inDistance
:=
0
,
float32
(
math
.
MaxFloat32
)
choice
,
m
axDistance
:=
0
,
minFloat32
for
q
,
loc
:=
range
locs
{
// query num, the number of ways to merge
distance
:=
hits
[
q
][
i
]
.
Scores
[
loc
]
if
distance
<
min
Distance
{
if
distance
>
max
Distance
{
choice
=
q
m
in
Distance
=
distance
m
ax
Distance
=
distance
}
}
choiceOffset
:=
locs
[
choice
]
// check if distance is valid, `invalid` here means very very big,
// in this process, distance here is the smallest, so the rest of distance are all invalid
if
hits
[
choice
][
i
]
.
Scores
[
choiceOffset
]
>=
float32
(
math
.
MaxFloat32
)
{
if
hits
[
choice
][
i
]
.
Scores
[
choiceOffset
]
<=
minFloat32
{
break
}
reducedHits
.
IDs
=
append
(
reducedHits
.
IDs
,
hits
[
choice
][
i
]
.
IDs
[
choiceOffset
])
...
...
@@ -517,6 +518,11 @@ func (qt *QueryTask) PostExecute() error {
reducedHits
.
Scores
=
append
(
reducedHits
.
Scores
,
hits
[
choice
][
i
]
.
Scores
[
choiceOffset
])
locs
[
choice
]
++
}
if
searchResults
[
0
]
.
MetricType
!=
"IP"
{
for
k
:=
range
reducedHits
.
Scores
{
reducedHits
.
Scores
[
k
]
*=
-
1
}
}
reducedHitsBs
,
err
:=
proto
.
Marshal
(
reducedHits
)
if
err
!=
nil
{
log
.
Println
(
"marshal error"
)
...
...
internal/querynode/plan.go
浏览文件 @
5acc9681
...
...
@@ -41,6 +41,13 @@ func (plan *Plan) getTopK() int64 {
return
int64
(
topK
)
}
func
(
plan
*
Plan
)
getMetricType
()
string
{
cMetricType
:=
C
.
GetMetricType
(
plan
.
cPlan
)
defer
C
.
free
(
unsafe
.
Pointer
(
cMetricType
))
metricType
:=
C
.
GoString
(
cMetricType
)
return
metricType
}
func
(
plan
*
Plan
)
delete
()
{
C
.
DeletePlan
(
plan
.
cPlan
)
}
...
...
internal/querynode/plan_test.go
浏览文件 @
5acc9681
...
...
@@ -27,6 +27,8 @@ func TestPlan_Plan(t *testing.T) {
assert
.
NotEqual
(
t
,
plan
,
nil
)
topk
:=
plan
.
getTopK
()
assert
.
Equal
(
t
,
int
(
topk
),
10
)
metricType
:=
plan
.
getMetricType
()
assert
.
Equal
(
t
,
metricType
,
"L2"
)
plan
.
delete
()
deleteCollection
(
collection
)
}
...
...
internal/querynode/search_service.go
浏览文件 @
5acc9681
...
...
@@ -336,6 +336,7 @@ func (ss *searchService) search(msg msgstream.TsMsg) error {
Timestamp
:
searchTimestamp
,
ResultChannelID
:
searchMsg
.
ResultChannelID
,
Hits
:
hits
,
MetricType
:
plan
.
getMetricType
(),
}
searchResultMsg
:=
&
msgstream
.
SearchResultMsg
{
BaseMsg
:
msgstream
.
BaseMsg
{
HashValues
:
[]
uint32
{
uint32
(
searchMsg
.
ResultChannelID
)}},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录