Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
add9f9ec
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,发现更多精彩内容 >>
提交
add9f9ec
编写于
8月 13, 2019
作者:
G
groot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean code
Former-commit-id: e283d5da7a6d24f4d0cda3eed6f5620f779a889f
上级
cb4ba39f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
82 addition
and
86 deletion
+82
-86
cpp/build.sh
cpp/build.sh
+1
-1
cpp/src/CMakeLists.txt
cpp/src/CMakeLists.txt
+10
-25
cpp/src/sdk/CMakeLists.txt
cpp/src/sdk/CMakeLists.txt
+8
-12
cpp/src/sdk/examples/grpcsimple/CMakeLists.txt
cpp/src/sdk/examples/grpcsimple/CMakeLists.txt
+4
-4
cpp/src/sdk/examples/thriftsimple/CMakeLists.txt
cpp/src/sdk/examples/thriftsimple/CMakeLists.txt
+4
-4
cpp/src/sdk/examples/thriftsimple/src/ClientTest.cpp
cpp/src/sdk/examples/thriftsimple/src/ClientTest.cpp
+8
-6
cpp/src/sdk/thrift/ClientProxy.cpp
cpp/src/sdk/thrift/ClientProxy.cpp
+24
-18
cpp/src/sdk/thrift/ClientProxy.h
cpp/src/sdk/thrift/ClientProxy.h
+12
-10
cpp/src/server/Server.cpp
cpp/src/server/Server.cpp
+11
-6
未找到文件。
cpp/build.sh
浏览文件 @
add9f9ec
...
...
@@ -11,7 +11,7 @@ PROFILING="OFF"
BUILD_FAISS_WITH_MKL
=
"OFF"
USE_JFROG_CACHE
=
"OFF"
KNOWHERE_OPTS
=
""
MILVUS_WITH_THRIFT
=
"O
FF
"
MILVUS_WITH_THRIFT
=
"O
N
"
while
getopts
"p:d:t:uhlrcgmj"
arg
do
...
...
cpp/src/CMakeLists.txt
浏览文件 @
add9f9ec
...
...
@@ -80,9 +80,12 @@ include_directories(grpc/gen-status)
include_directories
(
grpc/gen-milvus
)
if
(
MILVUS_WITH_THRIFT STREQUAL
"ON"
)
message
(
"Build thrift server"
)
add_definitions
(
"-DMILVUS_ENABLE_THRIFT"
)
set
(
client_thrift_lib
thrift
)
else
()
message
(
"Build grpc server"
)
set
(
client_grpc_lib
grpcpp_channelz
grpc++
...
...
@@ -200,7 +203,7 @@ set(knowhere_libs
)
if
(
MILVUS_WITH_THRIFT STREQUAL
"ON"
)
add_executable
(
milvus_
thrift_
server
add_executable
(
milvus_server
${
config_files
}
${
server_files
}
${
thriftserver_files
}
...
...
@@ -219,33 +222,15 @@ else()
)
endif
()
if
(
ENABLE_LICENSE STREQUAL
"ON"
)
add_executable
(
get_sys_info
${
get_sys_info_files
}
)
add_executable
(
license_generator
${
license_generator_files
}
)
target_link_libraries
(
get_sys_info
${
license_libs
}
license_check
${
third_party_libs
}
)
target_link_libraries
(
license_generator
${
license_libs
}
${
third_party_libs
}
)
if
(
MILVUS_WITH_THRIFT STREQUAL
"ON"
)
target_link_libraries
(
milvus_thrift_server
${
server_libs
}
license_check
${
knowhere_libs
}
${
third_party_libs
}
)
else
()
target_link_libraries
(
milvus_server
${
server_libs
}
license_check
${
knowhere_libs
}
${
third_party_libs
}
)
endif
()
else
()
if
(
MILVUS_WITH_THRIFT STREQUAL
"ON"
)
target_link_libraries
(
milvus_thrift_server
${
server_libs
}
${
knowhere_libs
}
${
third_party_libs
}
)
else
()
target_link_libraries
(
milvus_server
${
server_libs
}
${
knowhere_libs
}
${
third_party_libs
}
)
endif
()
endif
()
if
(
MILVUS_WITH_THRIFT STREQUAL
"ON"
)
install
(
TARGETS milvus_thrift_server DESTINATION bin
)
if
(
MILVUS_WITH_THRIFT STREQUAL
"ON"
)
target_link_libraries
(
milvus_server
${
server_libs
}
${
knowhere_libs
}
${
third_party_libs
}
)
else
()
install
(
TARGETS milvus_server DESTINATION bin
)
target_link_libraries
(
milvus_server
${
server_libs
}
${
knowhere_libs
}
${
third_party_libs
}
)
endif
()
install
(
TARGETS milvus_server DESTINATION bin
)
install
(
FILES
${
KNOWHERE_BUILD_DIR
}
/lib/
${
CMAKE_SHARED_LIBRARY_PREFIX
}
tbb
${
CMAKE_SHARED_LIBRARY_SUFFIX
}
${
KNOWHERE_BUILD_DIR
}
/lib/
${
CMAKE_SHARED_LIBRARY_PREFIX
}
tbb
${
CMAKE_SHARED_LIBRARY_SUFFIX
}
.2
...
...
cpp/src/sdk/CMakeLists.txt
浏览文件 @
add9f9ec
...
...
@@ -23,17 +23,12 @@ if (MILVUS_WITH_THRIFT STREQUAL "ON")
${
CMAKE_SOURCE_DIR
}
/src/thrift/gen-cpp/milvus_types.cpp
)
add_library
(
milvus_
thrift_
sdk STATIC
add_library
(
milvus_sdk STATIC
${
interface_files
}
${
thrift_client_files
}
${
util_files
}
${
thrift_service_files
}
)
target_link_libraries
(
milvus_thrift_sdk
${
third_party_libs
}
)
install
(
TARGETS milvus_thrift_sdk DESTINATION lib
)
else
()
aux_source_directory
(
grpc grpc_client_files
)
...
...
@@ -47,17 +42,18 @@ else()
${
CMAKE_SOURCE_DIR
}
/src/grpc/gen-status/status.pb.cc
)
add_library
(
milvus_
grpc_
sdk STATIC
add_library
(
milvus_sdk STATIC
${
interface_files
}
${
grpc_client_files
}
${
util_files
}
${
grpc_service_files
}
)
target_link_libraries
(
milvus_grpc_sdk
${
third_party_libs
}
)
install
(
TARGETS milvus_grpc_sdk DESTINATION lib
)
endif
()
target_link_libraries
(
milvus_sdk
${
third_party_libs
}
)
install
(
TARGETS milvus_sdk DESTINATION lib
)
add_subdirectory
(
examples
)
cpp/src/sdk/examples/grpcsimple/CMakeLists.txt
浏览文件 @
add9f9ec
...
...
@@ -11,14 +11,14 @@ include_directories(../../include)
link_directories
(
${
CMAKE_BINARY_DIR
}
)
add_executable
(
grpc_
sdk_simple
add_executable
(
sdk_simple
main.cpp
${
src_files
}
)
target_link_libraries
(
grpc_
sdk_simple
milvus_
grpc_
sdk
target_link_libraries
(
sdk_simple
milvus_sdk
pthread
)
install
(
TARGETS
grpc_
sdk_simple DESTINATION bin
)
install
(
TARGETS sdk_simple DESTINATION bin
)
cpp/src/sdk/examples/thriftsimple/CMakeLists.txt
浏览文件 @
add9f9ec
...
...
@@ -11,14 +11,14 @@ include_directories(../../include)
link_directories
(
${
CMAKE_BINARY_DIR
}
)
add_executable
(
thrift_
sdk_simple
add_executable
(
sdk_simple
./main.cpp
${
src_files
}
)
target_link_libraries
(
thrift_
sdk_simple
milvus_
thrift_
sdk
target_link_libraries
(
sdk_simple
milvus_sdk
pthread
)
install
(
TARGETS
thrift_
sdk_simple DESTINATION bin
)
install
(
TARGETS sdk_simple DESTINATION bin
)
cpp/src/sdk/examples/thriftsimple/src/ClientTest.cpp
浏览文件 @
add9f9ec
...
...
@@ -22,7 +22,7 @@ namespace {
constexpr
int64_t
NQ
=
10
;
constexpr
int64_t
TOP_K
=
10
;
constexpr
int64_t
SEARCH_TARGET
=
5000
;
//change this value, result is different
constexpr
int64_t
ADD_VECTOR_LOOP
=
10
;
constexpr
int64_t
ADD_VECTOR_LOOP
=
5
;
constexpr
int64_t
SECONDS_EACH_HOUR
=
3600
;
#define BLOCK_SPLITER std::cout << "===========================================" << std::endl;
...
...
@@ -173,7 +173,7 @@ namespace {
std
::
vector
<
TopKQueryResult
>
topk_query_result_array
;
{
TimeRecorder
rc
(
phase_name
);
Status
stat
=
conn
->
Search
Vector
(
TABLE_NAME
,
record_array
,
query_range_array
,
TOP_K
,
topk_query_result_array
);
Status
stat
=
conn
->
Search
(
TABLE_NAME
,
record_array
,
query_range_array
,
TOP_K
,
topk_query_result_array
);
std
::
cout
<<
"SearchVector function call status: "
<<
stat
.
ToString
()
<<
std
::
endl
;
}
...
...
@@ -209,7 +209,7 @@ ClientTest::Test(const std::string& address, const std::string& port) {
std
::
cout
<<
"All tables: "
<<
std
::
endl
;
for
(
auto
&
table
:
tables
)
{
int64_t
row_count
=
0
;
stat
=
conn
->
GetTableRowCount
(
table
,
row_count
);
stat
=
conn
->
CountTable
(
table
,
row_count
);
std
::
cout
<<
"
\t
"
<<
table
<<
"("
<<
row_count
<<
" rows)"
<<
std
::
endl
;
}
}
...
...
@@ -241,7 +241,7 @@ ClientTest::Test(const std::string& address, const std::string& port) {
int64_t
begin_index
=
i
*
BATCH_ROW_COUNT
;
BuildVectors
(
begin_index
,
begin_index
+
BATCH_ROW_COUNT
,
record_array
);
std
::
vector
<
int64_t
>
record_ids
;
Status
stat
=
conn
->
AddVector
(
TABLE_NAME
,
record_array
,
record_ids
);
Status
stat
=
conn
->
Insert
(
TABLE_NAME
,
record_array
,
record_ids
);
std
::
cout
<<
"AddVector function call status: "
<<
stat
.
ToString
()
<<
std
::
endl
;
std
::
cout
<<
"Returned id array count: "
<<
record_ids
.
size
()
<<
std
::
endl
;
...
...
@@ -261,7 +261,9 @@ ClientTest::Test(const std::string& address, const std::string& port) {
{
//wait unit build index finish
TimeRecorder
recorder
(
"Build index"
);
std
::
cout
<<
"Wait until build all index done"
<<
std
::
endl
;
Status
stat
=
conn
->
BuildIndex
(
TABLE_NAME
);
IndexParam
index_param
;
index_param
.
table_name
=
TABLE_NAME
;
Status
stat
=
conn
->
CreateIndex
(
index_param
);
std
::
cout
<<
"BuildIndex function call status: "
<<
stat
.
ToString
()
<<
std
::
endl
;
}
...
...
@@ -270,7 +272,7 @@ ClientTest::Test(const std::string& address, const std::string& port) {
}
{
//delete table
Status
stat
=
conn
->
D
elete
Table
(
TABLE_NAME
);
Status
stat
=
conn
->
D
rop
Table
(
TABLE_NAME
);
std
::
cout
<<
"DeleteTable function call status: "
<<
stat
.
ToString
()
<<
std
::
endl
;
}
...
...
cpp/src/sdk/thrift/ClientProxy.cpp
浏览文件 @
add9f9ec
...
...
@@ -112,7 +112,7 @@ ClientProxy::HasTable(const std::string &table_name) {
}
Status
ClientProxy
::
D
elete
Table
(
const
std
::
string
&
table_name
)
{
ClientProxy
::
D
rop
Table
(
const
std
::
string
&
table_name
)
{
if
(
!
IsConnected
())
{
return
Status
(
StatusCode
::
NotConnected
,
"not connected to server"
);
}
...
...
@@ -128,18 +128,13 @@ ClientProxy::DeleteTable(const std::string &table_name) {
}
Status
ClientProxy
::
DropTable
(
const
std
::
string
&
table_name
)
{
return
this
->
DeleteTable
(
table_name
);
}
Status
ClientProxy
::
BuildIndex
(
const
std
::
string
&
table_name
)
{
ClientProxy
::
CreateIndex
(
const
IndexParam
&
index_param
)
{
if
(
!
IsConnected
())
{
return
Status
(
StatusCode
::
NotConnected
,
"not connected to server"
);
}
try
{
ClientPtr
()
->
interface
()
->
BuildIndex
(
table_name
);
ClientPtr
()
->
interface
()
->
BuildIndex
(
index_param
.
table_name
);
}
catch
(
std
::
exception
&
ex
)
{
return
Status
(
StatusCode
::
UnknownError
,
"failed to build index: "
+
std
::
string
(
ex
.
what
()));
...
...
@@ -149,7 +144,7 @@ ClientProxy::BuildIndex(const std::string &table_name) {
}
Status
ClientProxy
::
AddVector
(
const
std
::
string
&
table_name
,
ClientProxy
::
Insert
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
RowRecord
>
&
record_array
,
std
::
vector
<
int64_t
>
&
id_array
)
{
if
(
!
IsConnected
())
{
...
...
@@ -179,14 +174,7 @@ ClientProxy::AddVector(const std::string &table_name,
}
Status
ClientProxy
::
InsertVector
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
RowRecord
>
&
record_array
,
std
::
vector
<
int64_t
>
&
id_array
)
{
return
this
->
AddVector
(
table_name
,
record_array
,
id_array
);
}
Status
ClientProxy
::
SearchVector
(
const
std
::
string
&
table_name
,
ClientProxy
::
Search
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
RowRecord
>
&
query_record_array
,
const
std
::
vector
<
Range
>
&
query_range_array
,
int64_t
topk
,
...
...
@@ -277,7 +265,7 @@ ClientProxy::DescribeTable(const std::string &table_name, TableSchema &table_sch
}
Status
ClientProxy
::
GetTableRowCount
(
const
std
::
string
&
table_name
,
int64_t
&
row_count
)
{
ClientProxy
::
CountTable
(
const
std
::
string
&
table_name
,
int64_t
&
row_count
)
{
if
(
!
IsConnected
())
{
return
Status
(
StatusCode
::
NotConnected
,
"not connected to server"
);
}
...
...
@@ -337,5 +325,23 @@ ClientProxy::ServerStatus() const {
return
"connection lost"
;
}
}
Status
ClientProxy
::
DeleteByRange
(
Range
&
range
,
const
std
::
string
&
table_name
)
{
return
Status
::
OK
();
}
Status
ClientProxy
::
PreloadTable
(
const
std
::
string
&
table_name
)
const
{
return
Status
::
OK
();
}
IndexParam
ClientProxy
::
DescribeIndex
(
const
std
::
string
&
table_name
)
const
{
IndexParam
index_param
;
index_param
.
table_name
=
table_name
;
return
index_param
;
}
Status
ClientProxy
::
DropIndex
(
const
std
::
string
&
table_name
)
const
{
return
Status
::
OK
();
}
}
cpp/src/sdk/thrift/ClientProxy.h
浏览文件 @
add9f9ec
...
...
@@ -25,21 +25,15 @@ public:
virtual
bool
HasTable
(
const
std
::
string
&
table_name
)
override
;
virtual
Status
DeleteTable
(
const
std
::
string
&
table_name
)
override
;
virtual
Status
DropTable
(
const
std
::
string
&
table_name
)
override
;
virtual
Status
BuildIndex
(
const
std
::
string
&
table_name
)
override
;
virtual
Status
AddVector
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
RowRecord
>
&
record_array
,
std
::
vector
<
int64_t
>
&
id_array
)
override
;
virtual
Status
CreateIndex
(
const
IndexParam
&
index_param
)
override
;
virtual
Status
Insert
Vector
(
const
std
::
string
&
table_name
,
virtual
Status
Insert
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
RowRecord
>
&
record_array
,
std
::
vector
<
int64_t
>
&
id_array
)
override
;
virtual
Status
Search
Vector
(
const
std
::
string
&
table_name
,
virtual
Status
Search
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
RowRecord
>
&
query_record_array
,
const
std
::
vector
<
Range
>
&
query_range_array
,
int64_t
topk
,
...
...
@@ -47,7 +41,7 @@ public:
virtual
Status
DescribeTable
(
const
std
::
string
&
table_name
,
TableSchema
&
table_schema
)
override
;
virtual
Status
GetTableRowCount
(
const
std
::
string
&
table_name
,
int64_t
&
row_count
)
override
;
virtual
Status
CountTable
(
const
std
::
string
&
table_name
,
int64_t
&
row_count
)
override
;
virtual
Status
ShowTables
(
std
::
vector
<
std
::
string
>
&
table_array
)
override
;
...
...
@@ -57,6 +51,14 @@ public:
virtual
std
::
string
ServerStatus
()
const
override
;
virtual
Status
DeleteByRange
(
Range
&
range
,
const
std
::
string
&
table_name
)
override
;
virtual
Status
PreloadTable
(
const
std
::
string
&
table_name
)
const
override
;
virtual
IndexParam
DescribeIndex
(
const
std
::
string
&
table_name
)
const
override
;
virtual
Status
DropIndex
(
const
std
::
string
&
table_name
)
const
override
;
private:
std
::
shared_ptr
<
ThriftClient
>&
ClientPtr
()
const
;
...
...
cpp/src/server/Server.cpp
浏览文件 @
add9f9ec
...
...
@@ -6,11 +6,11 @@
#include <thread>
#include "Server.h"
//#include "ServerConfig.h"
//
#ifdef MILVUS_ENABLE_THRIFT
#ifdef MILVUS_ENABLE_THRIFT
#include "server/thrift_impl/MilvusServer.h"
//
#else
#else
#include "server/grpc_impl/GrpcMilvusServer.h"
//
#endif
#endif
#include "utils/Log.h"
#include "utils/SignalUtil.h"
...
...
@@ -225,15 +225,20 @@ Server::LoadConfig() {
void
Server
::
StartService
()
{
// std::thread thrift_thread = std::thread(&MilvusServer::StartService);
#ifdef MILVUS_ENABLE_THRIFT
MilvusServer
::
StartService
();
#else
grpc
::
GrpcMilvusServer
::
StartService
();
// thrift_thread.join();
#endif
}
void
Server
::
StopService
()
{
// MilvusServer::StartService();
#ifdef MILVUS_ENABLE_THRIFT
MilvusServer
::
StopService
();
#else
grpc
::
GrpcMilvusServer
::
StopService
();
#endif
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录