Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
7ce2107e
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7ce2107e
编写于
1月 23, 2020
作者:
N
Nikita Mikhaylov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
better
上级
c8e42e97
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
19 addition
and
15 deletion
+19
-15
dbms/src/Dictionaries/CacheDictionary.cpp
dbms/src/Dictionaries/CacheDictionary.cpp
+18
-15
dbms/src/Dictionaries/CacheDictionary.inc.h
dbms/src/Dictionaries/CacheDictionary.inc.h
+1
-0
未找到文件。
dbms/src/Dictionaries/CacheDictionary.cpp
浏览文件 @
7ce2107e
...
...
@@ -84,15 +84,15 @@ CacheDictionary::CacheDictionary(
,
cells
{
this
->
size
}
,
rnd_engine
(
randomSeed
())
,
update_queue
(
max_update_queue_size_
)
,
update_pool
(
5
)
,
update_pool
(
4
)
{
if
(
!
this
->
source_ptr
->
supportsSelectiveLoad
())
throw
Exception
{
full_name
+
": source cannot be used with CacheDictionary"
,
ErrorCodes
::
UNSUPPORTED_METHOD
};
createAttributes
();
for
(
int
i
=
0
;
i
<
5
;
++
i
)
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
update_pool
.
scheduleOrThrowOnError
([
this
]
{
update
Multi
ThreadFunction
();
});
update_pool
.
scheduleOrThrowOnError
([
this
]
{
updateThreadFunction
();
});
}
}
...
...
@@ -100,11 +100,11 @@ CacheDictionary::~CacheDictionary()
{
finished
=
true
;
update_queue
.
clear
();
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
auto
empty_finishing_ptr
=
std
::
make_shared
<
UpdateUnit
>
(
std
::
vector
<
Key
>
());
update_queue
.
push
(
empty_finishing_ptr
);
}
update_
thread
.
join
();
update_
pool
.
wait
();
}
...
...
@@ -748,20 +748,15 @@ void CacheDictionary::updateThreadFunction()
if
(
current_queue_size
>
0
)
LOG_DEBUG
(
log
,
"Performing bunch of keys update in cache dictionary with "
<<
current_queue_size
+
1
<<
" keys"
;
);
std
::
vector
<
UpdateUnitPtr
>
update_request
(
current_queue_size
+
1
)
;
std
::
vector
<
UpdateUnitPtr
>
update_request
;
bool
first_position
=
true
;
update_request
.
push_back
(
first_popped
)
;
update_request
[
0
]
=
first_popped
;
auto
current_unit_ptr
=
UpdateUnitPtr
()
;
for
(
auto
&
unit_ptr
:
update_request
)
{
if
unlikely
(
first_position
)
while
(
update_queue
.
tryPop
(
current_unit_ptr
))
{
first_position
=
false
;
continue
;
}
update_queue
.
pop
(
unit_ptr
);
update_request
.
push_back
(
current_unit_ptr
);
}
/// Here we prepare total count of all requested ids
...
...
@@ -829,6 +824,8 @@ void CacheDictionary::updateMultiThreadFunction()
LOG_TRACE
(
log
,
"update with thread number "
<<
thread_number
);
auto
start
=
std
::
chrono
::
system_clock
::
now
();
try
{
auto
found_ids_mask_ptr
=
std
::
make_shared
<
std
::
unordered_map
<
Key
,
UInt8
>>
(
first_popped
->
requested_ids
.
size
());
...
...
@@ -857,6 +854,12 @@ void CacheDictionary::updateMultiThreadFunction()
first_popped
->
current_exception
=
std
::
current_exception
();
is_update_finished
.
notify_all
();
}
auto
end
=
std
::
chrono
::
system_clock
::
now
();
auto
duration
=
end
-
start
;
LOG_FATAL
(
log
,
"full update "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
duration
).
count
()
<<
" ms"
);
}
}
...
...
dbms/src/Dictionaries/CacheDictionary.inc.h
浏览文件 @
7ce2107e
...
...
@@ -39,6 +39,7 @@ template <typename AttributeType, typename OutputType, typename DefaultGetter>
void
CacheDictionary
::
getItemsNumberImpl
(
Attribute
&
attribute
,
const
PaddedPODArray
<
Key
>
&
ids
,
ResultArrayType
<
OutputType
>
&
out
,
DefaultGetter
&&
get_default
)
const
{
std
::
cout
<<
StackTrace
().
toString
()
<<
std
::
endl
;
/// Mapping: <id> -> { all indices `i` of `ids` such that `ids[i]` = <id> }
std
::
unordered_map
<
Key
,
std
::
vector
<
size_t
>>
cache_expired_ids
;
std
::
unordered_map
<
Key
,
std
::
vector
<
size_t
>>
cache_not_found_ids
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录