Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大炮V587
oceanbase
提交
1207f0bf
O
oceanbase
项目概览
大炮V587
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1207f0bf
编写于
2月 06, 2023
作者:
O
obdev
提交者:
ob-robot
2月 06, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ob_table_load_manager use obhashmap instead of ob_current_hash_map
上级
78662489
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
14 deletion
+16
-14
src/observer/table_load/ob_table_load_manager.h
src/observer/table_load/ob_table_load_manager.h
+13
-12
src/observer/table_load/ob_table_load_service.cpp
src/observer/table_load/ob_table_load_service.cpp
+3
-2
未找到文件。
src/observer/table_load/ob_table_load_manager.h
浏览文件 @
1207f0bf
...
@@ -29,25 +29,25 @@ public:
...
@@ -29,25 +29,25 @@ public:
template
<
typename
...
Args
>
template
<
typename
...
Args
>
int
get_or_new
(
const
KeyType
&
key
,
ValueType
*&
value
,
bool
&
is_new
,
const
Args
&
...
args
);
int
get_or_new
(
const
KeyType
&
key
,
ValueType
*&
value
,
bool
&
is_new
,
const
Args
&
...
args
);
template
<
typename
Function
>
template
<
typename
Function
>
int
for_each
(
Function
&
fn
)
{
return
value_map_
.
for
_each
(
fn
);
}
int
for_each
(
Function
&
fn
)
{
return
value_map_
.
for
each_refactored
(
fn
);
}
private:
private:
template
<
typename
...
Args
>
template
<
typename
...
Args
>
int
new_value
(
const
KeyType
&
key
,
ValueType
*&
value
,
const
Args
&
...
args
);
int
new_value
(
const
KeyType
&
key
,
ValueType
*&
value
,
const
Args
&
...
args
);
private:
private:
common
::
ObConcurrent
HashMap
<
KeyType
,
ValueType
*>
value_map_
;
common
::
hash
::
Ob
HashMap
<
KeyType
,
ValueType
*>
value_map_
;
lib
::
ObMutex
mutex_
;
lib
::
ObMutex
mutex_
;
};
};
template
<
class
KeyType
,
class
ValueType
>
template
<
class
KeyType
,
class
ValueType
>
int
ObTableLoadManager
<
KeyType
,
ValueType
>::
init
()
int
ObTableLoadManager
<
KeyType
,
ValueType
>::
init
()
{
{
return
value_map_
.
init
(
);
return
value_map_
.
create
(
1024
,
"TLD_LoadMgr"
,
"TLD_LoadMgr"
);
}
}
template
<
class
KeyType
,
class
ValueType
>
template
<
class
KeyType
,
class
ValueType
>
int
ObTableLoadManager
<
KeyType
,
ValueType
>::
put
(
const
KeyType
&
key
,
ValueType
*
value
)
int
ObTableLoadManager
<
KeyType
,
ValueType
>::
put
(
const
KeyType
&
key
,
ValueType
*
value
)
{
{
return
value_map_
.
pu
t_refactored
(
key
,
value
);
return
value_map_
.
se
t_refactored
(
key
,
value
);
}
}
template
<
class
KeyType
,
class
ValueType
>
template
<
class
KeyType
,
class
ValueType
>
...
@@ -59,7 +59,7 @@ int ObTableLoadManager<KeyType, ValueType>::get(const KeyType &key, ValueType *&
...
@@ -59,7 +59,7 @@ int ObTableLoadManager<KeyType, ValueType>::get(const KeyType &key, ValueType *&
template
<
class
KeyType
,
class
ValueType
>
template
<
class
KeyType
,
class
ValueType
>
int
ObTableLoadManager
<
KeyType
,
ValueType
>::
remove
(
const
KeyType
&
key
,
ValueType
*
value
)
int
ObTableLoadManager
<
KeyType
,
ValueType
>::
remove
(
const
KeyType
&
key
,
ValueType
*
value
)
{
{
return
value_map_
.
remov
e_refactored
(
key
);
return
value_map_
.
eras
e_refactored
(
key
);
}
}
template
<
class
KeyType
,
class
ValueType
>
template
<
class
KeyType
,
class
ValueType
>
...
@@ -70,7 +70,7 @@ int ObTableLoadManager<KeyType, ValueType>::new_value(const KeyType &key, ValueT
...
@@ -70,7 +70,7 @@ int ObTableLoadManager<KeyType, ValueType>::new_value(const KeyType &key, ValueT
int
ret
=
common
::
OB_SUCCESS
;
int
ret
=
common
::
OB_SUCCESS
;
lib
::
ObMutexGuard
guard
(
mutex_
);
lib
::
ObMutexGuard
guard
(
mutex_
);
ret
=
get
(
key
,
value
);
ret
=
get
(
key
,
value
);
if
(
ret
==
common
::
OB_
ENTRY
_NOT_EXIST
)
{
if
(
ret
==
common
::
OB_
HASH
_NOT_EXIST
)
{
ret
=
common
::
OB_SUCCESS
;
ret
=
common
::
OB_SUCCESS
;
if
(
OB_ISNULL
(
value
=
OB_NEW
(
ValueType
,
ObMemAttr
(
MTL_ID
(),
"TLD_MgrValue"
),
args
...)))
{
if
(
OB_ISNULL
(
value
=
OB_NEW
(
ValueType
,
ObMemAttr
(
MTL_ID
(),
"TLD_MgrValue"
),
args
...)))
{
ret
=
common
::
OB_ALLOCATE_MEMORY_FAILED
;
ret
=
common
::
OB_ALLOCATE_MEMORY_FAILED
;
...
@@ -89,7 +89,7 @@ int ObTableLoadManager<KeyType, ValueType>::new_value(const KeyType &key, ValueT
...
@@ -89,7 +89,7 @@ int ObTableLoadManager<KeyType, ValueType>::new_value(const KeyType &key, ValueT
}
else
if
(
ret
!=
common
::
OB_SUCCESS
)
{
}
else
if
(
ret
!=
common
::
OB_SUCCESS
)
{
OB_LOG
(
WARN
,
"fail to get value"
,
KR
(
ret
));
OB_LOG
(
WARN
,
"fail to get value"
,
KR
(
ret
));
}
else
{
// 已存在
}
else
{
// 已存在
ret
=
common
::
OB_
ENTRY
_EXIST
;
ret
=
common
::
OB_
HASH
_EXIST
;
}
}
return
ret
;
return
ret
;
}
}
...
@@ -106,12 +106,13 @@ int ObTableLoadManager<KeyType, ValueType>::new_and_insert(const KeyType &key, V
...
@@ -106,12 +106,13 @@ int ObTableLoadManager<KeyType, ValueType>::new_and_insert(const KeyType &key, V
const
Args
&
...
args
)
const
Args
&
...
args
)
{
{
int
ret
=
common
::
OB_SUCCESS
;
int
ret
=
common
::
OB_SUCCESS
;
ret
=
value_map_
.
contains_key
(
key
);
ValueType
*
tmp_value
=
nullptr
;
if
(
OB_LIKELY
(
common
::
OB_ENTRY_NOT_EXIST
==
ret
))
{
ret
=
get
(
key
,
tmp_value
);
if
(
OB_LIKELY
(
common
::
OB_HASH_NOT_EXIST
==
ret
))
{
ret
=
new_value
(
key
,
value
,
args
...);
ret
=
new_value
(
key
,
value
,
args
...);
}
}
if
(
OB_FAIL
(
ret
))
{
if
(
OB_FAIL
(
ret
))
{
if
(
OB_LIKELY
(
common
::
OB_
ENTRY
_EXIST
==
ret
))
{
if
(
OB_LIKELY
(
common
::
OB_
HASH
_EXIST
==
ret
))
{
OB_LOG
(
WARN
,
"value already exist"
,
KR
(
ret
),
K
(
key
));
OB_LOG
(
WARN
,
"value already exist"
,
KR
(
ret
),
K
(
key
));
}
else
{
}
else
{
OB_LOG
(
WARN
,
"fail to call contains key"
,
KR
(
ret
),
K
(
key
));
OB_LOG
(
WARN
,
"fail to call contains key"
,
KR
(
ret
),
K
(
key
));
...
@@ -129,10 +130,10 @@ int ObTableLoadManager<KeyType, ValueType>::get_or_new(const KeyType &key, Value
...
@@ -129,10 +130,10 @@ int ObTableLoadManager<KeyType, ValueType>::get_or_new(const KeyType &key, Value
value
=
nullptr
;
value
=
nullptr
;
is_new
=
false
;
is_new
=
false
;
ret
=
get
(
key
,
value
);
ret
=
get
(
key
,
value
);
if
(
common
::
OB_
ENTRY
_NOT_EXIST
==
ret
)
{
if
(
common
::
OB_
HASH
_NOT_EXIST
==
ret
)
{
ret
=
common
::
OB_SUCCESS
;
ret
=
common
::
OB_SUCCESS
;
if
(
OB_FAIL
(
new_value
(
key
,
value
,
args
...)))
{
if
(
OB_FAIL
(
new_value
(
key
,
value
,
args
...)))
{
if
(
OB_UNLIKELY
(
common
::
OB_
ENTRY
_EXIST
!=
ret
))
{
if
(
OB_UNLIKELY
(
common
::
OB_
HASH
_EXIST
!=
ret
))
{
OB_LOG
(
WARN
,
"fail to new value"
,
KR
(
ret
));
OB_LOG
(
WARN
,
"fail to new value"
,
KR
(
ret
));
}
else
{
// 已存在
}
else
{
// 已存在
ret
=
common
::
OB_SUCCESS
;
ret
=
common
::
OB_SUCCESS
;
...
...
src/observer/table_load/ob_table_load_service.cpp
浏览文件 @
1207f0bf
...
@@ -44,8 +44,9 @@ void ObTableLoadService::ObGCTask::runTimerTask()
...
@@ -44,8 +44,9 @@ void ObTableLoadService::ObGCTask::runTimerTask()
LOG_WARN
(
"ObTableLoadService::ObGCTask not init"
,
KR
(
ret
),
KP
(
this
));
LOG_WARN
(
"ObTableLoadService::ObGCTask not init"
,
KR
(
ret
),
KP
(
this
));
}
else
{
}
else
{
LOG_DEBUG
(
"table load start gc"
,
K
(
tenant_id_
));
LOG_DEBUG
(
"table load start gc"
,
K
(
tenant_id_
));
auto
fn
=
[
this
](
uint64_t
table_id
,
ObTableLoadTableCtx
*
)
->
bool
{
auto
fn
=
[
this
](
common
::
hash
::
HashMapPair
<
uint64_t
,
ObTableLoadTableCtx
*>
&
entry
)
->
int
{
int
ret
=
OB_SUCCESS
;
int
ret
=
OB_SUCCESS
;
uint64_t
table_id
=
entry
.
first
;
ObTableLoadTableCtx
*
table_ctx
=
nullptr
;
ObTableLoadTableCtx
*
table_ctx
=
nullptr
;
if
(
OB_FAIL
(
service_
.
get_table_ctx
(
table_id
,
table_ctx
)))
{
if
(
OB_FAIL
(
service_
.
get_table_ctx
(
table_id
,
table_ctx
)))
{
}
else
if
(
table_ctx
->
is_dirty
())
{
}
else
if
(
table_ctx
->
is_dirty
())
{
...
@@ -81,7 +82,7 @@ void ObTableLoadService::ObGCTask::runTimerTask()
...
@@ -81,7 +82,7 @@ void ObTableLoadService::ObGCTask::runTimerTask()
service_
.
put_table_ctx
(
table_ctx
);
service_
.
put_table_ctx
(
table_ctx
);
table_ctx
=
nullptr
;
table_ctx
=
nullptr
;
}
}
return
true
;
return
ret
;
};
};
service_
.
table_ctx_manager_
.
for_each
(
fn
);
service_
.
table_ctx_manager_
.
for_each
(
fn
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录