Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
35da3638
milvus
项目概览
BaiXuePrincess
/
milvus
与 Fork 源项目一致
从无法访问的项目Fork
通知
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,发现更多精彩内容 >>
提交
35da3638
编写于
7月 12, 2019
作者:
G
groot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MS-208 Add buildinde interface for C++ SDK
Former-commit-id: f718eb611f6a0e7686b1b20c89da6aaf914689eb
上级
ddf48c45
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
101 addition
and
21 deletion
+101
-21
cpp/CHANGELOG.md
cpp/CHANGELOG.md
+1
-0
cpp/src/db/EngineFactory.cpp
cpp/src/db/EngineFactory.cpp
+3
-3
cpp/src/db/FaissExecutionEngine.cpp
cpp/src/db/FaissExecutionEngine.cpp
+3
-2
cpp/src/db/FaissExecutionEngine.h
cpp/src/db/FaissExecutionEngine.h
+3
-0
cpp/src/sdk/examples/simple/src/ClientTest.cpp
cpp/src/sdk/examples/simple/src/ClientTest.cpp
+55
-16
cpp/src/sdk/include/MilvusApi.h
cpp/src/sdk/include/MilvusApi.h
+11
-0
cpp/src/sdk/src/client/ClientProxy.cpp
cpp/src/sdk/src/client/ClientProxy.cpp
+16
-0
cpp/src/sdk/src/client/ClientProxy.h
cpp/src/sdk/src/client/ClientProxy.h
+2
-0
cpp/src/sdk/src/interface/ConnectionImpl.cpp
cpp/src/sdk/src/interface/ConnectionImpl.cpp
+5
-0
cpp/src/sdk/src/interface/ConnectionImpl.h
cpp/src/sdk/src/interface/ConnectionImpl.h
+2
-0
未找到文件。
cpp/CHANGELOG.md
浏览文件 @
35da3638
...
@@ -17,6 +17,7 @@ Please mark all change in change log and use the ticket from JIRA.
...
@@ -17,6 +17,7 @@ Please mark all change in change log and use the ticket from JIRA.
-
MS-152 - Delete assert in MySQLMetaImpl and change MySQLConnectionPool impl
-
MS-152 - Delete assert in MySQLMetaImpl and change MySQLConnectionPool impl
-
MS-204 - Support multi db_path
-
MS-204 - Support multi db_path
-
MS-206 - Support SQ8 index type
-
MS-206 - Support SQ8 index type
-
MS-208 - Add buildinde interface for C++ SDK
## New Feature
## New Feature
-
MS-195 - Add nlist and use_blas_threshold conf
-
MS-195 - Add nlist and use_blas_threshold conf
...
...
cpp/src/db/EngineFactory.cpp
浏览文件 @
35da3638
...
@@ -22,19 +22,19 @@ EngineFactory::Build(uint16_t dimension,
...
@@ -22,19 +22,19 @@ EngineFactory::Build(uint16_t dimension,
switch
(
type
)
{
switch
(
type
)
{
case
EngineType
::
FAISS_IDMAP
:
{
case
EngineType
::
FAISS_IDMAP
:
{
execution_engine_ptr
=
execution_engine_ptr
=
ExecutionEnginePtr
(
new
FaissExecutionEngine
(
dimension
,
location
,
"IDMap"
,
"IDMap,Flat"
));
ExecutionEnginePtr
(
new
FaissExecutionEngine
(
dimension
,
location
,
BUILD_INDEX_TYPE_IDMAP
,
"IDMap,Flat"
));
break
;
break
;
}
}
case
EngineType
::
FAISS_IVFFLAT
:
{
case
EngineType
::
FAISS_IVFFLAT
:
{
execution_engine_ptr
=
execution_engine_ptr
=
ExecutionEnginePtr
(
new
FaissExecutionEngine
(
dimension
,
location
,
"IVF"
,
"IDMap,Flat"
));
ExecutionEnginePtr
(
new
FaissExecutionEngine
(
dimension
,
location
,
BUILD_INDEX_TYPE_IVF
,
"IDMap,Flat"
));
break
;
break
;
}
}
case
EngineType
::
FAISS_IVFSQ8
:
{
case
EngineType
::
FAISS_IVFSQ8
:
{
execution_engine_ptr
=
execution_engine_ptr
=
ExecutionEnginePtr
(
new
FaissExecutionEngine
(
dimension
,
location
,
"IVFSQ8"
,
"IDMap,Flat"
));
ExecutionEnginePtr
(
new
FaissExecutionEngine
(
dimension
,
location
,
BUILD_INDEX_TYPE_IVFSQ8
,
"IDMap,Flat"
));
break
;
break
;
}
}
...
...
cpp/src/db/FaissExecutionEngine.cpp
浏览文件 @
35da3638
...
@@ -162,7 +162,8 @@ Status FaissExecutionEngine::Cache() {
...
@@ -162,7 +162,8 @@ Status FaissExecutionEngine::Cache() {
Status
FaissExecutionEngine
::
Init
()
{
Status
FaissExecutionEngine
::
Init
()
{
if
(
build_index_type_
==
"IVF"
)
{
if
(
build_index_type_
==
BUILD_INDEX_TYPE_IVF
||
build_index_type_
==
BUILD_INDEX_TYPE_IVFSQ8
)
{
using
namespace
zilliz
::
milvus
::
server
;
using
namespace
zilliz
::
milvus
::
server
;
ServerConfig
&
config
=
ServerConfig
::
GetInstance
();
ServerConfig
&
config
=
ServerConfig
::
GetInstance
();
...
@@ -170,7 +171,7 @@ Status FaissExecutionEngine::Init() {
...
@@ -170,7 +171,7 @@ Status FaissExecutionEngine::Init() {
nprobe_
=
engine_config
.
GetInt32Value
(
CONFIG_NPROBE
,
1000
);
nprobe_
=
engine_config
.
GetInt32Value
(
CONFIG_NPROBE
,
1000
);
nlist_
=
engine_config
.
GetInt32Value
(
CONFIG_NLIST
,
16384
);
nlist_
=
engine_config
.
GetInt32Value
(
CONFIG_NLIST
,
16384
);
}
else
if
(
build_index_type_
==
"IDMap"
)
{
}
else
if
(
build_index_type_
==
BUILD_INDEX_TYPE_IDMAP
)
{
;
;
}
else
{
}
else
{
return
Status
::
Error
(
"Wrong index type: "
,
build_index_type_
);
return
Status
::
Error
(
"Wrong index type: "
,
build_index_type_
);
...
...
cpp/src/db/FaissExecutionEngine.h
浏览文件 @
35da3638
...
@@ -15,6 +15,9 @@ namespace zilliz {
...
@@ -15,6 +15,9 @@ namespace zilliz {
namespace
milvus
{
namespace
milvus
{
namespace
engine
{
namespace
engine
{
const
static
std
::
string
BUILD_INDEX_TYPE_IDMAP
=
"IDMap"
;
const
static
std
::
string
BUILD_INDEX_TYPE_IVF
=
"IVF"
;
const
static
std
::
string
BUILD_INDEX_TYPE_IVFSQ8
=
"IVFSQ8"
;
class
FaissExecutionEngine
:
public
ExecutionEngine
{
class
FaissExecutionEngine
:
public
ExecutionEngine
{
public:
public:
...
...
cpp/src/sdk/examples/simple/src/ClientTest.cpp
浏览文件 @
35da3638
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include <iostream>
#include <iostream>
#include <time.h>
#include <time.h>
#include <chrono>
#include <unistd.h>
#include <unistd.h>
using
namespace
::
milvus
;
using
namespace
::
milvus
;
...
@@ -126,6 +127,43 @@ namespace {
...
@@ -126,6 +127,43 @@ namespace {
std
::
cout
<<
"Waiting "
<<
seconds
<<
" seconds ..."
<<
std
::
endl
;
std
::
cout
<<
"Waiting "
<<
seconds
<<
" seconds ..."
<<
std
::
endl
;
sleep
(
seconds
);
sleep
(
seconds
);
}
}
class
TimeRecorder
{
public:
TimeRecorder
(
const
std
::
string
&
title
)
:
title_
(
title
)
{
start_
=
std
::
chrono
::
system_clock
::
now
();
}
~
TimeRecorder
()
{
std
::
chrono
::
system_clock
::
time_point
end
=
std
::
chrono
::
system_clock
::
now
();
long
span
=
(
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
end
-
start_
)).
count
();
std
::
cout
<<
title_
<<
" totally cost: "
<<
span
<<
" ms"
<<
std
::
endl
;
}
private:
std
::
string
title_
;
std
::
chrono
::
system_clock
::
time_point
start_
;
};
void
DoSearch
(
std
::
shared_ptr
<
Connection
>
conn
,
const
std
::
vector
<
RowRecord
>&
record_array
,
const
std
::
string
&
phase_name
)
{
std
::
vector
<
Range
>
query_range_array
;
Range
rg
;
rg
.
start_value
=
CurrentTmDate
();
rg
.
end_value
=
CurrentTmDate
();
query_range_array
.
emplace_back
(
rg
);
std
::
vector
<
TopKQueryResult
>
topk_query_result_array
;
{
TimeRecorder
rc
(
phase_name
);
Status
stat
=
conn
->
SearchVector
(
TABLE_NAME
,
record_array
,
query_range_array
,
TOP_K
,
topk_query_result_array
);
std
::
cout
<<
"SearchVector function call status: "
<<
stat
.
ToString
()
<<
std
::
endl
;
}
PrintSearchResult
(
topk_query_result_array
);
}
}
}
void
void
...
@@ -188,28 +226,29 @@ ClientTest::Test(const std::string& address, const std::string& port) {
...
@@ -188,28 +226,29 @@ ClientTest::Test(const std::string& address, const std::string& port) {
PrintRecordIdArray
(
record_ids
);
PrintRecordIdArray
(
record_ids
);
}
}
{
//search vectors
std
::
vector
<
RowRecord
>
search_record_array
;
Sleep
(
2
);
BuildVectors
(
SEARCH_TARGET
,
SEARCH_TARGET
+
NQ
,
search_record_array
);
std
::
vector
<
RowRecord
>
record_array
;
{
//search vectors without index
BuildVectors
(
SEARCH_TARGET
,
SEARCH_TARGET
+
NQ
,
record_array
);
Sleep
(
2
);
DoSearch
(
conn
,
search_record_array
,
"Search without index"
);
}
std
::
vector
<
Range
>
query_range_array
;
{
//wait unit build index finish
Range
rg
;
std
::
cout
<<
"Wait until build all index done"
<<
std
::
endl
;
rg
.
start_value
=
CurrentTmDate
();
Status
stat
=
conn
->
BuildIndex
(
TABLE_NAME
);
rg
.
end_value
=
CurrentTmDate
();
std
::
cout
<<
"BuildIndex function call status: "
<<
stat
.
ToString
()
<<
std
::
endl
;
query_range_array
.
emplace_back
(
rg
);
std
::
vector
<
TopKQueryResult
>
topk_query_result_array
;
Status
stat
=
conn
->
SearchVector
(
TABLE_NAME
,
record_array
,
query_range_array
,
TOP_K
,
topk_query_result_array
);
std
::
cout
<<
"SearchVector function call status: "
<<
stat
.
ToString
()
<<
std
::
endl
;
PrintSearchResult
(
topk_query_result_array
);
}
}
{
//delete table
{
//search vectors after build index finish
Status
stat
=
conn
->
DeleteTable
(
TABLE_NAME
);
DoSearch
(
conn
,
search_record_array
,
"Search after build index finish"
);
std
::
cout
<<
"DeleteTable function call status: "
<<
stat
.
ToString
()
<<
std
::
endl
;
}
}
// {//delete table
// Status stat = conn->DeleteTable(TABLE_NAME);
// std::cout << "DeleteTable function call status: " << stat.ToString() << std::endl;
// }
{
//server status
{
//server status
std
::
string
status
=
conn
->
ServerStatus
();
std
::
string
status
=
conn
->
ServerStatus
();
std
::
cout
<<
"Server status before disconnect: "
<<
status
<<
std
::
endl
;
std
::
cout
<<
"Server status before disconnect: "
<<
status
<<
std
::
endl
;
...
...
cpp/src/sdk/include/MilvusApi.h
浏览文件 @
35da3638
...
@@ -181,6 +181,17 @@ public:
...
@@ -181,6 +181,17 @@ public:
virtual
Status
DeleteTable
(
const
std
::
string
&
table_name
)
=
0
;
virtual
Status
DeleteTable
(
const
std
::
string
&
table_name
)
=
0
;
/**
* @brief Build index method
*
* This method is used to build index for whole table
*
* @param table_name, table name is going to be build index.
*
* @return Indicate if build index successfully.
*/
virtual
Status
BuildIndex
(
const
std
::
string
&
table_name
)
=
0
;
/**
/**
* @brief Add vector to table
* @brief Add vector to table
*
*
...
...
cpp/src/sdk/src/client/ClientProxy.cpp
浏览文件 @
35da3638
...
@@ -126,6 +126,22 @@ ClientProxy::DeleteTable(const std::string &table_name) {
...
@@ -126,6 +126,22 @@ ClientProxy::DeleteTable(const std::string &table_name) {
return
Status
::
OK
();
return
Status
::
OK
();
}
}
Status
ClientProxy
::
BuildIndex
(
const
std
::
string
&
table_name
)
{
if
(
!
IsConnected
())
{
return
Status
(
StatusCode
::
NotConnected
,
"not connected to server"
);
}
try
{
ClientPtr
()
->
interface
()
->
BuildIndex
(
table_name
);
}
catch
(
std
::
exception
&
ex
)
{
return
Status
(
StatusCode
::
UnknownError
,
"failed to build index: "
+
std
::
string
(
ex
.
what
()));
}
return
Status
::
OK
();
}
Status
Status
ClientProxy
::
AddVector
(
const
std
::
string
&
table_name
,
ClientProxy
::
AddVector
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
RowRecord
>
&
record_array
,
const
std
::
vector
<
RowRecord
>
&
record_array
,
...
...
cpp/src/sdk/src/client/ClientProxy.h
浏览文件 @
35da3638
...
@@ -27,6 +27,8 @@ public:
...
@@ -27,6 +27,8 @@ public:
virtual
Status
DeleteTable
(
const
std
::
string
&
table_name
)
override
;
virtual
Status
DeleteTable
(
const
std
::
string
&
table_name
)
override
;
virtual
Status
BuildIndex
(
const
std
::
string
&
table_name
)
override
;
virtual
Status
AddVector
(
const
std
::
string
&
table_name
,
virtual
Status
AddVector
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
RowRecord
>
&
record_array
,
const
std
::
vector
<
RowRecord
>
&
record_array
,
std
::
vector
<
int64_t
>
&
id_array
)
override
;
std
::
vector
<
int64_t
>
&
id_array
)
override
;
...
...
cpp/src/sdk/src/interface/ConnectionImpl.cpp
浏览文件 @
35da3638
...
@@ -66,6 +66,11 @@ ConnectionImpl::DeleteTable(const std::string &table_name) {
...
@@ -66,6 +66,11 @@ ConnectionImpl::DeleteTable(const std::string &table_name) {
return
client_proxy_
->
DeleteTable
(
table_name
);
return
client_proxy_
->
DeleteTable
(
table_name
);
}
}
Status
ConnectionImpl
::
BuildIndex
(
const
std
::
string
&
table_name
)
{
return
client_proxy_
->
BuildIndex
(
table_name
);
}
Status
Status
ConnectionImpl
::
AddVector
(
const
std
::
string
&
table_name
,
ConnectionImpl
::
AddVector
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
RowRecord
>
&
record_array
,
const
std
::
vector
<
RowRecord
>
&
record_array
,
...
...
cpp/src/sdk/src/interface/ConnectionImpl.h
浏览文件 @
35da3638
...
@@ -29,6 +29,8 @@ public:
...
@@ -29,6 +29,8 @@ public:
virtual
Status
DeleteTable
(
const
std
::
string
&
table_name
)
override
;
virtual
Status
DeleteTable
(
const
std
::
string
&
table_name
)
override
;
virtual
Status
BuildIndex
(
const
std
::
string
&
table_name
)
override
;
virtual
Status
AddVector
(
const
std
::
string
&
table_name
,
virtual
Status
AddVector
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
RowRecord
>
&
record_array
,
const
std
::
vector
<
RowRecord
>
&
record_array
,
std
::
vector
<
int64_t
>
&
id_array
)
override
;
std
::
vector
<
int64_t
>
&
id_array
)
override
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录