Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
6d6f7e6f
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,发现更多精彩内容 >>
提交
6d6f7e6f
编写于
4月 19, 2019
作者:
X
Xu Peng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(db): change open db api
Former-commit-id: 145b55b170bc9050daa6191752096e1418533aea
上级
d7c7720e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
27 deletion
+36
-27
cpp/src/db/DB.h
cpp/src/db/DB.h
+1
-1
cpp/src/db/DBImpl.cpp
cpp/src/db/DBImpl.cpp
+4
-3
cpp/src/server/VecServiceHandler.cpp
cpp/src/server/VecServiceHandler.cpp
+18
-23
cpp/src/server/VecServiceHandler.h
cpp/src/server/VecServiceHandler.h
+13
-0
未找到文件。
cpp/src/db/DB.h
浏览文件 @
6d6f7e6f
...
...
@@ -15,7 +15,7 @@ class Env;
class
DB
{
public:
static
DB
*
Open
(
const
Options
&
options
);
static
void
Open
(
const
Options
&
options
,
DB
**
dbptr
);
virtual
Status
add_group
(
meta
::
GroupSchema
&
group_info_
)
=
0
;
virtual
Status
get_group
(
meta
::
GroupSchema
&
group_info_
)
=
0
;
...
...
cpp/src/db/DBImpl.cpp
浏览文件 @
6d6f7e6f
...
...
@@ -265,9 +265,10 @@ DBImpl::~DBImpl() {
DB
::~
DB
()
{}
DB
*
DB
::
Open
(
const
Options
&
options
)
{
DBImpl
*
impl
=
new
DBImpl
(
options
);
return
impl
;
void
DB
::
Open
(
const
Options
&
options
,
DB
**
dbptr
)
{
*
dbptr
=
nullptr
;
*
dbptr
=
new
DBImpl
(
options
);
return
;
}
}
// namespace engine
...
...
cpp/src/server/VecServiceHandler.cpp
浏览文件 @
6d6f7e6f
...
...
@@ -15,25 +15,13 @@ namespace zilliz {
namespace
vecwise
{
namespace
server
{
namespace
{
static
engine
::
DB
*
DB
()
{
static
engine
::
DB
*
s_db
=
nullptr
;
if
(
s_db
==
nullptr
)
{
engine
::
Options
opt
;
std
::
string
db_path
=
"/tmp/test"
;
ConfigNode
&
config
=
ServerConfig
::
GetInstance
().
GetConfig
(
CONFIG_SERVER
);
opt
.
meta
.
backend_uri
=
config
.
GetValue
(
CONFIG_SERVER_DB_URL
);
opt
.
meta
.
path
=
db_path
;
s_db
=
engine
::
DB
::
Open
(
opt
);
}
return
s_db
;
}
}
VecServiceHandler
::
VecServiceHandler
()
{
zilliz
::
vecwise
::
engine
::
Options
opt
;
ConfigNode
&
config
=
ServerConfig
::
GetInstance
().
GetConfig
(
CONFIG_SERVER
);
opt
.
meta
.
backend_uri
=
config
.
GetValue
(
CONFIG_SERVER_DB_URL
);
opt
.
meta
.
path
=
"/tmp/test"
;
zilliz
::
vecwise
::
engine
::
DB
::
Open
(
opt
,
&
db_
);
}
void
...
...
@@ -46,7 +34,7 @@ VecServiceHandler::add_group(const VecGroup &group) {
engine
::
meta
::
GroupSchema
group_info
;
group_info
.
dimension
=
(
size_t
)
group
.
dimension
;
group_info
.
group_id
=
group
.
id
;
engine
::
Status
stat
=
DB
()
->
add_group
(
group_info
);
engine
::
Status
stat
=
db_
->
add_group
(
group_info
);
if
(
!
stat
.
ok
())
{
SERVER_LOG_ERROR
<<
"Engine failed: "
<<
stat
.
ToString
();
}
...
...
@@ -65,7 +53,7 @@ VecServiceHandler::get_group(VecGroup &_return, const std::string &group_id) {
try
{
engine
::
meta
::
GroupSchema
group_info
;
group_info
.
group_id
=
group_id
;
engine
::
Status
stat
=
DB
()
->
get_group
(
group_info
);
engine
::
Status
stat
=
db_
->
get_group
(
group_info
);
if
(
!
stat
.
ok
())
{
SERVER_LOG_ERROR
<<
"Engine failed: "
<<
stat
.
ToString
();
}
else
{
...
...
@@ -101,7 +89,7 @@ VecServiceHandler::add_vector(VecTensorIdList& _return, const std::string &group
try
{
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
);
engine
::
Status
stat
=
db_
->
add_vectors
(
group_id
,
1
,
vec_f
.
data
(),
vector_ids
);
if
(
!
stat
.
ok
())
{
SERVER_LOG_ERROR
<<
"Engine failed: "
<<
stat
.
ToString
();
}
else
{
...
...
@@ -129,7 +117,7 @@ VecServiceHandler::add_vector_batch(VecTensorIdList &_return,
}
engine
::
IDNumbers
vector_ids
;
engine
::
Status
stat
=
DB
()
->
add_vectors
(
group_id
,
tensor_list
.
tensor_list
.
size
(),
vec_f
.
data
(),
vector_ids
);
engine
::
Status
stat
=
db_
->
add_vectors
(
group_id
,
tensor_list
.
tensor_list
.
size
(),
vec_f
.
data
(),
vector_ids
);
if
(
!
stat
.
ok
())
{
SERVER_LOG_ERROR
<<
"Engine failed: "
<<
stat
.
ToString
();
}
else
{
...
...
@@ -157,7 +145,7 @@ VecServiceHandler::search_vector(VecSearchResult &_return,
try
{
engine
::
QueryResults
results
;
std
::
vector
<
float
>
vec_f
(
tensor
.
tensor
.
begin
(),
tensor
.
tensor
.
end
());
engine
::
Status
stat
=
DB
()
->
search
(
group_id
,
(
size_t
)
top_k
,
1
,
vec_f
.
data
(),
results
);
engine
::
Status
stat
=
db_
->
search
(
group_id
,
(
size_t
)
top_k
,
1
,
vec_f
.
data
(),
results
);
if
(
!
stat
.
ok
())
{
SERVER_LOG_ERROR
<<
"Engine failed: "
<<
stat
.
ToString
();
}
else
{
...
...
@@ -190,7 +178,7 @@ VecServiceHandler::search_vector_batch(VecSearchResultList &_return,
}
engine
::
QueryResults
results
;
engine
::
Status
stat
=
DB
()
->
search
(
group_id
,
(
size_t
)
top_k
,
tensor_list
.
tensor_list
.
size
(),
vec_f
.
data
(),
results
);
engine
::
Status
stat
=
db_
->
search
(
group_id
,
(
size_t
)
top_k
,
tensor_list
.
tensor_list
.
size
(),
vec_f
.
data
(),
results
);
if
(
!
stat
.
ok
())
{
SERVER_LOG_ERROR
<<
"Engine failed: "
<<
stat
.
ToString
();
}
else
{
...
...
@@ -207,6 +195,13 @@ VecServiceHandler::search_vector_batch(VecSearchResultList &_return,
}
}
VecServiceHandler
::~
VecServiceHandler
()
{
if
(
db_
!=
nullptr
)
{
delete
db_
;
db_
=
nullptr
;
}
}
}
}
}
cpp/src/server/VecServiceHandler.h
浏览文件 @
6d6f7e6f
...
...
@@ -15,6 +15,14 @@
#include <cstdint>
#include <string>
namespace
zilliz
{
namespace
vecwise
{
namespace
engine
{
class
DB
;
}
}
}
namespace
zilliz
{
namespace
vecwise
{
namespace
server
{
...
...
@@ -66,6 +74,11 @@ public:
const
VecTensorList
&
tensor_list
,
const
VecTimeRangeList
&
time_range_list
);
~
VecServiceHandler
();
private:
zilliz
::
vecwise
::
engine
::
DB
*
db_
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录