Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
8f541258
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,发现更多精彩内容 >>
提交
8f541258
编写于
9月 01, 2018
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Minor modifications #2808
上级
6d509251
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
44 deletion
+34
-44
dbms/src/Common/Arena.h
dbms/src/Common/Arena.h
+16
-19
dbms/src/Interpreters/Aggregator.cpp
dbms/src/Interpreters/Aggregator.cpp
+15
-21
dbms/src/Interpreters/Aggregator.h
dbms/src/Interpreters/Aggregator.h
+2
-2
dbms/src/Interpreters/SpecializedAggregator.h
dbms/src/Interpreters/SpecializedAggregator.h
+1
-2
未找到文件。
dbms/src/Common/Arena.h
浏览文件 @
8f541258
...
...
@@ -124,27 +124,24 @@ public:
return
res
;
}
/// Get peice of memory with alignment
char
*
alignedAlloc
(
size_t
size
,
size_t
align
)
/// Get peice of memory with alignment
char
*
alignedAlloc
(
size_t
size
,
size_t
align
ment
)
{
// Fast code path for non-alignment requirement
if
(
align
<=
1
)
return
alloc
(
size
);
uintptr_t
pos
=
reinterpret_cast
<
uintptr_t
>
(
head
->
pos
);
// next pos match align requirement
pos
=
((
pos
-
1
)
&
~
(
align
-
1
))
+
align
;
if
(
unlikely
(
pos
+
size
>
reinterpret_cast
<
uintptr_t
>
(
head
->
end
)))
do
{
addChunk
(
size
);
pos
=
reinterpret_cast
<
uintptr_t
>
(
head
->
pos
);
pos
=
((
pos
-
1
)
&
~
(
align
-
1
))
+
align
;
}
char
*
res
=
(
char
*
)
pos
;
head
->
pos
=
res
+
size
;
return
res
;
void
*
head_pos
=
head
->
pos
;
size_t
space
=
head
->
end
-
head
->
pos
;
auto
res
=
static_cast
<
char
*>
(
std
::
align
(
alignment
,
size
,
head_pos
,
space
));
if
(
res
)
{
head
->
pos
=
static_cast
<
char
*>
(
head_pos
);
head
->
pos
+=
size
;
return
res
;
}
addChunk
(
size
+
alignment
);
}
while
(
true
);
}
/** Rollback just performed allocation.
...
...
dbms/src/Interpreters/Aggregator.cpp
浏览文件 @
8f541258
...
...
@@ -48,6 +48,7 @@ namespace ErrorCodes
extern
const
int
TOO_MANY_ROWS
;
extern
const
int
EMPTY_DATA_PASSED
;
extern
const
int
CANNOT_MERGE_DIFFERENT_AGGREGATED_DATA_VARIANTS
;
extern
const
int
LOGICAL_ERROR
;
}
...
...
@@ -163,23 +164,20 @@ Aggregator::Aggregator(const Params & params_)
offsets_of_aggregate_states
[
i
]
=
total_size_of_aggregate_states
;
total_size_of_aggregate_states
+=
params
.
aggregates
[
i
].
function
->
sizeOfData
();
// aggreate states are aligned based on maximum requirement
align_aggregate_states
=
std
::
max
(
align_aggregate_states
,
params
.
aggregates
[
i
].
function
->
alignOfData
());
align_aggregate_states
=
std
::
max
(
align_aggregate_states
,
params
.
aggregates
[
i
].
function
->
alignOfData
());
// If not the last aggregate_state, we need pad it so that next aggregate_state will be
// aligned.
// If not the last aggregate_state, we need pad it so that next aggregate_state will be aligned.
if
(
i
+
1
<
params
.
aggregates_size
)
{
size_t
next_align_req
=
params
.
aggregates
[
i
+
1
].
function
->
alignOfData
();
if
((
next_align_req
&
(
next_align_req
-
1
))
!=
0
)
{
throw
Exception
(
"alignOfData is not 2^N"
);
}
// extend total_size to next alignment requirement
total_size_of_aggregate_states
=
(
total_size_of_aggregate_states
&
~
(
next_align_req
-
1
))
+
next_align_req
;
size_t
alignment_of_next_state
=
params
.
aggregates
[
i
+
1
].
function
->
alignOfData
();
if
((
alignment_of_next_state
&
(
alignment_of_next_state
-
1
))
!=
0
)
throw
Exception
(
"Logical error: alignOfData is not 2^N"
,
ErrorCodes
::
LOGICAL_ERROR
);
/// Extend total_size to next alignment requirement
/// Add padding by rounding up 'total_size_of_aggregate_states' to be a multiplier of alignment_of_next_state.
total_size_of_aggregate_states
=
(
total_size_of_aggregate_states
+
alignment_of_next_state
-
1
)
/
alignment_of_next_state
*
alignment_of_next_state
;
}
if
(
!
params
.
aggregates
[
i
].
function
->
hasTrivialDestructor
())
...
...
@@ -637,8 +635,7 @@ void NO_INLINE Aggregator::executeImplCase(
method
.
onNewKey
(
*
it
,
params
.
keys_size
,
keys
,
*
aggregates_pool
);
AggregateDataPtr
place
=
aggregates_pool
->
alignedAlloc
(
total_size_of_aggregate_states
,
align_aggregate_states
);
AggregateDataPtr
place
=
aggregates_pool
->
alignedAlloc
(
total_size_of_aggregate_states
,
align_aggregate_states
);
createAggregateStates
(
place
);
aggregate_data
=
place
;
}
...
...
@@ -756,8 +753,7 @@ bool Aggregator::executeOnBlock(const Block & block, AggregatedDataVariants & re
if
((
params
.
overflow_row
||
result
.
type
==
AggregatedDataVariants
::
Type
::
without_key
)
&&
!
result
.
without_key
)
{
AggregateDataPtr
place
=
result
.
aggregates_pool
->
alignedAlloc
(
total_size_of_aggregate_states
,
align_aggregate_states
);
AggregateDataPtr
place
=
result
.
aggregates_pool
->
alignedAlloc
(
total_size_of_aggregate_states
,
align_aggregate_states
);
createAggregateStates
(
place
);
result
.
without_key
=
place
;
}
...
...
@@ -1925,8 +1921,7 @@ void NO_INLINE Aggregator::mergeStreamsImplCase(
method
.
onNewKey
(
*
it
,
params
.
keys_size
,
keys
,
*
aggregates_pool
);
AggregateDataPtr
place
=
aggregates_pool
->
alignedAlloc
(
total_size_of_aggregate_states
,
align_aggregate_states
);
AggregateDataPtr
place
=
aggregates_pool
->
alignedAlloc
(
total_size_of_aggregate_states
,
align_aggregate_states
);
createAggregateStates
(
place
);
aggregate_data
=
place
;
}
...
...
@@ -1977,8 +1972,7 @@ void NO_INLINE Aggregator::mergeWithoutKeyStreamsImpl(
AggregatedDataWithoutKey
&
res
=
result
.
without_key
;
if
(
!
res
)
{
AggregateDataPtr
place
=
result
.
aggregates_pool
->
alignedAlloc
(
total_size_of_aggregate_states
,
align_aggregate_states
);
AggregateDataPtr
place
=
result
.
aggregates_pool
->
alignedAlloc
(
total_size_of_aggregate_states
,
align_aggregate_states
);
createAggregateStates
(
place
);
res
=
place
;
}
...
...
dbms/src/Interpreters/Aggregator.h
浏览文件 @
8f541258
...
...
@@ -1155,8 +1155,8 @@ protected:
Sizes
offsets_of_aggregate_states
;
/// The offset to the n-th aggregate function in a row of aggregate functions.
size_t
total_size_of_aggregate_states
=
0
;
/// The total size of the row from the aggregate functions.
// add info to track align
ed
requirement
// If there are states whose alignment
info we
re v1, ..vn, align_aggregate_states will be max(v1, ... vn)
// add info to track align
ment
requirement
// If there are states whose alignment
ment a
re v1, ..vn, align_aggregate_states will be max(v1, ... vn)
size_t
align_aggregate_states
=
1
;
bool
all_aggregates_has_trivial_destructor
=
false
;
...
...
dbms/src/Interpreters/SpecializedAggregator.h
浏览文件 @
8f541258
...
...
@@ -191,8 +191,7 @@ void NO_INLINE Aggregator::executeSpecializedCase(
method
.
onNewKey
(
*
it
,
params
.
keys_size
,
keys
,
*
aggregates_pool
);
AggregateDataPtr
place
=
aggregates_pool
->
alignedAlloc
(
total_size_of_aggregate_states
,
align_aggregate_states
);
AggregateDataPtr
place
=
aggregates_pool
->
alignedAlloc
(
total_size_of_aggregate_states
,
align_aggregate_states
);
AggregateFunctionsList
::
forEach
(
AggregateFunctionsCreator
(
aggregate_functions
,
offsets_of_aggregate_states
,
place
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录