Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
541e0d61
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,发现更多精彩内容 >>
提交
541e0d61
编写于
4月 26, 2019
作者:
G
groot
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'new_orm' into jinhai
Former-commit-id: 3cc778a3f03cd9d71f91e0bb8b12f16f0aea7fbc
上级
7e00f351
52234126
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
33 addition
and
9 deletion
+33
-9
cpp/conf/server_config.yaml
cpp/conf/server_config.yaml
+1
-0
cpp/src/server/ServerConfig.h
cpp/src/server/ServerConfig.h
+1
-0
cpp/src/server/VecServiceTask.cpp
cpp/src/server/VecServiceTask.cpp
+27
-6
cpp/test_client/src/ClientApp.cpp
cpp/test_client/src/ClientApp.cpp
+4
-3
未找到文件。
cpp/conf/server_config.yaml
浏览文件 @
541e0d61
...
...
@@ -5,6 +5,7 @@ server_config:
server_mode
:
thread_pool
#optional: simple, thread_pool
db_path
:
/tmp/vecwise
db_backend_url
:
http://127.0.0.1
db_flush_interval
:
10
#unit: second
log_config
:
global
:
...
...
cpp/src/server/ServerConfig.h
浏览文件 @
541e0d61
...
...
@@ -21,6 +21,7 @@ static const std::string CONFIG_SERVER_PROTOCOL = "transfer_protocol";
static
const
std
::
string
CONFIG_SERVER_MODE
=
"server_mode"
;
static
const
std
::
string
CONFIG_SERVER_DB_URL
=
"db_backend_url"
;
static
const
std
::
string
CONFIG_SERVER_DB_PATH
=
"db_path"
;
static
const
std
::
string
CONFIG_SERVER_DB_FLUSH_INTERVAL
=
"db_flush_interval"
;
static
const
std
::
string
CONFIG_LOG
=
"log_config"
;
...
...
cpp/src/server/VecServiceTask.cpp
浏览文件 @
541e0d61
...
...
@@ -27,6 +27,7 @@ namespace {
ConfigNode
&
config
=
ServerConfig
::
GetInstance
().
GetConfig
(
CONFIG_SERVER
);
opt
.
meta
.
backend_uri
=
config
.
GetValue
(
CONFIG_SERVER_DB_URL
);
std
::
string
db_path
=
config
.
GetValue
(
CONFIG_SERVER_DB_PATH
);
opt
.
memory_sync_interval
=
(
uint16_t
)
config
.
GetInt32Value
(
CONFIG_SERVER_DB_FLUSH_INTERVAL
,
10
);
opt
.
meta
.
path
=
db_path
+
"/db"
;
CommonUtil
::
CreateDirectory
(
opt
.
meta
.
path
);
...
...
@@ -155,9 +156,29 @@ BaseTaskPtr AddSingleVectorTask::Create(const std::string& group_id,
ServerError
AddSingleVectorTask
::
OnExecute
()
{
try
{
engine
::
meta
::
GroupSchema
group_info
;
group_info
.
group_id
=
group_id_
;
engine
::
Status
stat
=
DB
()
->
get_group
(
group_info
);
if
(
!
stat
.
ok
())
{
SERVER_LOG_ERROR
<<
"Engine failed: "
<<
stat
.
ToString
();
return
SERVER_INVALID_ARGUMENT
;
}
uint64_t
vec_dim
=
group_info
.
dimension
;
if
(
vec_dim
!=
tensor_
.
tensor
.
size
())
{
SERVER_LOG_ERROR
<<
"Invalid vector dimension: "
<<
tensor_
.
tensor
.
size
()
<<
" vs. group dimension:"
<<
vec_dim
;
return
SERVER_INVALID_ARGUMENT
;
}
std
::
vector
<
float
>
vec_f
;
vec_f
.
resize
(
vec_dim
);
for
(
uint64_t
d
=
0
;
d
<
vec_dim
;
d
++
)
{
vec_f
[
d
]
=
(
float
)(
tensor_
.
tensor
[
d
]);
}
engine
::
IDNumbers
vector_ids
;
std
::
vector
<
float
>
vec_f
(
tensor_
.
tensor
.
begin
(),
tensor_
.
tensor
.
end
());
engine
::
Status
stat
=
DB
()
->
add_vectors
(
group_id_
,
1
,
vec_f
.
data
(),
vector_ids
);
stat
=
DB
()
->
add_vectors
(
group_id_
,
1
,
vec_f
.
data
(),
vector_ids
);
if
(
!
stat
.
ok
())
{
SERVER_LOG_ERROR
<<
"Engine failed: "
<<
stat
.
ToString
();
return
SERVER_UNEXPECTED_ERROR
;
...
...
@@ -213,10 +234,10 @@ ServerError AddBatchVectorTask::OnExecute() {
vec_f
.
resize
(
vec_count
*
vec_dim
);
//allocate enough memory
for
(
uint64_t
i
=
0
;
i
<
vec_count
;
i
++
)
{
const
std
::
vector
<
double
>&
tensor
=
tensor_list_
.
tensor_list
[
i
].
tensor
;
if
(
tensor
.
size
()
!=
group_info
.
dimension
)
{
SERVER_LOG_ERROR
<<
"Invalid vector d
ata size
: "
<<
tensor
.
size
()
<<
" vs. group dimension:"
<<
group_info
.
dimension
;
return
SERVER_
UNEXPECTED_ERROR
;
if
(
tensor
.
size
()
!=
vec_dim
)
{
SERVER_LOG_ERROR
<<
"Invalid vector d
imension
: "
<<
tensor
.
size
()
<<
" vs. group dimension:"
<<
vec_dim
;
return
SERVER_
INVALID_ARGUMENT
;
}
for
(
uint64_t
d
=
0
;
d
<
vec_dim
;
d
++
)
{
...
...
cpp/test_client/src/ClientApp.cpp
浏览文件 @
541e0d61
...
...
@@ -41,6 +41,7 @@ void ClientApp::Run(const std::string &config_file) {
int32_t
port
=
server_config
.
GetInt32Value
(
server
::
CONFIG_SERVER_PORT
,
33001
);
std
::
string
protocol
=
server_config
.
GetValue
(
server
::
CONFIG_SERVER_PROTOCOL
,
"binary"
);
//std::string mode = server_config.GetValue(server::CONFIG_SERVER_MODE, "thread_pool");
int32_t
flush_interval
=
server_config
.
GetInt32Value
(
server
::
CONFIG_SERVER_DB_FLUSH_INTERVAL
);
CLIENT_LOG_INFO
<<
"Connect to server: "
<<
address
<<
":"
<<
std
::
to_string
(
port
);
...
...
@@ -65,7 +66,7 @@ void ClientApp::Run(const std::string &config_file) {
for
(
int32_t
i
=
0
;
i
<
dim
;
i
++
)
{
tensor
.
tensor
.
push_back
((
double
)
(
i
+
k
));
}
tensor
.
uid
=
"vec_"
+
std
::
to_string
(
k
);
tensor
.
uid
=
"
s_
vec_"
+
std
::
to_string
(
k
);
session
.
interface
()
->
add_vector
(
group
.
id
,
tensor
);
...
...
@@ -83,14 +84,14 @@ void ClientApp::Run(const std::string &config_file) {
for
(
int32_t
i
=
0
;
i
<
dim
;
i
++
)
{
tensor
.
tensor
.
push_back
((
double
)
(
i
+
k
));
}
tensor
.
uid
=
"vec_"
+
std
::
to_string
(
k
);
tensor
.
uid
=
"
m_
vec_"
+
std
::
to_string
(
k
);
vec_list
.
tensor_list
.
push_back
(
tensor
);
}
session
.
interface
()
->
add_vector_batch
(
group
.
id
,
vec_list
);
rc
.
Elapse
(
"done!"
);
}
sleep
(
20
);
sleep
(
flush_interval
);
//search vector
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录