Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
71fab516
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,发现更多精彩内容 >>
提交
71fab516
编写于
4月 06, 2020
作者:
N
Nikolai Kochetov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix AggregatingSorted for simple aggregate functions.
上级
fe442d8c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
67 addition
and
16 deletion
+67
-16
src/Processors/Merges/AggregatingSortedTransform.cpp
src/Processors/Merges/AggregatingSortedTransform.cpp
+23
-5
src/Processors/Merges/AggregatingSortedTransform.h
src/Processors/Merges/AggregatingSortedTransform.h
+2
-2
src/Processors/Merges/CollapsingSortedTransform.h
src/Processors/Merges/CollapsingSortedTransform.h
+3
-2
src/Processors/Merges/GraphiteRollupSortedTransform.h
src/Processors/Merges/GraphiteRollupSortedTransform.h
+3
-2
src/Processors/Merges/ReplacingSortedTransform.h
src/Processors/Merges/ReplacingSortedTransform.h
+3
-2
src/Processors/Merges/RowRef.h
src/Processors/Merges/RowRef.h
+30
-1
src/Processors/Merges/VersionedCollapsingTransform.h
src/Processors/Merges/VersionedCollapsingTransform.h
+3
-2
未找到文件。
src/Processors/Merges/AggregatingSortedTransform.cpp
浏览文件 @
71fab516
...
...
@@ -68,6 +68,24 @@ namespace
return
def
;
}
MutableColumns
getMergedColumns
(
const
Block
&
header
,
const
AggregatingSortedTransform
::
ColumnsDefinition
&
def
)
{
MutableColumns
columns
;
columns
.
resize
(
header
.
columns
());
for
(
auto
&
desc
:
def
.
columns_to_simple_aggregate
)
{
auto
&
type
=
header
.
getByPosition
(
desc
.
column_number
).
type
;
columns
[
desc
.
column_number
]
=
recursiveRemoveLowCardinality
(
type
)
->
createColumn
();
}
for
(
size_t
i
=
0
;
i
<
columns
.
size
();
++
i
)
if
(
!
columns
[
i
])
columns
[
i
]
=
header
.
getByPosition
(
i
).
type
->
createColumn
();
return
columns
;
}
}
AggregatingSortedTransform
::
AggregatingSortedTransform
(
...
...
@@ -75,7 +93,7 @@ AggregatingSortedTransform::AggregatingSortedTransform(
SortDescription
description_
,
size_t
max_block_size
)
:
IMergingTransform
(
num_inputs
,
header
,
header
,
true
)
,
columns_definition
(
defineColumns
(
header
,
description_
))
,
merged_data
(
header
.
cloneEmptyColumns
(
),
false
,
max_block_size
)
,
merged_data
(
getMergedColumns
(
header
,
columns_definition
),
false
,
max_block_size
)
,
description
(
std
::
move
(
description_
))
,
source_chunks
(
num_inputs
)
,
cursors
(
num_inputs
)
...
...
@@ -106,7 +124,7 @@ void AggregatingSortedTransform::updateCursor(Chunk chunk, size_t source_num)
column
=
column
->
convertToFullColumnIfConst
();
for
(
auto
&
desc
:
columns_definition
.
columns_to_simple_aggregate
)
if
(
desc
.
type_to_convert
)
if
(
desc
.
inner_type
)
columns
[
desc
.
column_number
]
=
recursiveRemoveLowCardinality
(
columns
[
desc
.
column_number
]);
chunk
.
setColumns
(
std
::
move
(
columns
),
num_rows
);
...
...
@@ -145,10 +163,10 @@ void AggregatingSortedTransform::work()
for
(
auto
&
desc
:
columns_definition
.
columns_to_simple_aggregate
)
{
if
(
desc
.
type_to_convert
)
if
(
desc
.
inner_type
)
{
auto
&
from_type
=
header
.
getByPosition
(
desc
.
column_number
).
type
;
auto
&
to_type
=
desc
.
type_to_convert
;
auto
&
from_type
=
desc
.
inner_
type
;
auto
&
to_type
=
header
.
getByPosition
(
desc
.
column_number
).
type
;
columns
[
desc
.
column_number
]
=
recursiveTypeConversion
(
columns
[
desc
.
column_number
],
from_type
,
to_type
);
}
}
...
...
src/Processors/Merges/AggregatingSortedTransform.h
浏览文件 @
71fab516
...
...
@@ -129,13 +129,13 @@ public:
size_t
column_number
=
0
;
IColumn
*
column
=
nullptr
;
const
DataTypePtr
type_to_convert
;
const
DataTypePtr
inner_type
;
AlignedBuffer
state
;
bool
created
=
false
;
SimpleAggregateDescription
(
AggregateFunctionPtr
function_
,
const
size_t
column_number_
,
DataTypePtr
type
)
:
function
(
std
::
move
(
function_
)),
column_number
(
column_number_
),
type_to_convert
(
std
::
move
(
type
))
:
function
(
std
::
move
(
function_
)),
column_number
(
column_number_
),
inner_type
(
std
::
move
(
type
))
{
add_function
=
function
->
getAddressOfAddFunction
();
state
.
reset
(
function
->
sizeOfData
(),
function
->
alignOfData
());
...
...
src/Processors/Merges/CollapsingSortedTransform.h
浏览文件 @
71fab516
...
...
@@ -64,14 +64,15 @@ private:
SortingHeap
<
SortCursor
>
queue
;
bool
is_queue_initialized
=
false
;
/// Allocator must be destroyed after all RowRefs.
detail
::
SharedChunkAllocator
chunk_allocator
;
using
RowRef
=
detail
::
RowRefWithOwnedChunk
;
static
constexpr
size_t
max_row_refs
=
4
;
/// first_negative, last_positive, last, current.
RowRef
first_negative_row
;
RowRef
last_positive_row
;
RowRef
last_row
;
detail
::
SharedChunkAllocator
chunk_allocator
;
size_t
count_positive
=
0
;
/// The number of positive rows for the current primary key.
size_t
count_negative
=
0
;
/// The number of negative rows for the current primary key.
bool
last_is_positive
=
false
;
/// true if the last row for the current primary key is positive.
...
...
src/Processors/Merges/GraphiteRollupSortedTransform.h
浏览文件 @
71fab516
...
...
@@ -237,12 +237,13 @@ private:
/// Path name of current bucket
StringRef
current_group_path
;
/// Allocator must be destroyed after all RowRefs.
detail
::
SharedChunkAllocator
chunk_allocator
;
static
constexpr
size_t
max_row_refs
=
2
;
/// current_subgroup_newest_row, current_row.
/// Last row with maximum version for current primary key (time bucket).
RowRef
current_subgroup_newest_row
;
detail
::
SharedChunkAllocator
chunk_allocator
;
/// Time of last read row
time_t
current_time
=
0
;
time_t
current_time_rounded
=
0
;
...
...
src/Processors/Merges/ReplacingSortedTransform.h
浏览文件 @
71fab516
...
...
@@ -50,6 +50,9 @@ private:
SortingHeap
<
SortCursor
>
queue
;
bool
is_queue_initialized
=
false
;
/// Allocator must be destroyed after all RowRefs.
detail
::
SharedChunkAllocator
chunk_allocator
;
using
RowRef
=
detail
::
RowRefWithOwnedChunk
;
static
constexpr
size_t
max_row_refs
=
3
;
/// last, current, selected.
RowRef
last_row
;
...
...
@@ -57,8 +60,6 @@ private:
RowRef
selected_row
;
/// Last row with maximum version for current primary key.
size_t
max_pos
=
0
;
/// The position (into current_row_sources) of the row with the highest version.
detail
::
SharedChunkAllocator
chunk_allocator
;
/// Sources of rows with the current primary key.
PODArray
<
RowSourcePart
>
current_row_sources
;
...
...
src/Processors/Merges/RowRef.h
浏览文件 @
71fab516
...
...
@@ -3,6 +3,8 @@
#include <Processors/Chunk.h>
#include <Columns/IColumn.h>
#include <Core/SortCursor.h>
#include <Common/StackTrace.h>
#include <common/logger_useful.h>
#include <boost/smart_ptr/intrusive_ptr.hpp>
...
...
@@ -51,6 +53,9 @@ class SharedChunkAllocator
public:
explicit
SharedChunkAllocator
(
size_t
max_chunks
)
{
if
(
max_chunks
==
0
)
max_chunks
=
1
;
chunks
.
resize
(
max_chunks
);
free_chunks
.
reserve
(
max_chunks
);
...
...
@@ -74,12 +79,36 @@ public:
return
SharedChunkPtr
(
&
chunks
[
pos
]);
}
~
SharedChunkAllocator
()
{
if
(
free_chunks
.
size
()
!=
chunks
.
size
())
{
LOG_ERROR
(
&
Logger
::
get
(
"SharedChunkAllocator"
),
"SharedChunkAllocator was destroyed before RowRef was released. StackTrace: "
<<
StackTrace
().
toString
());
return
;
}
}
private:
std
::
vector
<
SharedChunk
>
chunks
;
std
::
vector
<
size_t
>
free_chunks
;
void
release
(
SharedChunk
*
ptr
)
void
release
(
SharedChunk
*
ptr
)
noexcept
{
if
(
chunks
.
empty
())
{
/// This may happen if allocator was removed before chunks.
/// Log message and exit, because we don't want to throw exception in destructor.
LOG_ERROR
(
&
Logger
::
get
(
"SharedChunkAllocator"
),
"SharedChunkAllocator was destroyed before RowRef was released. StackTrace: "
<<
StackTrace
().
toString
());
return
;
}
/// Release memory. It is not obligatory.
ptr
->
clear
();
ptr
->
all_columns
.
clear
();
...
...
src/Processors/Merges/VersionedCollapsingTransform.h
浏览文件 @
71fab516
...
...
@@ -53,14 +53,15 @@ private:
SortingHeap
<
SortCursor
>
queue
;
bool
is_queue_initialized
=
false
;
/// Allocator must be destroyed after all RowRefs.
detail
::
SharedChunkAllocator
chunk_allocator
;
using
RowRef
=
detail
::
RowRefWithOwnedChunk
;
const
size_t
max_rows_in_queue
;
/// Rows with the same primary key and sign.
FixedSizeDequeWithGaps
<
RowRef
>
current_keys
;
Int8
sign_in_queue
=
0
;
detail
::
SharedChunkAllocator
chunk_allocator
;
std
::
queue
<
RowSourcePart
>
current_row_sources
;
/// Sources of rows with the current primary key
void
insertGap
(
size_t
gap_size
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录