Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
43717781
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,发现更多精彩内容 >>
提交
43717781
编写于
1月 02, 2018
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unification of Nested: development [#CLICKHOUSE-2].
上级
fffad2bb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
43 deletion
+28
-43
dbms/src/Storages/StorageLog.cpp
dbms/src/Storages/StorageLog.cpp
+15
-22
dbms/src/Storages/StorageTinyLog.cpp
dbms/src/Storages/StorageTinyLog.cpp
+13
-21
未找到文件。
dbms/src/Storages/StorageLog.cpp
浏览文件 @
43717781
...
...
@@ -51,11 +51,10 @@ class LogBlockInputStream final : public IProfilingBlockInputStream
{
public:
LogBlockInputStream
(
size_t
block_size_
,
const
Names
&
column_name
s_
,
StorageLog
&
storage_
,
size_t
block_size_
,
const
Names
AndTypesList
&
column
s_
,
StorageLog
&
storage_
,
size_t
mark_number_
,
size_t
rows_limit_
,
size_t
max_read_buffer_size_
)
:
block_size
(
block_size_
),
column_names
(
column_names_
),
column_types
(
column_names
.
size
()),
columns
(
columns_
),
storage
(
storage_
),
mark_number
(
mark_number_
),
rows_limit
(
rows_limit_
),
...
...
@@ -70,8 +69,8 @@ public:
std
::
stringstream
res
;
res
<<
"Log("
<<
storage
.
getTableName
()
<<
", "
<<
&
storage
<<
", "
<<
mark_number
<<
", "
<<
rows_limit
;
for
(
const
auto
&
name
:
column_name
s
)
res
<<
", "
<<
name
;
for
(
const
auto
&
name
_type
:
column
s
)
res
<<
", "
<<
name
_type
.
name
;
res
<<
")"
;
return
res
.
str
();
...
...
@@ -82,8 +81,7 @@ protected:
private:
size_t
block_size
;
Names
column_names
;
DataTypes
column_types
;
NamesAndTypesList
columns
;
StorageLog
&
storage
;
size_t
mark_number
;
/// from what mark to read data
size_t
rows_limit
;
/// The maximum number of rows that can be read
...
...
@@ -191,11 +189,6 @@ Block LogBlockInputStream::readImpl()
if
(
Poco
::
DirectoryIterator
(
storage
.
getFullPath
())
==
Poco
::
DirectoryIterator
())
return
res
;
/// If the files are not open, then open them.
if
(
streams
.
empty
())
for
(
size_t
i
=
0
,
size
=
column_names
.
size
();
i
<
size
;
++
i
)
column_types
[
i
]
=
storage
.
getDataTypeByName
(
column_names
[
i
]);
/// How many rows to read for the next block.
size_t
max_rows_to_read
=
std
::
min
(
block_size
,
rows_limit
-
rows_read
);
...
...
@@ -203,18 +196,16 @@ Block LogBlockInputStream::readImpl()
using
OffsetColumns
=
std
::
map
<
std
::
string
,
ColumnPtr
>
;
OffsetColumns
offset_columns
;
for
(
size_t
i
=
0
,
size
=
column_names
.
size
();
i
<
size
;
++
i
)
for
(
const
auto
&
name_type
:
columns
)
{
const
auto
&
name
=
column_names
[
i
];
MutableColumnPtr
column
;
bool
read_offsets
=
true
;
/// For nested structures, remember pointers to columns with offsets
if
(
const
DataTypeArray
*
type_arr
=
typeid_cast
<
const
DataTypeArray
*>
(
column_types
[
i
]
.
get
()))
if
(
const
DataTypeArray
*
type_arr
=
typeid_cast
<
const
DataTypeArray
*>
(
name_type
.
type
.
get
()))
{
String
nested_name
=
Nested
::
extractTableName
(
name
);
String
nested_name
=
Nested
::
extractTableName
(
name
_type
.
name
);
if
(
offset_columns
.
count
(
nested_name
)
==
0
)
offset_columns
[
nested_name
]
=
ColumnArray
::
ColumnOffsets
::
create
();
...
...
@@ -224,20 +215,20 @@ Block LogBlockInputStream::readImpl()
column
=
ColumnArray
::
create
(
type_arr
->
getNestedType
()
->
createColumn
(),
offset_columns
[
nested_name
]);
}
else
column
=
column_types
[
i
]
->
createColumn
();
column
=
name_type
.
type
->
createColumn
();
try
{
readData
(
name
,
*
column_types
[
i
]
,
*
column
,
max_rows_to_read
,
read_offsets
);
readData
(
name
_type
.
name
,
*
name_type
.
type
,
*
column
,
max_rows_to_read
,
read_offsets
);
}
catch
(
Exception
&
e
)
{
e
.
addMessage
(
"while reading column "
+
name
+
" at "
+
storage
.
path
+
escapeForFileName
(
storage
.
name
));
e
.
addMessage
(
"while reading column "
+
name
_type
.
name
+
" at "
+
storage
.
path
+
escapeForFileName
(
storage
.
name
));
throw
;
}
if
(
column
->
size
())
res
.
insert
(
ColumnWithTypeAndName
(
std
::
move
(
column
),
column_types
[
i
],
name
));
res
.
insert
(
ColumnWithTypeAndName
(
std
::
move
(
column
),
name_type
.
type
,
name_type
.
name
));
}
if
(
res
)
...
...
@@ -538,6 +529,8 @@ BlockInputStreams StorageLog::read(
processed_stage
=
QueryProcessingStage
::
FetchColumns
;
loadMarks
();
NamesAndTypesList
columns
=
getColumnsList
().
addTypes
(
column_names
);
std
::
shared_lock
<
std
::
shared_mutex
>
lock
(
rwlock
);
BlockInputStreams
res
;
...
...
@@ -560,7 +553,7 @@ BlockInputStreams StorageLog::read(
res
.
emplace_back
(
std
::
make_shared
<
LogBlockInputStream
>
(
max_block_size
,
column
_name
s
,
columns
,
*
this
,
mark_begin
,
rows_end
-
rows_begin
,
...
...
dbms/src/Storages/StorageTinyLog.cpp
浏览文件 @
43717781
...
...
@@ -55,8 +55,8 @@ namespace ErrorCodes
class
TinyLogBlockInputStream
final
:
public
IProfilingBlockInputStream
{
public:
TinyLogBlockInputStream
(
size_t
block_size_
,
const
Names
&
column_name
s_
,
StorageTinyLog
&
storage_
,
size_t
max_read_buffer_size_
)
:
block_size
(
block_size_
),
column
_names
(
column_names_
),
column_types
(
column_names
.
size
()
),
TinyLogBlockInputStream
(
size_t
block_size_
,
const
Names
AndTypesList
&
column
s_
,
StorageTinyLog
&
storage_
,
size_t
max_read_buffer_size_
)
:
block_size
(
block_size_
),
column
s
(
columns_
),
storage
(
storage_
),
max_read_buffer_size
(
max_read_buffer_size_
)
{}
String
getName
()
const
override
{
return
"TinyLog"
;
}
...
...
@@ -67,8 +67,7 @@ protected:
Block
readImpl
()
override
;
private:
size_t
block_size
;
Names
column_names
;
DataTypes
column_types
;
NamesAndTypesList
columns
;
StorageTinyLog
&
storage
;
bool
finished
=
false
;
size_t
max_read_buffer_size
;
...
...
@@ -151,8 +150,8 @@ String TinyLogBlockInputStream::getID() const
std
::
stringstream
res
;
res
<<
"TinyLog("
<<
storage
.
getTableName
()
<<
", "
<<
&
storage
;
for
(
const
auto
&
name
:
column_name
s
)
res
<<
", "
<<
name
;
for
(
const
auto
&
name
_type
:
column
s
)
res
<<
", "
<<
name
_type
.
name
;
res
<<
")"
;
return
res
.
str
();
...
...
@@ -180,27 +179,20 @@ Block TinyLogBlockInputStream::readImpl()
return
res
;
}
/// If the files are not open, then open them.
if
(
streams
.
empty
())
for
(
size_t
i
=
0
,
size
=
column_names
.
size
();
i
<
size
;
++
i
)
column_types
[
i
]
=
storage
.
getDataTypeByName
(
column_names
[
i
]);
/// Pointers to offset columns, shared for columns from nested data structures
using
OffsetColumns
=
std
::
map
<
std
::
string
,
ColumnPtr
>
;
OffsetColumns
offset_columns
;
for
(
size_t
i
=
0
,
size
=
column_names
.
size
();
i
<
size
;
++
i
)
for
(
const
auto
&
name_type
:
columns
)
{
const
auto
&
name
=
column_names
[
i
];
MutableColumnPtr
column
;
bool
read_offsets
=
true
;
/// For nested structures, remember pointers to columns with offsets
if
(
const
DataTypeArray
*
type_arr
=
typeid_cast
<
const
DataTypeArray
*>
(
column_types
[
i
]
.
get
()))
if
(
const
DataTypeArray
*
type_arr
=
typeid_cast
<
const
DataTypeArray
*>
(
name_type
.
type
.
get
()))
{
String
nested_name
=
Nested
::
extractTableName
(
name
);
String
nested_name
=
Nested
::
extractTableName
(
name
_type
.
name
);
if
(
offset_columns
.
count
(
nested_name
)
==
0
)
offset_columns
[
nested_name
]
=
ColumnArray
::
ColumnOffsets
::
create
();
...
...
@@ -210,20 +202,20 @@ Block TinyLogBlockInputStream::readImpl()
column
=
ColumnArray
::
create
(
type_arr
->
getNestedType
()
->
createColumn
(),
offset_columns
[
nested_name
]);
}
else
column
=
column_types
[
i
]
->
createColumn
();
column
=
name_type
.
type
->
createColumn
();
try
{
readData
(
name
,
*
column_types
[
i
]
,
*
column
,
block_size
,
read_offsets
);
readData
(
name
_type
.
name
,
*
name_type
.
type
,
*
column
,
block_size
,
read_offsets
);
}
catch
(
Exception
&
e
)
{
e
.
addMessage
(
"while reading column "
+
name
+
" at "
+
storage
.
full_path
());
e
.
addMessage
(
"while reading column "
+
name
_type
.
name
+
" at "
+
storage
.
full_path
());
throw
;
}
if
(
column
->
size
())
res
.
insert
(
ColumnWithTypeAndName
(
std
::
move
(
column
),
column_types
[
i
],
name
));
res
.
insert
(
ColumnWithTypeAndName
(
std
::
move
(
column
),
name_type
.
type
,
name_type
.
name
));
}
if
(
!
res
||
streams
.
begin
()
->
second
->
compressed
.
eof
())
...
...
@@ -386,7 +378,7 @@ BlockInputStreams StorageTinyLog::read(
check
(
column_names
);
processed_stage
=
QueryProcessingStage
::
FetchColumns
;
return
BlockInputStreams
(
1
,
std
::
make_shared
<
TinyLogBlockInputStream
>
(
max_block_size
,
column_names
,
*
this
,
context
.
getSettingsRef
().
max_read_buffer_size
));
max_block_size
,
getColumnsList
().
addTypes
(
column_names
)
,
*
this
,
context
.
getSettingsRef
().
max_read_buffer_size
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录