Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
84b0b80b
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,发现更多精彩内容 >>
提交
84b0b80b
编写于
7月 11, 2019
作者:
G
groot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
distribute index file averagely to multi db path
Former-commit-id: 4d6887936804193a30f8bb708b8f34cef1d6bf39
上级
a9f84375
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
7 deletion
+21
-7
cpp/src/db/DBImpl.cpp
cpp/src/db/DBImpl.cpp
+1
-0
cpp/src/db/Utils.cpp
cpp/src/db/Utils.cpp
+20
-7
未找到文件。
cpp/src/db/DBImpl.cpp
浏览文件 @
84b0b80b
...
...
@@ -461,6 +461,7 @@ Status DBImpl::BuildIndex(const meta::TableFileSchema& file) {
meta
::
TableFileSchema
table_file
;
table_file
.
table_id_
=
file
.
table_id_
;
table_file
.
date_
=
file
.
date_
;
table_file
.
file_type_
=
meta
::
TableFileSchema
::
INDEX
;
//for multi-db-path, distribute index file averagely to each path
Status
status
=
meta_ptr_
->
CreateTableFile
(
table_file
);
if
(
!
status
.
ok
())
{
return
status
;
...
...
cpp/src/db/Utils.cpp
浏览文件 @
84b0b80b
...
...
@@ -7,6 +7,7 @@
#include "utils/CommonUtil.h"
#include "Log.h"
#include <mutex>
#include <chrono>
#include <boost/filesystem.hpp>
...
...
@@ -19,6 +20,9 @@ namespace {
static
const
std
::
string
TABLES_FOLDER
=
"/tables/"
;
static
uint64_t
index_file_counter
=
0
;
static
std
::
mutex
index_file_counter_mutex
;
std
::
string
ConstructParentFolder
(
const
std
::
string
&
db_path
,
const
meta
::
TableFileSchema
&
table_file
)
{
std
::
string
table_path
=
db_path
+
TABLES_FOLDER
+
table_file
.
table_id_
;
std
::
string
partition_path
=
table_path
+
"/"
+
std
::
to_string
(
table_file
.
date_
);
...
...
@@ -28,8 +32,22 @@ std::string ConstructParentFolder(const std::string& db_path, const meta::TableF
std
::
string
GetTableFileParentFolder
(
const
DBMetaOptions
&
options
,
const
meta
::
TableFileSchema
&
table_file
)
{
uint64_t
path_count
=
options
.
slave_paths
.
size
()
+
1
;
std
::
string
target_path
=
options
.
path
;
uint64_t
index
=
table_file
.
id_
%
path_count
;
if
(
index
>
0
)
{
uint64_t
index
=
0
;
if
(
meta
::
TableFileSchema
::
INDEX
==
table_file
.
file_type_
)
{
// index file is large file and to be persisted permanently
// we need to distribute index files to each db_path averagely
// round robin according to a file counter
std
::
lock_guard
<
std
::
mutex
>
lock
(
index_file_counter_mutex
);
index
=
index_file_counter
%
path_count
;
index_file_counter
++
;
}
else
{
// for other type files, they could be merged or deleted
// so we round robin according to their file id
index
=
table_file
.
id_
%
path_count
;
}
if
(
index
>
0
)
{
target_path
=
options
.
slave_paths
[
index
-
1
];
}
...
...
@@ -97,10 +115,6 @@ Status CreateTableFilePath(const DBMetaOptions& options, meta::TableFileSchema&
}
Status
GetTableFilePath
(
const
DBMetaOptions
&
options
,
meta
::
TableFileSchema
&
table_file
)
{
#if 0
std::string parent_path = GetTableFileParentFolder(options, table_file);
table_file.location_ = parent_path + "/" + table_file.file_id_;
#else
std
::
string
parent_path
=
ConstructParentFolder
(
options
.
path
,
table_file
);
std
::
string
file_path
=
parent_path
+
"/"
+
table_file
.
file_id_
;
if
(
boost
::
filesystem
::
exists
(
file_path
))
{
...
...
@@ -116,7 +130,6 @@ Status GetTableFilePath(const DBMetaOptions& options, meta::TableFileSchema& tab
}
}
}
#endif
return
Status
::
Error
(
"Table file doesn't exist: "
+
table_file
.
file_id_
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录