Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
a6e92dc9
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,发现更多精彩内容 >>
提交
a6e92dc9
编写于
4月 18, 2019
作者:
X
Xu Peng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(db): update for merege and index
Former-commit-id: b06f36ce5a8ebca0f1f4554437b19233f8f6f723
上级
08a1527b
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
62 addition
and
3 deletion
+62
-3
cpp/src/db/DBImpl.cpp
cpp/src/db/DBImpl.cpp
+8
-1
cpp/src/db/DBMetaImpl.cpp
cpp/src/db/DBMetaImpl.cpp
+40
-1
cpp/src/db/DBMetaImpl.h
cpp/src/db/DBMetaImpl.h
+4
-0
cpp/src/db/LocalMetaImpl.cpp
cpp/src/db/LocalMetaImpl.cpp
+5
-0
cpp/src/db/LocalMetaImpl.h
cpp/src/db/LocalMetaImpl.h
+2
-0
cpp/src/db/Meta.h
cpp/src/db/Meta.h
+2
-0
cpp/src/db/Options.h
cpp/src/db/Options.h
+1
-1
未找到文件。
cpp/src/db/DBImpl.cpp
浏览文件 @
a6e92dc9
...
...
@@ -124,8 +124,15 @@ Status DBImpl::merge_files(const std::string& group_id, const meta::DateT& date,
updated
.
push_back
(
file_schema
);
}
auto
index_size
=
group_file
.
dimension
*
index
->
ntotal
;
faiss
::
write_index
(
index
.
get
(),
group_file
.
location
.
c_str
());
std
::
cout
<<
"Merged size="
<<
index_size
<<
std
::
endl
;
if
(
index_size
>=
_options
.
index_trigger_size
)
{
group_file
.
file_type
=
meta
::
GroupFileSchema
::
TO_INDEX
;
}
else
{
group_file
.
file_type
=
meta
::
GroupFileSchema
::
RAW
;
}
updated
.
push_back
(
group_file
);
status
=
_pMeta
->
update_files
(
updated
);
...
...
cpp/src/db/DBMetaImpl.cpp
浏览文件 @
a6e92dc9
...
...
@@ -33,7 +33,7 @@ inline auto StoragePrototype(const std::string& path) {
}
using
ConnectorT
=
decltype
(
StoragePrototype
(
""
));
using
ConnectorT
=
decltype
(
StoragePrototype
(
"
/tmp/dummy.sqlite3
"
));
static
std
::
unique_ptr
<
ConnectorT
>
ConnectorPtr
;
long
GetFileSize
(
const
std
::
string
&
filename
)
...
...
@@ -77,6 +77,8 @@ Status DBMetaImpl::initialize() {
ConnectorPtr
->
sync_schema
();
cleanup
();
return
Status
::
OK
();
}
...
...
@@ -211,6 +213,7 @@ Status DBMetaImpl::files_to_index(GroupFilesSchema& files) {
group_file
.
file_type
=
std
::
get
<
3
>
(
file
);
group_file
.
rows
=
std
::
get
<
4
>
(
file
);
group_file
.
date
=
std
::
get
<
5
>
(
file
);
GetGroupFilePath
(
group_file
);
auto
groupItr
=
groups
.
find
(
group_file
.
group_id
);
if
(
groupItr
==
groups
.
end
())
{
GroupSchema
group_info
;
...
...
@@ -316,6 +319,42 @@ Status DBMetaImpl::update_files(const GroupFilesSchema& files) {
return
Status
::
OK
();
}
Status
DBMetaImpl
::
cleanup
()
{
std
::
unique_lock
<
std
::
mutex
>
lk
(
mutex_
);
auto
selected
=
ConnectorPtr
->
select
(
columns
(
&
GroupFileSchema
::
id
,
&
GroupFileSchema
::
group_id
,
&
GroupFileSchema
::
file_id
,
&
GroupFileSchema
::
file_type
,
&
GroupFileSchema
::
rows
,
&
GroupFileSchema
::
date
),
where
(
c
(
&
GroupFileSchema
::
file_type
)
==
(
int
)
GroupFileSchema
::
TO_DELETE
or
c
(
&
GroupFileSchema
::
file_type
)
==
(
int
)
GroupFileSchema
::
NEW
));
GroupFilesSchema
updated
;
for
(
auto
&
file
:
selected
)
{
GroupFileSchema
group_file
;
group_file
.
id
=
std
::
get
<
0
>
(
file
);
group_file
.
group_id
=
std
::
get
<
1
>
(
file
);
group_file
.
file_id
=
std
::
get
<
2
>
(
file
);
group_file
.
file_type
=
std
::
get
<
3
>
(
file
);
group_file
.
rows
=
std
::
get
<
4
>
(
file
);
group_file
.
date
=
std
::
get
<
5
>
(
file
);
GetGroupFilePath
(
group_file
);
if
(
group_file
.
file_type
==
GroupFileSchema
::
TO_DELETE
)
{
boost
::
filesystem
::
remove
(
group_file
.
location
);
}
ConnectorPtr
->
remove
<
GroupFileSchema
>
(
group_file
.
id
);
std
::
cout
<<
"Removing id="
<<
group_file
.
id
<<
" location="
<<
group_file
.
location
<<
std
::
endl
;
}
return
Status
::
OK
();
}
DBMetaImpl
::~
DBMetaImpl
()
{
cleanup
();
}
}
// namespace meta
}
// namespace engine
}
// namespace vecwise
...
...
cpp/src/db/DBMetaImpl.h
浏览文件 @
a6e92dc9
...
...
@@ -42,6 +42,10 @@ public:
virtual
Status
files_to_index
(
GroupFilesSchema
&
)
override
;
virtual
Status
cleanup
()
override
;
virtual
~
DBMetaImpl
();
private:
Status
get_group_no_lock
(
GroupSchema
&
group_info
);
...
...
cpp/src/db/LocalMetaImpl.cpp
浏览文件 @
a6e92dc9
...
...
@@ -236,6 +236,11 @@ Status LocalMetaImpl::update_files(const GroupFilesSchema& files) {
return
Status
::
OK
();
}
Status
LocalMetaImpl
::
cleanup
()
{
//PXU TODO
return
Status
::
OK
();
}
}
// namespace meta
}
// namespace engine
}
// namespace vecwise
...
...
cpp/src/db/LocalMetaImpl.h
浏览文件 @
a6e92dc9
...
...
@@ -34,6 +34,8 @@ public:
virtual
Status
update_files
(
const
GroupFilesSchema
&
files
)
override
;
virtual
Status
cleanup
()
override
;
virtual
Status
files_to_merge
(
const
std
::
string
&
group_id
,
DatePartionedGroupFilesSchema
&
files
)
override
;
...
...
cpp/src/db/Meta.h
浏览文件 @
a6e92dc9
...
...
@@ -75,6 +75,8 @@ public:
virtual
Status
files_to_index
(
GroupFilesSchema
&
)
=
0
;
virtual
Status
cleanup
()
=
0
;
static
DateT
GetDate
(
const
std
::
time_t
&
t
);
static
DateT
GetDate
();
...
...
cpp/src/db/Options.h
浏览文件 @
a6e92dc9
...
...
@@ -20,7 +20,7 @@ struct Options {
Options
();
uint16_t
memory_sync_interval
=
10
;
uint16_t
merge_trigger_number
=
100
;
size_t
index_trigger_size
=
1024
*
1024
*
1024
;
size_t
index_trigger_size
=
1024
*
1024
*
256
;
Env
*
env
;
DBMetaOptions
meta
;
};
// Options
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录