Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
83cff9fa
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,发现更多精彩内容 >>
提交
83cff9fa
编写于
4月 16, 2019
作者:
X
Xu Peng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(db): add group_id related info for memvertor apis
Former-commit-id: 561ecf8893c38246fa1fb3ed33603d3de67e1126
上级
9dd6b395
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
28 addition
and
11 deletion
+28
-11
cpp/src/db/db_impl.cpp
cpp/src/db/db_impl.cpp
+6
-1
cpp/src/db/db_meta_impl.cpp
cpp/src/db/db_meta_impl.cpp
+1
-0
cpp/src/db/memvectors.cpp
cpp/src/db/memvectors.cpp
+15
-7
cpp/src/db/memvectors.h
cpp/src/db/memvectors.h
+6
-3
未找到文件。
cpp/src/db/db_impl.cpp
浏览文件 @
83cff9fa
#include <assert.h>
#include <chrono>
#include <thread>
#include <iostream>
#include "db_impl.h"
#include "db_meta_impl.h"
#include "env.h"
...
...
@@ -100,7 +101,11 @@ void DBImpl::background_call() {
}
void
DBImpl
::
background_compaction
()
{
_pMemMgr
->
serialize
();
std
::
vector
<
std
::
string
>
group_ids
;
_pMemMgr
->
serialize
(
group_ids
);
for
(
auto
group_id
:
group_ids
)
{
std
::
cout
<<
__func__
<<
" group_id="
<<
group_id
<<
std
::
endl
;
}
}
DBImpl
::~
DBImpl
()
{
...
...
cpp/src/db/db_meta_impl.cpp
浏览文件 @
83cff9fa
...
...
@@ -30,6 +30,7 @@ Status DBMetaImpl::get_group(const std::string& group_id_, GroupSchema& group_in
SimpleIDGenerator
g
;
ss
.
str
(
""
);
ss
<<
"/tmp/test/"
<<
g
.
getNextIDNumber
()
<<
".log"
;
group_info_
.
group_id
=
"1"
;
group_info_
.
dimension
=
64
;
group_info_
.
next_file_location
=
ss
.
str
();
return
Status
::
OK
();
...
...
cpp/src/db/memvectors.cpp
浏览文件 @
83cff9fa
...
...
@@ -13,10 +13,12 @@ namespace zilliz {
namespace
vecwise
{
namespace
engine
{
MemVectors
::
MemVectors
(
size_t
dimension_
,
const
std
::
string
&
file_location_
)
:
_file_location
(
file_location_
),
MemVectors
::
MemVectors
(
const
std
::
string
&
group_id
,
size_t
dimension
,
const
std
::
string
&
file_location
)
:
group_id_
(
group_id
),
_file_location
(
file_location
),
_pIdGenerator
(
new
SimpleIDGenerator
()),
_dimension
(
dimension
_
),
_dimension
(
dimension
),
_pInnerIndex
(
new
faiss
::
IndexFlat
(
_dimension
)),
_pIdMapIndex
(
new
faiss
::
IndexIDMap
(
_pInnerIndex
))
{
}
...
...
@@ -37,13 +39,15 @@ size_t MemVectors::approximate_size() const {
return
total
()
*
_dimension
;
}
void
MemVectors
::
serialize
(
)
{
Status
MemVectors
::
serialize
(
std
::
string
&
group_id
)
{
/* std::stringstream ss; */
/* ss << "/tmp/test/" << _pIdGenerator->getNextIDNumber(); */
/* faiss::write_index(_pIdMapIndex, ss.str().c_str()); */
/* std::cout << _pIdMapIndex->ntotal << std::endl; */
/* std::cout << _file_location << std::endl; */
faiss
::
write_index
(
_pIdMapIndex
,
_file_location
.
c_str
());
group_id
=
group_id_
;
return
Status
::
OK
();
}
MemVectors
::~
MemVectors
()
{
...
...
@@ -77,7 +81,8 @@ VectorsPtr MemManager::get_mem_by_group(const std::string& group_id) {
return
nullptr
;
}
_memMap
[
group_id
]
=
std
::
shared_ptr
<
MemVectors
>
(
new
MemVectors
(
group_info
.
dimension
,
_memMap
[
group_id
]
=
std
::
shared_ptr
<
MemVectors
>
(
new
MemVectors
(
group_info
.
group_id
,
group_info
.
dimension
,
group_info
.
next_file_location
));
return
_memMap
[
group_id
];
}
...
...
@@ -126,10 +131,13 @@ Status MemManager::mark_memory_as_immutable() {
/* return false; */
/* } */
Status
MemManager
::
serialize
()
{
Status
MemManager
::
serialize
(
std
::
vector
<
std
::
string
>&
group_ids
)
{
mark_memory_as_immutable
();
std
::
string
group_id
;
group_ids
.
clear
();
for
(
auto
&
mem
:
_immMems
)
{
mem
->
serialize
();
mem
->
serialize
(
group_id
);
group_ids
.
push_back
(
group_id
);
}
_immMems
.
clear
();
return
Status
::
OK
();
...
...
cpp/src/db/memvectors.h
浏览文件 @
83cff9fa
...
...
@@ -21,7 +21,9 @@ namespace engine {
class
MemVectors
{
public:
explicit
MemVectors
(
size_t
dimension_
,
const
std
::
string
&
file_location_
);
explicit
MemVectors
(
const
std
::
string
&
group_id
,
size_t
dimension
,
const
std
::
string
&
file_location
);
void
add
(
size_t
n_
,
const
float
*
vectors_
,
IDNumbers
&
vector_ids_
);
...
...
@@ -29,7 +31,7 @@ public:
size_t
approximate_size
()
const
;
void
serialize
(
);
Status
serialize
(
std
::
string
&
group_id
);
~
MemVectors
();
...
...
@@ -40,6 +42,7 @@ private:
MemVectors
(
const
MemVectors
&
)
=
delete
;
MemVectors
&
operator
=
(
const
MemVectors
&
)
=
delete
;
std
::
string
group_id_
;
const
std
::
string
_file_location
;
IDGenerator
*
_pIdGenerator
;
size_t
_dimension
;
...
...
@@ -62,7 +65,7 @@ public:
Status
add_vectors
(
const
std
::
string
&
group_id_
,
size_t
n_
,
const
float
*
vectors_
,
IDNumbers
&
vector_ids_
);
Status
serialize
();
Status
serialize
(
std
::
vector
<
std
::
string
>&
group_ids
);
private:
Status
add_vectors_no_lock
(
const
std
::
string
&
group_id_
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录