Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
a2cad460
M
milvus
项目概览
milvus
/
milvus
10 个月 前同步成功
通知
260
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
a2cad460
编写于
12月 21, 2020
作者:
X
XuPeng-SH
提交者:
GitHub
12月 21, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modificate name to id data structure in Snapshots (#4483)
Signed-off-by:
N
XuPeng-SH
<
xupeng3112@163.com
>
上级
9d76f3a6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
10 deletion
+26
-10
core/src/db/snapshot/Snapshots.cpp
core/src/db/snapshot/Snapshots.cpp
+25
-9
core/src/db/snapshot/Snapshots.h
core/src/db/snapshot/Snapshots.h
+1
-1
未找到文件。
core/src/db/snapshot/Snapshots.cpp
浏览文件 @
a2cad460
...
...
@@ -55,7 +55,12 @@ Snapshots::DoDropCollection(ScopedSnapshotT& ss, const LSN_TYPE& lsn) {
{
std
::
unique_lock
<
std
::
shared_timed_mutex
>
lock
(
mutex_
);
alive_cids_
.
erase
(
context
.
collection
->
GetID
());
name_id_map_
.
erase
(
context
.
collection
->
GetName
());
auto
&
ids
=
name_id_map_
[
context
.
collection
->
GetName
()];
if
(
ids
.
size
()
==
1
)
{
name_id_map_
.
erase
(
context
.
collection
->
GetName
());
}
else
{
ids
.
erase
(
context
.
collection
->
GetID
());
}
/* holders_.erase(context.collection->GetID()); */
auto
h
=
holders_
.
find
(
context
.
collection
->
GetID
());
if
(
h
!=
holders_
.
end
())
{
...
...
@@ -133,8 +138,8 @@ Snapshots::GetCollectionIds(IDS_TYPE& ids) const {
Status
Snapshots
::
GetCollectionNames
(
std
::
vector
<
std
::
string
>&
names
)
const
{
std
::
shared_lock
<
std
::
shared_timed_mutex
>
lock
(
mutex_
);
for
(
auto
&
kv
:
name_id_map_
)
{
names
.
push_back
(
kv
.
first
);
for
(
auto
&
[
name
,
_
]
:
name_id_map_
)
{
names
.
push_back
(
name
);
}
return
Status
::
OK
();
}
...
...
@@ -180,8 +185,9 @@ Snapshots::GetHolder(const std::string& name, SnapshotHolderPtr& holder) const {
std
::
shared_lock
<
std
::
shared_timed_mutex
>
lock
(
mutex_
);
auto
kv
=
name_id_map_
.
find
(
name
);
if
(
kv
!=
name_id_map_
.
end
())
{
auto
id
=
*
(
kv
->
second
.
rbegin
());
lock
.
unlock
();
return
GetHolder
(
kv
->
secon
d
,
holder
);
return
GetHolder
(
i
d
,
holder
);
}
std
::
stringstream
emsg
;
emsg
<<
"Snapshots::GetHolderNoLock: Specified snapshot holder for collection "
;
...
...
@@ -215,7 +221,12 @@ Snapshots::LoadHolder(StorePtr store, const ID_TYPE& collection_id, SnapshotHold
holders_
[
collection_id
]
=
holder
;
ScopedSnapshotT
ss
;
STATUS_CHECK
(
holder
->
Load
(
store
,
ss
));
name_id_map_
[
ss
->
GetName
()]
=
collection_id
;
auto
it
=
name_id_map_
.
find
(
ss
->
GetName
());
if
(
it
==
name_id_map_
.
end
())
{
name_id_map_
[
ss
->
GetName
()]
=
{
collection_id
};
}
else
{
name_id_map_
[
ss
->
GetName
()].
insert
(
collection_id
);
}
alive_cids_
.
insert
(
collection_id
);
return
Status
::
OK
();
}
...
...
@@ -284,14 +295,14 @@ Snapshots::OnReaderTimer(const boost::system::error_code& ec) {
}
auto
aids
=
op2
->
GetIDs
();
std
::
set
<
ID_TYPE
>
diff
;
std
::
set
<
ID_TYPE
>
stale_ids
;
{
std
::
unique_lock
<
std
::
shared_timed_mutex
>
lock
(
mutex_
);
std
::
set_difference
(
alive_cids_
.
begin
(),
alive_cids_
.
end
(),
aids
.
begin
(),
aids
.
end
(),
std
::
inserter
(
diff
,
diff
.
begin
()));
std
::
inserter
(
stale_ids
,
stale_ids
.
begin
()));
}
for
(
auto
&
cid
:
diff
)
{
for
(
auto
&
cid
:
stale_ids
)
{
ScopedSnapshotT
ss
;
status
=
GetSnapshot
(
ss
,
cid
);
if
(
!
status
.
ok
())
{
...
...
@@ -300,7 +311,12 @@ Snapshots::OnReaderTimer(const boost::system::error_code& ec) {
}
std
::
unique_lock
<
std
::
shared_timed_mutex
>
lock
(
mutex_
);
alive_cids_
.
erase
(
cid
);
name_id_map_
.
erase
(
ss
->
GetName
());
auto
&
ids
=
name_id_map_
[
ss
->
GetName
()];
if
(
ids
.
size
()
==
1
)
{
name_id_map_
.
erase
(
ss
->
GetName
());
}
else
{
ids
.
erase
(
ss
->
GetID
());
}
holders_
.
erase
(
cid
);
}
}
...
...
core/src/db/snapshot/Snapshots.h
浏览文件 @
a2cad460
...
...
@@ -100,7 +100,7 @@ class Snapshots {
mutable
std
::
shared_timed_mutex
mutex_
;
std
::
map
<
ID_TYPE
,
SnapshotHolderPtr
>
holders_
;
std
::
set
<
ID_TYPE
>
alive_cids_
;
std
::
map
<
std
::
string
,
ID_TYPE
>
name_id_map_
;
std
::
map
<
std
::
string
,
std
::
set
<
ID_TYPE
>
>
name_id_map_
;
mutable
std
::
shared_timed_mutex
inactive_mtx_
;
std
::
map
<
ID_TYPE
,
SnapshotHolderPtr
>
inactive_holders_
;
std
::
set
<
ID_TYPE
>
invalid_ssid_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录