Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
b9f3c4fc
milvus
项目概览
BaiXuePrincess
/
milvus
与 Fork 源项目一致
Fork自
milvus / milvus
通知
7
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b9f3c4fc
编写于
11月 21, 2019
作者:
J
Jin Hai
提交者:
GitHub
11月 21, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #442 from yhmo/0.6.0
#433 C++ SDK query result is not easy to use
上级
1c7ac286
de6d3217
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
43 addition
and
26 deletion
+43
-26
CHANGELOG.md
CHANGELOG.md
+1
-0
core/scripts/migration/README.md
core/scripts/migration/README.md
+0
-0
core/scripts/migration/mysql_4_to_6.sql
core/scripts/migration/mysql_4_to_6.sql
+0
-0
core/scripts/migration/mysql_6_to_4.sql
core/scripts/migration/mysql_6_to_4.sql
+3
-0
core/scripts/migration/sqlite_4_to_6.sql
core/scripts/migration/sqlite_4_to_6.sql
+0
-0
core/scripts/migration/sqlite_6_to_4.sql
core/scripts/migration/sqlite_6_to_4.sql
+7
-0
core/src/sdk/examples/partition/src/ClientTest.cpp
core/src/sdk/examples/partition/src/ClientTest.cpp
+1
-0
core/src/sdk/examples/simple/src/ClientTest.cpp
core/src/sdk/examples/simple/src/ClientTest.cpp
+1
-0
core/src/sdk/examples/utils/Utils.cpp
core/src/sdk/examples/utils/Utils.cpp
+17
-18
core/src/sdk/grpc/ClientProxy.cpp
core/src/sdk/grpc/ClientProxy.cpp
+11
-6
core/src/sdk/include/MilvusApi.h
core/src/sdk/include/MilvusApi.h
+2
-2
未找到文件。
CHANGELOG.md
浏览文件 @
b9f3c4fc
...
@@ -39,6 +39,7 @@ Please mark all change in change log and use the ticket from JIRA.
...
@@ -39,6 +39,7 @@ Please mark all change in change log and use the ticket from JIRA.
-
\#
358 - Add more information in build.sh and install.md
-
\#
358 - Add more information in build.sh and install.md
-
\#
404 - Add virtual method Init() in Pass abstract class
-
\#
404 - Add virtual method Init() in Pass abstract class
-
\#
409 - Add a Fallback pass in optimizer
-
\#
409 - Add a Fallback pass in optimizer
-
\#
433 - C++ SDK query result is not easy to use
## Task
## Task
...
...
core/migration/README.md
→
core/
scripts/
migration/README.md
浏览文件 @
b9f3c4fc
文件已移动
core/migration/mysql_4_to_6.sql
→
core/
scripts/
migration/mysql_4_to_6.sql
浏览文件 @
b9f3c4fc
文件已移动
core/scripts/migration/mysql_6_to_4.sql
0 → 100644
浏览文件 @
b9f3c4fc
alter
table
Tables
drop
column
owner_table
;
alter
table
Tables
drop
column
partition_tag
;
alter
table
Tables
drop
column
version
;
core/migration/sqlite_4_to_6.sql
→
core/
scripts/
migration/sqlite_4_to_6.sql
浏览文件 @
b9f3c4fc
文件已移动
core/scripts/migration/sqlite_6_to_4.sql
0 → 100644
浏览文件 @
b9f3c4fc
CREATE
TABLE
'TempTables'
(
'id'
INTEGER
PRIMARY
KEY
NOT
NULL
,
'table_id'
TEXT
UNIQUE
NOT
NULL
,
'state'
INTEGER
NOT
NULL
,
'dimension'
INTEGER
NOT
NULL
,
'created_on'
INTEGER
NOT
NULL
,
'flag'
INTEGER
DEFAULT
0
NOT
NULL
,
'index_file_size'
INTEGER
NOT
NULL
,
'engine_type'
INTEGER
NOT
NULL
,
'nlist'
INTEGER
NOT
NULL
,
'metric_type'
INTEGER
NOT
NULL
);
INSERT
INTO
TempTables
SELECT
id
,
table_id
,
state
,
dimension
,
created_on
,
flag
,
index_file_size
,
engine_type
,
nlist
,
metric_type
FROM
Tables
;
DROP
TABLE
Tables
;
ALTER
TABLE
TempTables
RENAME
TO
Tables
;
core/src/sdk/examples/partition/src/ClientTest.cpp
浏览文件 @
b9f3c4fc
...
@@ -148,6 +148,7 @@ ClientTest::Test(const std::string& address, const std::string& port) {
...
@@ -148,6 +148,7 @@ ClientTest::Test(const std::string& address, const std::string& port) {
}
}
{
// wait unit build index finish
{
// wait unit build index finish
milvus_sdk
::
TimeRecorder
rc
(
"Create index"
);
std
::
cout
<<
"Wait until create all index done"
<<
std
::
endl
;
std
::
cout
<<
"Wait until create all index done"
<<
std
::
endl
;
milvus
::
IndexParam
index1
=
BuildIndexParam
();
milvus
::
IndexParam
index1
=
BuildIndexParam
();
milvus_sdk
::
Utils
::
PrintIndexParam
(
index1
);
milvus_sdk
::
Utils
::
PrintIndexParam
(
index1
);
...
...
core/src/sdk/examples/simple/src/ClientTest.cpp
浏览文件 @
b9f3c4fc
...
@@ -150,6 +150,7 @@ ClientTest::Test(const std::string& address, const std::string& port) {
...
@@ -150,6 +150,7 @@ ClientTest::Test(const std::string& address, const std::string& port) {
}
}
{
// wait unit build index finish
{
// wait unit build index finish
milvus_sdk
::
TimeRecorder
rc
(
"Create index"
);
std
::
cout
<<
"Wait until create all index done"
<<
std
::
endl
;
std
::
cout
<<
"Wait until create all index done"
<<
std
::
endl
;
milvus
::
IndexParam
index1
=
BuildIndexParam
();
milvus
::
IndexParam
index1
=
BuildIndexParam
();
milvus_sdk
::
Utils
::
PrintIndexParam
(
index1
);
milvus_sdk
::
Utils
::
PrintIndexParam
(
index1
);
...
...
core/src/sdk/examples/utils/Utils.cpp
浏览文件 @
b9f3c4fc
...
@@ -157,18 +157,20 @@ void
...
@@ -157,18 +157,20 @@ void
Utils
::
PrintSearchResult
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>&
search_record_array
,
Utils
::
PrintSearchResult
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>&
search_record_array
,
const
milvus
::
TopKQueryResult
&
topk_query_result
)
{
const
milvus
::
TopKQueryResult
&
topk_query_result
)
{
BLOCK_SPLITER
BLOCK_SPLITER
size_t
nq
=
topk_query_result
.
row_num
;
std
::
cout
<<
"Returned result count: "
<<
topk_query_result
.
size
()
<<
std
::
endl
;
size_t
topk
=
topk_query_result
.
ids
.
size
()
/
nq
;
std
::
cout
<<
"Returned result count: "
<<
nq
*
topk
<<
std
::
endl
;
int32_t
index
=
0
;
if
(
topk_query_result
.
size
()
!=
search_record_array
.
size
())
{
for
(
size_t
i
=
0
;
i
<
nq
;
i
++
)
{
std
::
cout
<<
"ERROR: Returned result count dones equal nq"
<<
std
::
endl
;
auto
search_id
=
search_record_array
[
index
].
first
;
return
;
index
++
;
}
std
::
cout
<<
"No."
<<
index
<<
" vector "
<<
search_id
<<
" top "
<<
topk
<<
" search result:"
<<
std
::
endl
;
for
(
size_t
i
=
0
;
i
<
topk_query_result
.
size
();
i
++
)
{
const
milvus
::
QueryResult
&
one_result
=
topk_query_result
[
i
];
size_t
topk
=
one_result
.
ids
.
size
();
auto
search_id
=
search_record_array
[
i
].
first
;
std
::
cout
<<
"No."
<<
i
<<
" vector "
<<
search_id
<<
" top "
<<
topk
<<
" search result:"
<<
std
::
endl
;
for
(
size_t
j
=
0
;
j
<
topk
;
j
++
)
{
for
(
size_t
j
=
0
;
j
<
topk
;
j
++
)
{
size_t
idx
=
i
*
topk
+
j
;
std
::
cout
<<
"
\t
"
<<
one_result
.
ids
[
j
]
<<
"
\t
"
<<
one_result
.
distances
[
j
]
<<
std
::
endl
;
std
::
cout
<<
"
\t
"
<<
topk_query_result
.
ids
[
idx
]
<<
"
\t
"
<<
topk_query_result
.
distances
[
idx
]
<<
std
::
endl
;
}
}
}
}
BLOCK_SPLITER
BLOCK_SPLITER
...
@@ -178,12 +180,11 @@ void
...
@@ -178,12 +180,11 @@ void
Utils
::
CheckSearchResult
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>&
search_record_array
,
Utils
::
CheckSearchResult
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>&
search_record_array
,
const
milvus
::
TopKQueryResult
&
topk_query_result
)
{
const
milvus
::
TopKQueryResult
&
topk_query_result
)
{
BLOCK_SPLITER
BLOCK_SPLITER
size_t
nq
=
topk_query_result
.
row_num
;
size_t
nq
=
topk_query_result
.
size
();
size_t
result_k
=
topk_query_result
.
ids
.
size
()
/
nq
;
int64_t
index
=
0
;
for
(
size_t
i
=
0
;
i
<
nq
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
nq
;
i
++
)
{
auto
result_id
=
topk_query_result
.
ids
[
i
*
result_k
];
const
milvus
::
QueryResult
&
one_result
=
topk_query_result
[
i
];
auto
search_id
=
search_record_array
[
index
++
].
first
;
auto
search_id
=
search_record_array
[
i
].
first
;
int64_t
result_id
=
one_result
.
ids
[
0
];
if
(
result_id
!=
search_id
)
{
if
(
result_id
!=
search_id
)
{
std
::
cout
<<
"The top 1 result is wrong: "
<<
result_id
<<
" vs. "
<<
search_id
<<
std
::
endl
;
std
::
cout
<<
"The top 1 result is wrong: "
<<
result_id
<<
" vs. "
<<
search_id
<<
std
::
endl
;
}
else
{
}
else
{
...
@@ -198,9 +199,7 @@ Utils::DoSearch(std::shared_ptr<milvus::Connection> conn, const std::string& tab
...
@@ -198,9 +199,7 @@ Utils::DoSearch(std::shared_ptr<milvus::Connection> conn, const std::string& tab
const
std
::
vector
<
std
::
string
>&
partiton_tags
,
int64_t
top_k
,
int64_t
nprobe
,
const
std
::
vector
<
std
::
string
>&
partiton_tags
,
int64_t
top_k
,
int64_t
nprobe
,
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>&
search_record_array
,
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>&
search_record_array
,
milvus
::
TopKQueryResult
&
topk_query_result
)
{
milvus
::
TopKQueryResult
&
topk_query_result
)
{
topk_query_result
.
distances
.
clear
();
topk_query_result
.
clear
();
topk_query_result
.
ids
.
clear
();
topk_query_result
.
row_num
=
0
;
std
::
vector
<
milvus
::
Range
>
query_range_array
;
std
::
vector
<
milvus
::
Range
>
query_range_array
;
milvus
::
Range
rg
;
milvus
::
Range
rg
;
...
...
core/src/sdk/grpc/ClientProxy.cpp
浏览文件 @
b9f3c4fc
...
@@ -250,12 +250,17 @@ ClientProxy::Search(const std::string& table_name, const std::vector<std::string
...
@@ -250,12 +250,17 @@ ClientProxy::Search(const std::string& table_name, const std::vector<std::string
Status
status
=
client_ptr_
->
Search
(
result
,
search_param
);
Status
status
=
client_ptr_
->
Search
(
result
,
search_param
);
// step 4: convert result array
// step 4: convert result array
topk_query_result
.
row_num
=
result
.
row_num
();
topk_query_result
.
reserve
(
result
.
row_num
());
topk_query_result
.
ids
.
resize
(
result
.
ids
().
size
());
int64_t
nq
=
result
.
row_num
();
memcpy
(
topk_query_result
.
ids
.
data
(),
result
.
ids
().
data
(),
result
.
ids
().
size
()
*
sizeof
(
int64_t
));
int64_t
topk
=
result
.
ids
().
size
()
/
nq
;
topk_query_result
.
distances
.
resize
(
result
.
distances
().
size
());
for
(
int64_t
i
=
0
;
i
<
result
.
row_num
();
i
++
)
{
memcpy
(
topk_query_result
.
distances
.
data
(),
result
.
distances
().
data
(),
milvus
::
QueryResult
one_result
;
result
.
distances
().
size
()
*
sizeof
(
float
));
one_result
.
ids
.
resize
(
topk
);
one_result
.
distances
.
resize
(
topk
);
memcpy
(
one_result
.
ids
.
data
(),
result
.
ids
().
data
()
+
topk
*
i
,
topk
*
sizeof
(
int64_t
));
memcpy
(
one_result
.
distances
.
data
(),
result
.
distances
().
data
()
+
topk
*
i
,
topk
*
sizeof
(
float
));
topk_query_result
.
emplace_back
(
one_result
);
}
return
status
;
return
status
;
}
catch
(
std
::
exception
&
ex
)
{
}
catch
(
std
::
exception
&
ex
)
{
...
...
core/src/sdk/include/MilvusApi.h
浏览文件 @
b9f3c4fc
...
@@ -81,11 +81,11 @@ struct RowRecord {
...
@@ -81,11 +81,11 @@ struct RowRecord {
/**
/**
* @brief TopK query result
* @brief TopK query result
*/
*/
struct
TopKQueryResult
{
struct
QueryResult
{
int64_t
row_num
;
std
::
vector
<
int64_t
>
ids
;
std
::
vector
<
int64_t
>
ids
;
std
::
vector
<
float
>
distances
;
std
::
vector
<
float
>
distances
;
};
};
using
TopKQueryResult
=
std
::
vector
<
QueryResult
>
;
/**
/**
* @brief index parameters
* @brief index parameters
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录