Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
2e5d61cd
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,发现更多精彩内容 >>
提交
2e5d61cd
编写于
12月 04, 2019
作者:
A
Alexander Tokmakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
better constructors of storages
上级
cf5c998b
变更
77
隐藏空白更改
内联
并排
Showing
77 changed file
with
285 addition
and
263 deletion
+285
-263
dbms/programs/server/TCPHandler.cpp
dbms/programs/server/TCPHandler.cpp
+1
-1
dbms/src/Core/ExternalTable.cpp
dbms/src/Core/ExternalTable.cpp
+1
-1
dbms/src/DataStreams/PushingToViewsBlockOutputStream.cpp
dbms/src/DataStreams/PushingToViewsBlockOutputStream.cpp
+1
-1
dbms/src/Databases/DatabaseDictionary.cpp
dbms/src/Databases/DatabaseDictionary.cpp
+2
-2
dbms/src/Databases/DatabaseMySQL.cpp
dbms/src/Databases/DatabaseMySQL.cpp
+1
-1
dbms/src/Databases/DatabaseOnDisk.cpp
dbms/src/Databases/DatabaseOnDisk.cpp
+6
-3
dbms/src/Databases/DatabaseWithDictionaries.cpp
dbms/src/Databases/DatabaseWithDictionaries.cpp
+1
-1
dbms/src/Interpreters/GlobalSubqueriesVisitor.h
dbms/src/Interpreters/GlobalSubqueriesVisitor.h
+1
-1
dbms/src/Interpreters/InterpreterCreateQuery.cpp
dbms/src/Interpreters/InterpreterCreateQuery.cpp
+0
-3
dbms/src/Interpreters/InterpreterSystemQuery.cpp
dbms/src/Interpreters/InterpreterSystemQuery.cpp
+0
-3
dbms/src/Parsers/ASTQueryWithTableAndOutput.h
dbms/src/Parsers/ASTQueryWithTableAndOutput.h
+1
-0
dbms/src/Storages/Kafka/StorageKafka.cpp
dbms/src/Storages/Kafka/StorageKafka.cpp
+4
-5
dbms/src/Storages/Kafka/StorageKafka.h
dbms/src/Storages/Kafka/StorageKafka.h
+10
-5
dbms/src/Storages/LiveView/StorageLiveView.cpp
dbms/src/Storages/LiveView/StorageLiveView.cpp
+4
-5
dbms/src/Storages/LiveView/StorageLiveView.h
dbms/src/Storages/LiveView/StorageLiveView.h
+1
-2
dbms/src/Storages/MergeTree/MergeTreeData.cpp
dbms/src/Storages/MergeTree/MergeTreeData.cpp
+3
-4
dbms/src/Storages/MergeTree/MergeTreeData.h
dbms/src/Storages/MergeTree/MergeTreeData.h
+1
-1
dbms/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h
dbms/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h
+6
-2
dbms/src/Storages/MergeTree/registerStorageMergeTree.cpp
dbms/src/Storages/MergeTree/registerStorageMergeTree.cpp
+2
-2
dbms/src/Storages/StorageBuffer.cpp
dbms/src/Storages/StorageBuffer.cpp
+23
-13
dbms/src/Storages/StorageBuffer.h
dbms/src/Storages/StorageBuffer.h
+10
-4
dbms/src/Storages/StorageDictionary.cpp
dbms/src/Storages/StorageDictionary.cpp
+5
-6
dbms/src/Storages/StorageDictionary.h
dbms/src/Storages/StorageDictionary.h
+1
-2
dbms/src/Storages/StorageDistributed.cpp
dbms/src/Storages/StorageDistributed.cpp
+24
-20
dbms/src/Storages/StorageDistributed.h
dbms/src/Storages/StorageDistributed.h
+4
-6
dbms/src/Storages/StorageFactory.cpp
dbms/src/Storages/StorageFactory.cpp
+3
-6
dbms/src/Storages/StorageFactory.h
dbms/src/Storages/StorageFactory.h
+2
-5
dbms/src/Storages/StorageFile.cpp
dbms/src/Storages/StorageFile.cpp
+5
-3
dbms/src/Storages/StorageFile.h
dbms/src/Storages/StorageFile.h
+1
-2
dbms/src/Storages/StorageHDFS.cpp
dbms/src/Storages/StorageHDFS.cpp
+3
-4
dbms/src/Storages/StorageHDFS.h
dbms/src/Storages/StorageHDFS.h
+1
-2
dbms/src/Storages/StorageInput.cpp
dbms/src/Storages/StorageInput.cpp
+1
-1
dbms/src/Storages/StorageJoin.cpp
dbms/src/Storages/StorageJoin.cpp
+3
-5
dbms/src/Storages/StorageJoin.h
dbms/src/Storages/StorageJoin.h
+1
-2
dbms/src/Storages/StorageLog.cpp
dbms/src/Storages/StorageLog.cpp
+7
-6
dbms/src/Storages/StorageLog.h
dbms/src/Storages/StorageLog.h
+1
-2
dbms/src/Storages/StorageMaterializedView.cpp
dbms/src/Storages/StorageMaterializedView.cpp
+7
-8
dbms/src/Storages/StorageMaterializedView.h
dbms/src/Storages/StorageMaterializedView.h
+1
-2
dbms/src/Storages/StorageMemory.cpp
dbms/src/Storages/StorageMemory.cpp
+3
-3
dbms/src/Storages/StorageMemory.h
dbms/src/Storages/StorageMemory.h
+1
-1
dbms/src/Storages/StorageMerge.cpp
dbms/src/Storages/StorageMerge.cpp
+3
-4
dbms/src/Storages/StorageMerge.h
dbms/src/Storages/StorageMerge.h
+1
-2
dbms/src/Storages/StorageMergeTree.cpp
dbms/src/Storages/StorageMergeTree.cpp
+20
-9
dbms/src/Storages/StorageMergeTree.h
dbms/src/Storages/StorageMergeTree.h
+1
-2
dbms/src/Storages/StorageMySQL.cpp
dbms/src/Storages/StorageMySQL.cpp
+3
-5
dbms/src/Storages/StorageMySQL.h
dbms/src/Storages/StorageMySQL.h
+1
-2
dbms/src/Storages/StorageNull.cpp
dbms/src/Storages/StorageNull.cpp
+1
-1
dbms/src/Storages/StorageNull.h
dbms/src/Storages/StorageNull.h
+2
-2
dbms/src/Storages/StorageReplicatedMergeTree.cpp
dbms/src/Storages/StorageReplicatedMergeTree.cpp
+29
-13
dbms/src/Storages/StorageReplicatedMergeTree.h
dbms/src/Storages/StorageReplicatedMergeTree.h
+1
-1
dbms/src/Storages/StorageS3.cpp
dbms/src/Storages/StorageS3.cpp
+5
-5
dbms/src/Storages/StorageS3.h
dbms/src/Storages/StorageS3.h
+1
-2
dbms/src/Storages/StorageSet.cpp
dbms/src/Storages/StorageSet.cpp
+5
-7
dbms/src/Storages/StorageSet.h
dbms/src/Storages/StorageSet.h
+2
-4
dbms/src/Storages/StorageStripeLog.cpp
dbms/src/Storages/StorageStripeLog.cpp
+8
-8
dbms/src/Storages/StorageStripeLog.h
dbms/src/Storages/StorageStripeLog.h
+1
-2
dbms/src/Storages/StorageTinyLog.cpp
dbms/src/Storages/StorageTinyLog.cpp
+8
-7
dbms/src/Storages/StorageTinyLog.h
dbms/src/Storages/StorageTinyLog.h
+1
-2
dbms/src/Storages/StorageURL.cpp
dbms/src/Storages/StorageURL.cpp
+7
-4
dbms/src/Storages/StorageURL.h
dbms/src/Storages/StorageURL.h
+3
-5
dbms/src/Storages/StorageValues.cpp
dbms/src/Storages/StorageValues.cpp
+2
-2
dbms/src/Storages/StorageValues.h
dbms/src/Storages/StorageValues.h
+1
-1
dbms/src/Storages/StorageView.cpp
dbms/src/Storages/StorageView.cpp
+3
-4
dbms/src/Storages/StorageView.h
dbms/src/Storages/StorageView.h
+1
-2
dbms/src/Storages/StorageXDBC.cpp
dbms/src/Storages/StorageXDBC.cpp
+9
-4
dbms/src/Storages/StorageXDBC.h
dbms/src/Storages/StorageXDBC.h
+1
-2
dbms/src/Storages/tests/gtest_transform_query_for_external_database.cpp
...ges/tests/gtest_transform_query_for_external_database.cpp
+1
-1
dbms/src/Storages/tests/storage_log.cpp
dbms/src/Storages/tests/storage_log.cpp
+1
-1
dbms/src/TableFunctions/ITableFunctionXDBC.cpp
dbms/src/TableFunctions/ITableFunctionXDBC.cpp
+1
-1
dbms/src/TableFunctions/TableFunctionFile.cpp
dbms/src/TableFunctions/TableFunctionFile.cpp
+1
-1
dbms/src/TableFunctions/TableFunctionHDFS.cpp
dbms/src/TableFunctions/TableFunctionHDFS.cpp
+1
-2
dbms/src/TableFunctions/TableFunctionMerge.cpp
dbms/src/TableFunctions/TableFunctionMerge.cpp
+1
-2
dbms/src/TableFunctions/TableFunctionMySQL.cpp
dbms/src/TableFunctions/TableFunctionMySQL.cpp
+1
-2
dbms/src/TableFunctions/TableFunctionRemote.cpp
dbms/src/TableFunctions/TableFunctionRemote.cpp
+2
-2
dbms/src/TableFunctions/TableFunctionS3.cpp
dbms/src/TableFunctions/TableFunctionS3.cpp
+1
-1
dbms/src/TableFunctions/TableFunctionURL.cpp
dbms/src/TableFunctions/TableFunctionURL.cpp
+1
-1
dbms/src/TableFunctions/TableFunctionValues.cpp
dbms/src/TableFunctions/TableFunctionValues.cpp
+1
-1
未找到文件。
dbms/programs/server/TCPHandler.cpp
浏览文件 @
2e5d61cd
...
...
@@ -993,7 +993,7 @@ bool TCPHandler::receiveData(bool scalar)
if
(
!
(
storage
=
query_context
->
tryGetExternalTable
(
name
)))
{
NamesAndTypesList
columns
=
block
.
getNamesAndTypesList
();
storage
=
StorageMemory
::
create
(
"_external"
,
name
,
ColumnsDescription
{
columns
},
ConstraintsDescription
{});
storage
=
StorageMemory
::
create
(
StorageID
(
"_external"
,
name
)
,
ColumnsDescription
{
columns
},
ConstraintsDescription
{});
storage
->
startup
();
query_context
->
addExternalTable
(
name
,
storage
);
}
...
...
dbms/src/Core/ExternalTable.cpp
浏览文件 @
2e5d61cd
...
...
@@ -160,7 +160,7 @@ void ExternalTablesHandler::handlePart(const Poco::Net::MessageHeader & header,
/// Create table
NamesAndTypesList
columns
=
sample_block
.
getNamesAndTypesList
();
StoragePtr
storage
=
StorageMemory
::
create
(
"_external"
,
data
.
second
,
ColumnsDescription
{
columns
},
ConstraintsDescription
{});
StoragePtr
storage
=
StorageMemory
::
create
(
StorageID
(
"_external"
,
data
.
second
)
,
ColumnsDescription
{
columns
},
ConstraintsDescription
{});
storage
->
startup
();
context
.
addExternalTable
(
data
.
second
,
storage
);
BlockOutputStreamPtr
output
=
storage
->
write
(
ASTPtr
(),
context
);
...
...
dbms/src/DataStreams/PushingToViewsBlockOutputStream.cpp
浏览文件 @
2e5d61cd
...
...
@@ -223,7 +223,7 @@ void PushingToViewsBlockOutputStream::process(const Block & block, size_t view_n
/// InterpreterSelectQuery will do processing of alias columns.
Context
local_context
=
*
views_context
;
local_context
.
addViewSource
(
StorageValues
::
create
(
storage
->
getDatabaseName
(),
storage
->
getTableName
(),
storage
->
getColumns
(),
StorageValues
::
create
(
StorageID
(
storage
->
getDatabaseName
(),
storage
->
getTableName
()),
storage
->
getColumns
(),
//FIXME
block
));
select
.
emplace
(
view
.
query
,
local_context
,
SelectQueryOptions
());
in
=
std
::
make_shared
<
MaterializingBlockInputStream
>
(
select
->
execute
().
in
);
...
...
dbms/src/Databases/DatabaseDictionary.cpp
浏览文件 @
2e5d61cd
...
...
@@ -52,7 +52,7 @@ Tables DatabaseDictionary::listTables(const Context & context, const FilterByNam
auto
dict_name
=
dict_ptr
->
getName
();
const
DictionaryStructure
&
dictionary_structure
=
dict_ptr
->
getStructure
();
auto
columns
=
StorageDictionary
::
getNamesAndTypes
(
dictionary_structure
);
tables
[
dict_name
]
=
StorageDictionary
::
create
(
getDatabaseName
(),
dict_name
,
ColumnsDescription
{
columns
},
context
,
true
,
dict_name
);
tables
[
dict_name
]
=
StorageDictionary
::
create
(
StorageID
(
getDatabaseName
(),
dict_name
)
,
ColumnsDescription
{
columns
},
context
,
true
,
dict_name
);
}
}
return
tables
;
...
...
@@ -74,7 +74,7 @@ StoragePtr DatabaseDictionary::tryGetTable(
{
const
DictionaryStructure
&
dictionary_structure
=
dict_ptr
->
getStructure
();
auto
columns
=
StorageDictionary
::
getNamesAndTypes
(
dictionary_structure
);
return
StorageDictionary
::
create
(
getDatabaseName
(),
table_name
,
ColumnsDescription
{
columns
},
context
,
true
,
table_name
);
return
StorageDictionary
::
create
(
StorageID
(
getDatabaseName
(),
table_name
)
,
ColumnsDescription
{
columns
},
context
,
true
,
table_name
);
}
return
{};
...
...
dbms/src/Databases/DatabaseMySQL.cpp
浏览文件 @
2e5d61cd
...
...
@@ -239,7 +239,7 @@ void DatabaseMySQL::fetchLatestTablesStructureIntoCache(const std::map<String, U
}
local_tables_cache
[
table_name
]
=
std
::
make_pair
(
table_modification_time
,
StorageMySQL
::
create
(
database_name
,
table_name
,
std
::
move
(
mysql_pool
),
database_name_in_mysql
,
table_name
,
StorageID
(
database_name
,
table_name
)
,
std
::
move
(
mysql_pool
),
database_name_in_mysql
,
table_name
,
false
,
""
,
ColumnsDescription
{
columns_name_and_type
},
ConstraintsDescription
{},
global_context
));
}
}
...
...
dbms/src/Databases/DatabaseOnDisk.cpp
浏览文件 @
2e5d61cd
...
...
@@ -68,9 +68,12 @@ std::pair<String, StoragePtr> createTableFromAST(
ast_create_query
.
table
,
StorageFactory
::
instance
().
get
(
ast_create_query
,
table_data_path_relative
,
ast_create_query
.
table
,
database_name
,
context
,
context
.
getGlobalContext
(),
columns
,
constraints
,
true
,
has_force_restore_data_flag
)
table_data_path_relative
,
context
,
context
.
getGlobalContext
(),
columns
,
constraints
,
has_force_restore_data_flag
)
};
}
...
...
dbms/src/Databases/DatabaseWithDictionaries.cpp
浏览文件 @
2e5d61cd
...
...
@@ -226,7 +226,7 @@ StoragePtr DatabaseWithDictionaries::getDictionaryStorage(const Context & contex
{
const
DictionaryStructure
&
dictionary_structure
=
dict_ptr
->
getStructure
();
auto
columns
=
StorageDictionary
::
getNamesAndTypes
(
dictionary_structure
);
return
StorageDictionary
::
create
(
database_name
,
table_name
,
ColumnsDescription
{
columns
},
context
,
true
,
dict_name
);
return
StorageDictionary
::
create
(
StorageID
(
database_name
,
table_name
)
,
ColumnsDescription
{
columns
},
context
,
true
,
dict_name
);
}
return
nullptr
;
}
...
...
dbms/src/Interpreters/GlobalSubqueriesVisitor.h
浏览文件 @
2e5d61cd
...
...
@@ -95,7 +95,7 @@ public:
Block
sample
=
interpreter
->
getSampleBlock
();
NamesAndTypesList
columns
=
sample
.
getNamesAndTypesList
();
StoragePtr
external_storage
=
StorageMemory
::
create
(
"_external"
,
external_table_name
,
ColumnsDescription
{
columns
},
ConstraintsDescription
{});
StoragePtr
external_storage
=
StorageMemory
::
create
(
StorageID
(
"_external"
,
external_table_name
)
,
ColumnsDescription
{
columns
},
ConstraintsDescription
{});
external_storage
->
startup
();
/** We replace the subquery with the name of the temporary table.
...
...
dbms/src/Interpreters/InterpreterCreateQuery.cpp
浏览文件 @
2e5d61cd
...
...
@@ -631,13 +631,10 @@ bool InterpreterCreateQuery::doCreateTable(const ASTCreateQuery & create,
{
res
=
StorageFactory
::
instance
().
get
(
create
,
database
?
database
->
getTableDataPath
(
create
)
:
""
,
table_name
,
create
.
database
,
context
,
context
.
getGlobalContext
(),
properties
.
columns
,
properties
.
constraints
,
create
.
attach
,
false
);
}
...
...
dbms/src/Interpreters/InterpreterSystemQuery.cpp
浏览文件 @
2e5d61cd
...
...
@@ -295,13 +295,10 @@ StoragePtr InterpreterSystemQuery::tryRestartReplica(const String & database_nam
StoragePtr
table
=
StorageFactory
::
instance
().
get
(
create
,
database
->
getTableDataPath
(
create
),
table_name
,
database_name
,
system_context
,
system_context
.
getGlobalContext
(),
columns
,
constraints
,
create
.
attach
,
false
);
database
->
createTable
(
system_context
,
table_name
,
table
,
create_ast
);
...
...
dbms/src/Parsers/ASTQueryWithTableAndOutput.h
浏览文件 @
2e5d61cd
...
...
@@ -15,6 +15,7 @@ class ASTQueryWithTableAndOutput : public ASTQueryWithOutput
public:
String
database
;
String
table
;
String
uuid
;
bool
temporary
{
false
};
protected:
...
...
dbms/src/Storages/Kafka/StorageKafka.cpp
浏览文件 @
2e5d61cd
...
...
@@ -75,8 +75,7 @@ namespace
}
StorageKafka
::
StorageKafka
(
const
std
::
string
&
table_name_
,
const
std
::
string
&
database_name_
,
const
StorageID
&
table_id_
,
Context
&
context_
,
const
ColumnsDescription
&
columns_
,
const
String
&
brokers_
,
...
...
@@ -89,7 +88,7 @@ StorageKafka::StorageKafka(
UInt64
max_block_size_
,
size_t
skip_broken_
,
bool
intermediate_commit_
)
:
IStorage
(
{
database_name_
,
table_name_
}
,
:
IStorage
(
table_id_
,
ColumnsDescription
({{
"_topic"
,
std
::
make_shared
<
DataTypeString
>
()},
{
"_key"
,
std
::
make_shared
<
DataTypeString
>
()},
{
"_offset"
,
std
::
make_shared
<
DataTypeUInt64
>
()},
...
...
@@ -105,7 +104,7 @@ StorageKafka::StorageKafka(
,
schema_name
(
global_context
.
getMacros
()
->
expand
(
schema_name_
))
,
num_consumers
(
num_consumers_
)
,
max_block_size
(
max_block_size_
)
,
log
(
&
Logger
::
get
(
"StorageKafka ("
+
table_
name_
+
")"
))
,
log
(
&
Logger
::
get
(
"StorageKafka ("
+
table_
id_
.
table_name
+
")"
))
,
semaphore
(
0
,
num_consumers_
)
,
skip_broken
(
skip_broken_
)
,
intermediate_commit
(
intermediate_commit_
)
...
...
@@ -645,7 +644,7 @@ void registerStorageKafka(StorageFactory & factory)
}
return
StorageKafka
::
create
(
args
.
table_
name
,
args
.
database_name
,
args
.
context
,
args
.
columns
,
args
.
table_
id
,
args
.
context
,
args
.
columns
,
brokers
,
group
,
topics
,
format
,
row_delimiter
,
schema
,
num_consumers
,
max_block_size
,
skip_broken
,
intermediate_commit
);
});
}
...
...
dbms/src/Storages/Kafka/StorageKafka.h
浏览文件 @
2e5d61cd
...
...
@@ -64,13 +64,18 @@ public:
protected:
StorageKafka
(
const
std
::
string
&
table_name_
,
const
std
::
string
&
database_name_
,
const
StorageID
&
table_id_
,
Context
&
context_
,
const
ColumnsDescription
&
columns_
,
const
String
&
brokers_
,
const
String
&
group_
,
const
Names
&
topics_
,
const
String
&
format_name_
,
char
row_delimiter_
,
const
String
&
schema_name_
,
size_t
num_consumers_
,
UInt64
max_block_size_
,
size_t
skip_broken
,
const
String
&
brokers_
,
const
String
&
group_
,
const
Names
&
topics_
,
const
String
&
format_name_
,
char
row_delimiter_
,
const
String
&
schema_name_
,
size_t
num_consumers_
,
UInt64
max_block_size_
,
size_t
skip_broken
,
bool
intermediate_commit_
);
private:
...
...
dbms/src/Storages/LiveView/StorageLiveView.cpp
浏览文件 @
2e5d61cd
...
...
@@ -193,12 +193,11 @@ void StorageLiveView::writeIntoLiveView(
StorageLiveView
::
StorageLiveView
(
const
String
&
table_name_
,
const
String
&
database_name_
,
const
StorageID
&
table_id_
,
Context
&
local_context
,
const
ASTCreateQuery
&
query
,
const
ColumnsDescription
&
columns_
)
:
IStorage
(
{
database_name_
,
table_name_
}
),
global_context
(
local_context
.
getGlobalContext
())
:
IStorage
(
table_id_
),
global_context
(
local_context
.
getGlobalContext
())
{
setColumns
(
columns_
);
...
...
@@ -224,7 +223,7 @@ StorageLiveView::StorageLiveView(
global_context
.
addDependency
(
DatabaseAndTableName
(
select_database_name
,
select_table_name
),
DatabaseAndTableName
(
database_name_
,
table_name_
));
//FIXME
DatabaseAndTableName
(
table_id_
.
database_name
,
table_id_
.
table_name
));
//FIXME
is_temporary
=
query
.
temporary
;
temporary_live_view_timeout
=
local_context
.
getSettingsRef
().
temporary_live_view_timeout
.
totalSeconds
();
...
...
@@ -599,7 +598,7 @@ void registerStorageLiveView(StorageFactory & factory)
if
(
!
args
.
attach
&&
!
args
.
local_context
.
getSettingsRef
().
allow_experimental_live_view
)
throw
Exception
(
"Experimental LIVE VIEW feature is not enabled (the setting 'allow_experimental_live_view')"
,
ErrorCodes
::
SUPPORT_IS_DISABLED
);
return
StorageLiveView
::
create
(
args
.
table_
name
,
args
.
database_name
,
args
.
local_context
,
args
.
query
,
args
.
columns
);
return
StorageLiveView
::
create
(
args
.
table_
id
,
args
.
local_context
,
args
.
query
,
args
.
columns
);
});
}
...
...
dbms/src/Storages/LiveView/StorageLiveView.h
浏览文件 @
2e5d61cd
...
...
@@ -173,8 +173,7 @@ private:
UInt64
temporary_live_view_timeout
;
StorageLiveView
(
const
String
&
table_name_
,
const
String
&
database_name_
,
const
StorageID
&
table_id_
,
Context
&
local_context
,
const
ASTCreateQuery
&
query
,
const
ColumnsDescription
&
columns
...
...
dbms/src/Storages/MergeTree/MergeTreeData.cpp
浏览文件 @
2e5d61cd
...
...
@@ -110,8 +110,7 @@ namespace
MergeTreeData
::
MergeTreeData
(
const
String
&
database_
,
const
String
&
table_
,
const
StorageID
&
table_id_
,
const
String
&
relative_data_path_
,
const
ColumnsDescription
&
columns_
,
const
IndicesDescription
&
indices_
,
...
...
@@ -128,7 +127,7 @@ MergeTreeData::MergeTreeData(
bool
require_part_metadata_
,
bool
attach
,
BrokenPartCallback
broken_part_callback_
)
:
IStorage
(
{
database_
,
table_
}
)
:
IStorage
(
table_id_
)
,
global_context
(
context_
)
,
merging_params
(
merging_params_
)
,
partition_by_ast
(
partition_by_ast_
)
...
...
@@ -136,7 +135,7 @@ MergeTreeData::MergeTreeData(
,
require_part_metadata
(
require_part_metadata_
)
,
relative_data_path
(
relative_data_path_
)
,
broken_part_callback
(
broken_part_callback_
)
,
log_name
(
database_
+
"."
+
table_
)
,
log_name
(
table_id_
.
getNameForLogs
()
)
,
log
(
&
Logger
::
get
(
log_name
))
,
storage_settings
(
std
::
move
(
storage_settings_
))
,
storage_policy
(
context_
.
getStoragePolicy
(
getSettings
()
->
storage_policy
))
...
...
dbms/src/Storages/MergeTree/MergeTreeData.h
浏览文件 @
2e5d61cd
...
...
@@ -330,7 +330,7 @@ public:
///
/// require_part_metadata - should checksums.txt and columns.txt exist in the part directory.
/// attach - whether the existing table is attached or the new table is created.
MergeTreeData
(
const
St
ring
&
database_
,
const
String
&
table
_
,
MergeTreeData
(
const
St
orageID
&
table_id
_
,
const
String
&
relative_data_path_
,
const
ColumnsDescription
&
columns_
,
const
IndicesDescription
&
indices_
,
...
...
dbms/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h
浏览文件 @
2e5d61cd
...
...
@@ -49,8 +49,12 @@ public:
protected:
StorageFromMergeTreeDataPart
(
const
MergeTreeData
::
DataPartPtr
&
part_
)
:
IStorage
({
part_
->
storage
.
getDatabaseName
(),
part_
->
storage
.
getTableName
()
+
" (part "
+
part_
->
name
+
")"
},
part_
->
storage
.
getVirtuals
()),
part
(
part_
)
:
IStorage
({
part_
->
storage
.
getDatabaseName
(),
part_
->
storage
.
getTableName
()
+
" (part "
+
part_
->
name
+
")"
}
,
part_
->
storage
.
getVirtuals
())
,
part
(
part_
)
{
setColumns
(
part_
->
storage
.
getColumns
());
setIndices
(
part_
->
storage
.
getIndices
());
...
...
dbms/src/Storages/MergeTree/registerStorageMergeTree.cpp
浏览文件 @
2e5d61cd
...
...
@@ -639,14 +639,14 @@ static StoragePtr create(const StorageFactory::Arguments & args)
if
(
replicated
)
return
StorageReplicatedMergeTree
::
create
(
zookeeper_path
,
replica_name
,
args
.
attach
,
args
.
database_name
,
args
.
table_name
,
args
.
relative_data_path
,
zookeeper_path
,
replica_name
,
args
.
attach
,
args
.
table_id
,
args
.
relative_data_path
,
args
.
columns
,
indices_description
,
args
.
constraints
,
args
.
context
,
date_column_name
,
partition_by_ast
,
order_by_ast
,
primary_key_ast
,
sample_by_ast
,
ttl_table_ast
,
merging_params
,
std
::
move
(
storage_settings
),
args
.
has_force_restore_data_flag
);
else
return
StorageMergeTree
::
create
(
args
.
database_name
,
args
.
table_name
,
args
.
relative_data_path
,
args
.
columns
,
indices_description
,
args
.
table_id
,
args
.
relative_data_path
,
args
.
columns
,
indices_description
,
args
.
constraints
,
args
.
attach
,
args
.
context
,
date_column_name
,
partition_by_ast
,
order_by_ast
,
primary_key_ast
,
sample_by_ast
,
ttl_table_ast
,
merging_params
,
std
::
move
(
storage_settings
),
args
.
has_force_restore_data_flag
);
...
...
dbms/src/Storages/StorageBuffer.cpp
浏览文件 @
2e5d61cd
...
...
@@ -56,18 +56,27 @@ namespace ErrorCodes
}
StorageBuffer
::
StorageBuffer
(
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
StorageBuffer
::
StorageBuffer
(
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
Context
&
context_
,
size_t
num_shards_
,
const
Thresholds
&
min_thresholds_
,
const
Thresholds
&
max_thresholds_
,
const
String
&
destination_database_
,
const
String
&
destination_table_
,
bool
allow_materialized_
)
:
IStorage
({
database_name_
,
table_name_
}),
global_context
(
context_
),
num_shards
(
num_shards_
),
buffers
(
num_shards_
),
min_thresholds
(
min_thresholds_
),
max_thresholds
(
max_thresholds_
),
destination_database
(
destination_database_
),
destination_table
(
destination_table_
),
no_destination
(
destination_database
.
empty
()
&&
destination_table
.
empty
()),
allow_materialized
(
allow_materialized_
),
log
(
&
Logger
::
get
(
"StorageBuffer ("
+
table_name_
+
")"
))
size_t
num_shards_
,
const
Thresholds
&
min_thresholds_
,
const
Thresholds
&
max_thresholds_
,
const
String
&
destination_database_
,
const
String
&
destination_table_
,
bool
allow_materialized_
)
:
IStorage
(
table_id_
)
,
global_context
(
context_
)
,
num_shards
(
num_shards_
),
buffers
(
num_shards_
)
,
min_thresholds
(
min_thresholds_
)
,
max_thresholds
(
max_thresholds_
)
,
destination_database
(
destination_database_
)
,
destination_table
(
destination_table_
)
,
no_destination
(
destination_database
.
empty
()
&&
destination_table
.
empty
())
,
allow_materialized
(
allow_materialized_
)
,
log
(
&
Logger
::
get
(
"StorageBuffer ("
+
table_id_
.
getFullTableName
()
+
")"
))
{
setColumns
(
columns_
);
setConstraints
(
constraints_
);
...
...
@@ -753,8 +762,9 @@ void registerStorageBuffer(StorageFactory & factory)
UInt64
max_bytes
=
applyVisitor
(
FieldVisitorConvertToNumber
<
UInt64
>
(),
engine_args
[
8
]
->
as
<
ASTLiteral
&>
().
value
);
return
StorageBuffer
::
create
(
args
.
database_name
,
args
.
table_name
,
args
.
columns
,
args
.
constraints
,
args
.
table_id
,
args
.
columns
,
args
.
constraints
,
args
.
context
,
num_buckets
,
StorageBuffer
::
Thresholds
{
min_time
,
min_rows
,
min_bytes
},
...
...
dbms/src/Storages/StorageBuffer.h
浏览文件 @
2e5d61cd
...
...
@@ -135,11 +135,17 @@ protected:
/** num_shards - the level of internal parallelism (the number of independent buffers)
* The buffer is flushed if all minimum thresholds or at least one of the maximum thresholds are exceeded.
*/
StorageBuffer
(
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
StorageBuffer
(
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
Context
&
context_
,
size_t
num_shards_
,
const
Thresholds
&
min_thresholds_
,
const
Thresholds
&
max_thresholds_
,
const
String
&
destination_database_
,
const
String
&
destination_table_
,
bool
allow_materialized_
);
size_t
num_shards_
,
const
Thresholds
&
min_thresholds_
,
const
Thresholds
&
max_thresholds_
,
const
String
&
destination_database_
,
const
String
&
destination_table_
,
bool
allow_materialized_
);
};
}
dbms/src/Storages/StorageDictionary.cpp
浏览文件 @
2e5d61cd
...
...
@@ -24,15 +24,14 @@ namespace ErrorCodes
StorageDictionary
::
StorageDictionary
(
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
Context
&
context
,
bool
attach
,
const
String
&
dictionary_name_
)
:
IStorage
(
{
database_name_
,
table_name_
}),
dictionary_name
(
dictionary_name_
),
logger
(
&
Poco
::
Logger
::
get
(
"StorageDictionary"
))
:
IStorage
(
table_id_
)
,
dictionary_name
(
dictionary_name_
)
,
logger
(
&
Poco
::
Logger
::
get
(
"StorageDictionary"
))
{
setColumns
(
columns_
);
...
...
@@ -107,7 +106,7 @@ void registerStorageDictionary(StorageFactory & factory)
String
dictionary_name
=
args
.
engine_args
[
0
]
->
as
<
ASTLiteral
&>
().
value
.
safeGet
<
String
>
();
return
StorageDictionary
::
create
(
args
.
database_name
,
args
.
table_name
,
args
.
columns
,
args
.
context
,
args
.
attach
,
dictionary_name
);
args
.
table_id
,
args
.
columns
,
args
.
context
,
args
.
attach
,
dictionary_name
);
});
}
...
...
dbms/src/Storages/StorageDictionary.h
浏览文件 @
2e5d61cd
...
...
@@ -64,8 +64,7 @@ private:
protected:
StorageDictionary
(
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
Context
&
context
,
bool
attach
,
...
...
dbms/src/Storages/StorageDistributed.cpp
浏览文件 @
2e5d61cd
...
...
@@ -205,8 +205,7 @@ static ExpressionActionsPtr buildShardingKeyExpression(const ASTPtr & sharding_k
}
StorageDistributed
::
StorageDistributed
(
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
const
String
&
remote_database_
,
...
...
@@ -216,12 +215,18 @@ StorageDistributed::StorageDistributed(
const
ASTPtr
&
sharding_key_
,
const
String
&
relative_data_path_
,
bool
attach_
)
:
IStorage
({
database_name_
,
table_name_
},
ColumnsDescription
({
{
"_shard_num"
,
std
::
make_shared
<
DataTypeUInt32
>
()},
},
true
)),
remote_database
(
remote_database_
),
remote_table
(
remote_table_
),
global_context
(
context_
),
cluster_name
(
global_context
.
getMacros
()
->
expand
(
cluster_name_
)),
has_sharding_key
(
sharding_key_
),
path
(
relative_data_path_
.
empty
()
?
""
:
(
context_
.
getPath
()
+
relative_data_path_
))
:
IStorage
(
id_
,
ColumnsDescription
(
{
{
"_shard_num"
,
std
::
make_shared
<
DataTypeUInt32
>
()},
},
true
))
,
remote_database
(
remote_database_
)
,
remote_table
(
remote_table_
)
,
global_context
(
context_
)
,
cluster_name
(
global_context
.
getMacros
()
->
expand
(
cluster_name_
))
,
has_sharding_key
(
sharding_key_
)
,
path
(
relative_data_path_
.
empty
()
?
""
:
(
context_
.
getPath
()
+
relative_data_path_
))
{
setColumns
(
columns_
);
setConstraints
(
constraints_
);
...
...
@@ -236,15 +241,14 @@ StorageDistributed::StorageDistributed(
if
(
!
attach_
&&
!
cluster_name
.
empty
())
{
size_t
num_local_shards
=
global_context
.
getCluster
(
cluster_name
)
->
getLocalShardCount
();
if
(
num_local_shards
&&
remote_database
==
database_name_
&&
remote_table
==
table_name_
)
throw
Exception
(
"Distributed table "
+
table_name_
+
" looks at itself"
,
ErrorCodes
::
INFINITE_LOOP
);
if
(
num_local_shards
&&
remote_database
==
id_
.
database_name
&&
remote_table
==
id_
.
table_name
)
throw
Exception
(
"Distributed table "
+
id_
.
table_name
+
" looks at itself"
,
ErrorCodes
::
INFINITE_LOOP
);
}
}
StorageDistributed
::
StorageDistributed
(
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
ASTPtr
remote_table_function_ptr_
,
...
...
@@ -253,34 +257,34 @@ StorageDistributed::StorageDistributed(
const
ASTPtr
&
sharding_key_
,
const
String
&
relative_data_path_
,
bool
attach
)
:
StorageDistributed
(
database_name_
,
table_name
_
,
columns_
,
constraints_
,
String
{},
String
{},
cluster_name_
,
context_
,
sharding_key_
,
relative_data_path_
,
attach
)
:
StorageDistributed
(
id
_
,
columns_
,
constraints_
,
String
{},
String
{},
cluster_name_
,
context_
,
sharding_key_
,
relative_data_path_
,
attach
)
{
remote_table_function_ptr
=
remote_table_function_ptr_
;
remote_table_function_ptr
=
std
::
move
(
remote_table_function_ptr_
)
;
}
StoragePtr
StorageDistributed
::
createWithOwnCluster
(
const
std
::
string
&
table_name
_
,
const
StorageID
&
table_id
_
,
const
ColumnsDescription
&
columns_
,
const
String
&
remote_database_
,
/// database on remote servers.
const
String
&
remote_table_
,
/// The name of the table on the remote servers.
ClusterPtr
owned_cluster_
,
const
Context
&
context_
)
{
auto
res
=
create
(
String
{},
table_name
_
,
columns_
,
ConstraintsDescription
{},
remote_database_
,
remote_table_
,
String
{},
context_
,
ASTPtr
(),
String
(),
false
);
res
->
owned_cluster
=
owned_cluster_
;
auto
res
=
create
(
table_id
_
,
columns_
,
ConstraintsDescription
{},
remote_database_
,
remote_table_
,
String
{},
context_
,
ASTPtr
(),
String
(),
false
);
res
->
owned_cluster
=
std
::
move
(
owned_cluster_
)
;
return
res
;
}
StoragePtr
StorageDistributed
::
createWithOwnCluster
(
const
std
::
string
&
table_name
_
,
const
StorageID
&
table_id
_
,
const
ColumnsDescription
&
columns_
,
ASTPtr
&
remote_table_function_ptr_
,
ClusterPtr
&
owned_cluster_
,
const
Context
&
context_
)
{
auto
res
=
create
(
String
{},
table_name
_
,
columns_
,
ConstraintsDescription
{},
remote_table_function_ptr_
,
String
{},
context_
,
ASTPtr
(),
String
(),
false
);
auto
res
=
create
(
table_id
_
,
columns_
,
ConstraintsDescription
{},
remote_table_function_ptr_
,
String
{},
context_
,
ASTPtr
(),
String
(),
false
);
res
->
owned_cluster
=
owned_cluster_
;
return
res
;
}
...
...
@@ -662,7 +666,7 @@ void registerStorageDistributed(StorageFactory & factory)
}
return
StorageDistributed
::
create
(
args
.
database_name
,
args
.
table_name
,
args
.
columns
,
args
.
constraints
,
args
.
table_id
,
args
.
columns
,
args
.
constraints
,
remote_database
,
remote_table
,
cluster_name
,
args
.
context
,
sharding_key
,
args
.
relative_data_path
,
args
.
attach
);
...
...
dbms/src/Storages/StorageDistributed.h
浏览文件 @
2e5d61cd
...
...
@@ -37,7 +37,7 @@ public:
~
StorageDistributed
()
override
;
static
StoragePtr
createWithOwnCluster
(
const
std
::
string
&
table_name
_
,
const
StorageID
&
table_id
_
,
const
ColumnsDescription
&
columns_
,
const
String
&
remote_database_
,
/// database on remote servers.
const
String
&
remote_table_
,
/// The name of the table on the remote servers.
...
...
@@ -45,7 +45,7 @@ public:
const
Context
&
context_
);
static
StoragePtr
createWithOwnCluster
(
const
std
::
string
&
table_name
_
,
const
StorageID
&
table_id
_
,
const
ColumnsDescription
&
columns_
,
ASTPtr
&
remote_table_function_ptr_
,
/// Table function ptr.
ClusterPtr
&
owned_cluster_
,
...
...
@@ -155,8 +155,7 @@ public:
protected:
StorageDistributed
(
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
const
String
&
remote_database_
,
...
...
@@ -168,8 +167,7 @@ protected:
bool
attach_
);
StorageDistributed
(
const
String
&
database_name
,
const
String
&
table_name_
,
const
StorageID
&
id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
ASTPtr
remote_table_function_ptr_
,
...
...
dbms/src/Storages/StorageFactory.cpp
浏览文件 @
2e5d61cd
...
...
@@ -5,6 +5,7 @@
#include <Common/Exception.h>
#include <Common/StringUtils/StringUtils.h>
#include <IO/WriteHelpers.h>
#include <Storages/IStorage.h>
namespace
DB
{
...
...
@@ -41,13 +42,10 @@ void StorageFactory::registerStorage(const std::string & name, Creator creator)
StoragePtr
StorageFactory
::
get
(
const
ASTCreateQuery
&
query
,
const
String
&
relative_data_path
,
const
String
&
table_name
,
const
String
&
database_name
,
Context
&
local_context
,
Context
&
context
,
const
ColumnsDescription
&
columns
,
const
ConstraintsDescription
&
constraints
,
bool
attach
,
bool
has_force_restore_data_flag
)
const
{
String
name
;
...
...
@@ -151,13 +149,12 @@ StoragePtr StorageFactory::get(
.
storage_def
=
storage_def
,
.
query
=
query
,
.
relative_data_path
=
relative_data_path
,
.
table_name
=
table_name
,
.
database_name
=
database_name
,
.
table_id
=
StorageID
(
query
.
database
,
query
.
table
,
query
.
uuid
),
.
local_context
=
local_context
,
.
context
=
context
,
.
columns
=
columns
,
.
constraints
=
constraints
,
.
attach
=
attach
,
.
attach
=
query
.
attach
,
.
has_force_restore_data_flag
=
has_force_restore_data_flag
};
...
...
dbms/src/Storages/StorageFactory.h
浏览文件 @
2e5d61cd
...
...
@@ -15,6 +15,7 @@ namespace DB
class
Context
;
class
ASTCreateQuery
;
class
ASTStorage
;
struct
StorageID
;
/** Allows to create a table by the name and parameters of the engine.
...
...
@@ -36,8 +37,7 @@ public:
/// Path to table data.
/// Relative to <path> from server config (possibly <path> of some <disk> of some <volume> for *MergeTree)
const
String
&
relative_data_path
;
const
String
&
table_name
;
const
String
&
database_name
;
const
StorageID
&
table_id
;
Context
&
local_context
;
Context
&
context
;
const
ColumnsDescription
&
columns
;
...
...
@@ -51,13 +51,10 @@ public:
StoragePtr
get
(
const
ASTCreateQuery
&
query
,
const
String
&
relative_data_path
,
const
String
&
table_name
,
const
String
&
database_name
,
Context
&
local_context
,
Context
&
context
,
const
ColumnsDescription
&
columns
,
const
ConstraintsDescription
&
constraints
,
bool
attach
,
bool
has_force_restore_data_flag
)
const
;
/// Register a table engine by its name.
...
...
dbms/src/Storages/StorageFile.cpp
浏览文件 @
2e5d61cd
...
...
@@ -165,8 +165,10 @@ StorageFile::StorageFile(const std::string & relative_table_dir_path, CommonArgu
}
StorageFile
::
StorageFile
(
CommonArguments
args
)
:
IStorage
({
args
.
database_name
,
args
.
table_name
}),
format_name
(
args
.
format_name
),
compression_method
(
args
.
compression_method
),
base_path
(
args
.
context
.
getPath
())
:
IStorage
(
args
.
table_id
)
,
format_name
(
args
.
format_name
)
,
compression_method
(
args
.
compression_method
)
,
base_path
(
args
.
context
.
getPath
())
{
setColumns
(
args
.
columns
);
setConstraints
(
args
.
constraints
);
...
...
@@ -378,7 +380,7 @@ void registerStorageFile(StorageFactory & factory)
String
format_name
=
engine_args
[
0
]
->
as
<
ASTLiteral
&>
().
value
.
safeGet
<
String
>
();
String
compression_method
;
StorageFile
::
CommonArguments
common_args
{
args
.
database_name
,
args
.
table_name
,
format_name
,
compression_method
,
StorageFile
::
CommonArguments
common_args
{
args
.
table_id
,
format_name
,
compression_method
,
args
.
columns
,
args
.
constraints
,
args
.
context
};
if
(
engine_args
.
size
()
==
1
)
/// Table in database
...
...
dbms/src/Storages/StorageFile.h
浏览文件 @
2e5d61cd
...
...
@@ -42,8 +42,7 @@ public:
struct
CommonArguments
{
const
std
::
string
&
database_name
;
const
std
::
string
&
table_name
;
const
StorageID
&
table_id
;
const
std
::
string
&
format_name
;
const
std
::
string
&
compression_method
;
const
ColumnsDescription
&
columns
;
...
...
dbms/src/Storages/StorageHDFS.cpp
浏览文件 @
2e5d61cd
...
...
@@ -35,14 +35,13 @@ namespace ErrorCodes
}
StorageHDFS
::
StorageHDFS
(
const
String
&
uri_
,
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
String
&
format_name_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
Context
&
context_
,
const
String
&
compression_method_
=
""
)
:
IStorage
(
{
database_name_
,
table_name_
}
)
:
IStorage
(
table_id_
)
,
uri
(
uri_
)
,
format_name
(
format_name_
)
,
context
(
context_
)
...
...
@@ -252,7 +251,7 @@ void registerStorageHDFS(StorageFactory & factory)
compression_method
=
engine_args
[
2
]
->
as
<
ASTLiteral
&>
().
value
.
safeGet
<
String
>
();
}
else
compression_method
=
"auto"
;
return
StorageHDFS
::
create
(
url
,
args
.
database_name
,
args
.
table_name
,
format_name
,
args
.
columns
,
args
.
constraints
,
args
.
context
,
compression_method
);
return
StorageHDFS
::
create
(
url
,
args
.
table_id
,
format_name
,
args
.
columns
,
args
.
constraints
,
args
.
context
,
compression_method
);
});
}
...
...
dbms/src/Storages/StorageHDFS.h
浏览文件 @
2e5d61cd
...
...
@@ -30,8 +30,7 @@ public:
protected:
StorageHDFS
(
const
String
&
uri_
,
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
String
&
format_name_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
...
...
dbms/src/Storages/StorageInput.cpp
浏览文件 @
2e5d61cd
...
...
@@ -15,7 +15,7 @@ namespace ErrorCodes
extern
const
int
INVALID_USAGE_OF_INPUT
;
}
StorageInput
::
StorageInput
(
const
String
&
table_name_
,
const
ColumnsDescription
&
columns_
)
StorageInput
::
StorageInput
(
const
String
&
table_name_
,
const
ColumnsDescription
&
columns_
)
:
IStorage
({
""
,
table_name_
},
columns_
)
{
setColumns
(
columns_
);
...
...
dbms/src/Storages/StorageJoin.cpp
浏览文件 @
2e5d61cd
...
...
@@ -29,8 +29,7 @@ namespace ErrorCodes
StorageJoin
::
StorageJoin
(
const
String
&
relative_path_
,
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
Names
&
key_names_
,
bool
use_nulls_
,
SizeLimits
limits_
,
...
...
@@ -40,7 +39,7 @@ StorageJoin::StorageJoin(
const
ConstraintsDescription
&
constraints_
,
bool
overwrite
,
const
Context
&
context_
)
:
StorageSetOrJoinBase
{
relative_path_
,
database_name_
,
table_name
_
,
columns_
,
constraints_
,
context_
}
:
StorageSetOrJoinBase
{
relative_path_
,
table_id
_
,
columns_
,
constraints_
,
context_
}
,
key_names
(
key_names_
)
,
use_nulls
(
use_nulls_
)
,
limits
(
limits_
)
...
...
@@ -172,8 +171,7 @@ void registerStorageJoin(StorageFactory & factory)
return
StorageJoin
::
create
(
args
.
relative_data_path
,
args
.
database_name
,
args
.
table_name
,
args
.
table_id
,
key_names
,
join_use_nulls
,
SizeLimits
{
max_rows_in_join
,
max_bytes_in_join
,
join_overflow_mode
},
...
...
dbms/src/Storages/StorageJoin.h
浏览文件 @
2e5d61cd
...
...
@@ -62,8 +62,7 @@ private:
protected:
StorageJoin
(
const
String
&
relative_path_
,
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
Names
&
key_names_
,
bool
use_nulls_
,
SizeLimits
limits_
,
...
...
dbms/src/Storages/StorageLog.cpp
浏览文件 @
2e5d61cd
...
...
@@ -419,15 +419,16 @@ void LogBlockOutputStream::writeMarks(MarksForColumns && marks)
StorageLog
::
StorageLog
(
const
std
::
string
&
relative_path_
,
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
size_t
max_compress_block_size_
,
const
Context
&
context_
)
:
IStorage
({
database_name_
,
table_name_
}),
base_path
(
context_
.
getPath
()),
path
(
base_path
+
relative_path_
),
max_compress_block_size
(
max_compress_block_size_
),
file_checker
(
path
+
"sizes.json"
)
:
IStorage
(
table_id_
)
,
base_path
(
context_
.
getPath
())
,
path
(
base_path
+
relative_path_
)
,
max_compress_block_size
(
max_compress_block_size_
)
,
file_checker
(
path
+
"sizes.json"
)
{
setColumns
(
columns_
);
setConstraints
(
constraints_
);
...
...
@@ -648,7 +649,7 @@ void registerStorageLog(StorageFactory & factory)
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
StorageLog
::
create
(
args
.
relative_data_path
,
args
.
database_name
,
args
.
table_name
,
args
.
columns
,
args
.
constraints
,
args
.
relative_data_path
,
args
.
table_id
,
args
.
columns
,
args
.
constraints
,
args
.
context
.
getSettings
().
max_compress_block_size
,
args
.
context
);
});
}
...
...
dbms/src/Storages/StorageLog.h
浏览文件 @
2e5d61cd
...
...
@@ -53,8 +53,7 @@ protected:
*/
StorageLog
(
const
std
::
string
&
relative_path_
,
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
size_t
max_compress_block_size_
,
...
...
dbms/src/Storages/StorageMaterializedView.cpp
浏览文件 @
2e5d61cd
...
...
@@ -94,13 +94,12 @@ static void checkAllowedQueries(const ASTSelectQuery & query)
StorageMaterializedView
::
StorageMaterializedView
(
const
String
&
table_name_
,
const
String
&
database_name_
,
const
StorageID
&
table_id_
,
Context
&
local_context
,
const
ASTCreateQuery
&
query
,
const
ColumnsDescription
&
columns_
,
bool
attach_
)
:
IStorage
(
{
database_name_
,
table_name_
}
),
global_context
(
local_context
.
getGlobalContext
())
:
IStorage
(
table_id_
),
global_context
(
local_context
.
getGlobalContext
())
{
setColumns
(
columns_
);
...
...
@@ -126,7 +125,7 @@ StorageMaterializedView::StorageMaterializedView(
if
(
!
select_table_name
.
empty
())
global_context
.
addDependency
(
DatabaseAndTableName
(
select_database_name
,
select_table_name
),
DatabaseAndTableName
(
database_name_
,
table_name_
));
//FIXME
DatabaseAndTableName
(
table_id_
.
database_name
,
table_id_
.
table_name
));
//FIXME
// If the destination table is not set, use inner table
if
(
!
query
.
to_table
.
empty
())
...
...
@@ -136,8 +135,8 @@ StorageMaterializedView::StorageMaterializedView(
}
else
{
target_database_name
=
database_name_
;
target_table_name
=
generateInnerTableName
(
table_
name_
);
target_database_name
=
table_id_
.
database_name
;
target_table_name
=
generateInnerTableName
(
table_
id_
.
table_name
);
has_inner_table
=
true
;
}
...
...
@@ -168,7 +167,7 @@ StorageMaterializedView::StorageMaterializedView(
if
(
!
select_table_name
.
empty
())
global_context
.
removeDependency
(
DatabaseAndTableName
(
select_database_name
,
select_table_name
),
DatabaseAndTableName
(
database_name_
,
table_name_
));
//FIXME
DatabaseAndTableName
(
table_id_
.
database_name
,
table_id_
.
table_name
));
//FIXME
throw
;
}
...
...
@@ -390,7 +389,7 @@ void registerStorageMaterializedView(StorageFactory & factory)
{
/// Pass local_context here to convey setting for inner table
return
StorageMaterializedView
::
create
(
args
.
table_
name
,
args
.
database_name
,
args
.
local_context
,
args
.
query
,
args
.
table_
id
,
args
.
local_context
,
args
.
query
,
args
.
columns
,
args
.
attach
);
});
}
...
...
dbms/src/Storages/StorageMaterializedView.h
浏览文件 @
2e5d61cd
...
...
@@ -78,8 +78,7 @@ private:
protected:
StorageMaterializedView
(
const
String
&
table_name_
,
const
String
&
database_name_
,
const
StorageID
&
table_id_
,
Context
&
local_context
,
const
ASTCreateQuery
&
query
,
const
ColumnsDescription
&
columns_
,
...
...
dbms/src/Storages/StorageMemory.cpp
浏览文件 @
2e5d61cd
...
...
@@ -74,8 +74,8 @@ private:
};
StorageMemory
::
StorageMemory
(
String
database_name_
,
String
table_name
_
,
ColumnsDescription
columns_description_
,
ConstraintsDescription
constraints_
)
:
IStorage
(
{
database_name_
,
table_name_
}
)
StorageMemory
::
StorageMemory
(
const
StorageID
&
table_id
_
,
ColumnsDescription
columns_description_
,
ConstraintsDescription
constraints_
)
:
IStorage
(
table_id_
)
{
setColumns
(
std
::
move
(
columns_description_
));
setConstraints
(
std
::
move
(
constraints_
));
...
...
@@ -145,7 +145,7 @@ void registerStorageMemory(StorageFactory & factory)
"Engine "
+
args
.
engine_name
+
" doesn't support any arguments ("
+
toString
(
args
.
engine_args
.
size
())
+
" given)"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
StorageMemory
::
create
(
args
.
database_name
,
args
.
table_name
,
args
.
columns
,
args
.
constraints
);
return
StorageMemory
::
create
(
args
.
table_id
,
args
.
columns
,
args
.
constraints
);
});
}
...
...
dbms/src/Storages/StorageMemory.h
浏览文件 @
2e5d61cd
...
...
@@ -49,7 +49,7 @@ private:
std
::
mutex
mutex
;
protected:
StorageMemory
(
String
database_name_
,
String
table_name
_
,
ColumnsDescription
columns_description_
,
ConstraintsDescription
constraints_
);
StorageMemory
(
const
StorageID
&
table_id
_
,
ColumnsDescription
columns_description_
,
ConstraintsDescription
constraints_
);
};
}
dbms/src/Storages/StorageMerge.cpp
浏览文件 @
2e5d61cd
...
...
@@ -46,13 +46,12 @@ namespace ErrorCodes
StorageMerge
::
StorageMerge
(
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
String
&
source_database_
,
const
String
&
table_name_regexp_
,
const
Context
&
context_
)
:
IStorage
(
{
database_name_
,
table_name_
}
,
ColumnsDescription
({{
"_table"
,
std
::
make_shared
<
DataTypeString
>
()}},
true
))
:
IStorage
(
table_id_
,
ColumnsDescription
({{
"_table"
,
std
::
make_shared
<
DataTypeString
>
()}},
true
))
,
source_database
(
source_database_
)
,
table_name_regexp
(
table_name_regexp_
)
,
global_context
(
context_
)
...
...
@@ -512,7 +511,7 @@ void registerStorageMerge(StorageFactory & factory)
String
table_name_regexp
=
engine_args
[
1
]
->
as
<
ASTLiteral
&>
().
value
.
safeGet
<
String
>
();
return
StorageMerge
::
create
(
args
.
database_name
,
args
.
table_name
,
args
.
columns
,
args
.
table_id
,
args
.
columns
,
source_database
,
table_name_regexp
,
args
.
context
);
});
}
...
...
dbms/src/Storages/StorageMerge.h
浏览文件 @
2e5d61cd
...
...
@@ -65,8 +65,7 @@ private:
protected:
StorageMerge
(
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
String
&
source_database_
,
const
String
&
table_name_regexp_
,
...
...
dbms/src/Storages/StorageMergeTree.cpp
浏览文件 @
2e5d61cd
...
...
@@ -53,8 +53,7 @@ namespace ActionLocks
StorageMergeTree
::
StorageMergeTree
(
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
String
&
relative_data_path_
,
const
ColumnsDescription
&
columns_
,
const
IndicesDescription
&
indices_
,
...
...
@@ -70,13 +69,25 @@ StorageMergeTree::StorageMergeTree(
const
MergingParams
&
merging_params_
,
std
::
unique_ptr
<
MergeTreeSettings
>
storage_settings_
,
bool
has_force_restore_data_flag
)
:
MergeTreeData
(
database_name_
,
table_name_
,
relative_data_path_
,
columns_
,
indices_
,
constraints_
,
context_
,
date_column_name
,
partition_by_ast_
,
order_by_ast_
,
primary_key_ast_
,
sample_by_ast_
,
ttl_table_ast_
,
merging_params_
,
std
::
move
(
storage_settings_
),
false
,
attach
),
reader
(
*
this
),
writer
(
*
this
),
merger_mutator
(
*
this
,
global_context
.
getBackgroundPool
().
getNumberOfThreads
())
:
MergeTreeData
(
table_id_
,
relative_data_path_
,
columns_
,
indices_
,
constraints_
,
context_
,
date_column_name
,
partition_by_ast_
,
order_by_ast_
,
primary_key_ast_
,
sample_by_ast_
,
ttl_table_ast_
,
merging_params_
,
std
::
move
(
storage_settings_
),
false
,
/// require_part_metadata
attach
)
,
reader
(
*
this
)
,
writer
(
*
this
)
,
merger_mutator
(
*
this
,
global_context
.
getBackgroundPool
().
getNumberOfThreads
())
{
loadDataParts
(
has_force_restore_data_flag
);
...
...
dbms/src/Storages/StorageMergeTree.h
浏览文件 @
2e5d61cd
...
...
@@ -156,8 +156,7 @@ protected:
* See MergeTreeData constructor for comments on parameters.
*/
StorageMergeTree
(
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
String
&
relative_data_path_
,
const
ColumnsDescription
&
columns_
,
const
IndicesDescription
&
indices_
,
...
...
dbms/src/Storages/StorageMySQL.cpp
浏览文件 @
2e5d61cd
...
...
@@ -37,8 +37,7 @@ static String backQuoteMySQL(const String & x)
}
StorageMySQL
::
StorageMySQL
(
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
mysqlxx
::
Pool
&&
pool_
,
const
std
::
string
&
remote_database_name_
,
const
std
::
string
&
remote_table_name_
,
...
...
@@ -47,7 +46,7 @@ StorageMySQL::StorageMySQL(
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
const
Context
&
context_
)
:
IStorage
(
{
database_name_
,
table_name_
}
)
:
IStorage
(
table_id_
)
,
remote_database_name
(
remote_database_name_
)
,
remote_table_name
(
remote_table_name_
)
,
replace_query
{
replace_query_
}
...
...
@@ -234,8 +233,7 @@ void registerStorageMySQL(StorageFactory & factory)
ErrorCodes
::
BAD_ARGUMENTS
);
return
StorageMySQL
::
create
(
args
.
database_name
,
args
.
table_name
,
args
.
table_id
,
std
::
move
(
pool
),
remote_database
,
remote_table
,
...
...
dbms/src/Storages/StorageMySQL.h
浏览文件 @
2e5d61cd
...
...
@@ -21,8 +21,7 @@ class StorageMySQL : public ext::shared_ptr_helper<StorageMySQL>, public IStorag
friend
struct
ext
::
shared_ptr_helper
<
StorageMySQL
>
;
public:
StorageMySQL
(
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
mysqlxx
::
Pool
&&
pool_
,
const
std
::
string
&
remote_database_name_
,
const
std
::
string
&
remote_table_name_
,
...
...
dbms/src/Storages/StorageNull.cpp
浏览文件 @
2e5d61cd
...
...
@@ -26,7 +26,7 @@ void registerStorageNull(StorageFactory & factory)
"Engine "
+
args
.
engine_name
+
" doesn't support any arguments ("
+
toString
(
args
.
engine_args
.
size
())
+
" given)"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
StorageNull
::
create
(
args
.
database_name
,
args
.
table_name
,
args
.
columns
,
args
.
constraints
);
return
StorageNull
::
create
(
args
.
table_id
,
args
.
columns
,
args
.
constraints
);
});
}
...
...
dbms/src/Storages/StorageNull.h
浏览文件 @
2e5d61cd
...
...
@@ -42,8 +42,8 @@ public:
private:
protected:
StorageNull
(
String
database_name_
,
String
table_name
_
,
ColumnsDescription
columns_description_
,
ConstraintsDescription
constraints_
)
:
IStorage
(
{
database_name_
,
table_name_
}
)
StorageNull
(
const
StorageID
&
table_id
_
,
ColumnsDescription
columns_description_
,
ConstraintsDescription
constraints_
)
:
IStorage
(
table_id_
)
{
setColumns
(
std
::
move
(
columns_description_
));
setConstraints
(
std
::
move
(
constraints_
));
...
...
dbms/src/Storages/StorageReplicatedMergeTree.cpp
浏览文件 @
2e5d61cd
...
...
@@ -191,8 +191,7 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree(
const
String
&
zookeeper_path_
,
const
String
&
replica_name_
,
bool
attach
,
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
String
&
relative_data_path_
,
const
ColumnsDescription
&
columns_
,
const
IndicesDescription
&
indices_
,
...
...
@@ -207,17 +206,34 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree(
const
MergingParams
&
merging_params_
,
std
::
unique_ptr
<
MergeTreeSettings
>
settings_
,
bool
has_force_restore_data_flag
)
:
MergeTreeData
(
database_name_
,
table_name_
,
relative_data_path_
,
columns_
,
indices_
,
constraints_
,
context_
,
date_column_name
,
partition_by_ast_
,
order_by_ast_
,
primary_key_ast_
,
sample_by_ast_
,
ttl_table_ast_
,
merging_params_
,
std
::
move
(
settings_
),
true
,
attach
,
[
this
]
(
const
std
::
string
&
name
)
{
enqueuePartForCheck
(
name
);
}),
zookeeper_path
(
global_context
.
getMacros
()
->
expand
(
zookeeper_path_
,
database_name_
,
table_name_
)),
replica_name
(
global_context
.
getMacros
()
->
expand
(
replica_name_
,
database_name_
,
table_name_
)),
reader
(
*
this
),
writer
(
*
this
),
merger_mutator
(
*
this
,
global_context
.
getBackgroundPool
().
getNumberOfThreads
()),
queue
(
*
this
),
fetcher
(
*
this
),
cleanup_thread
(
*
this
),
alter_thread
(
*
this
),
part_check_thread
(
*
this
),
restarting_thread
(
*
this
)
:
MergeTreeData
(
table_id_
,
relative_data_path_
,
columns_
,
indices_
,
constraints_
,
context_
,
date_column_name
,
partition_by_ast_
,
order_by_ast_
,
primary_key_ast_
,
sample_by_ast_
,
ttl_table_ast_
,
merging_params_
,
std
::
move
(
settings_
),
true
,
/// require_part_metadata
attach
,
[
this
]
(
const
std
::
string
&
name
)
{
enqueuePartForCheck
(
name
);
})
,
zookeeper_path
(
global_context
.
getMacros
()
->
expand
(
zookeeper_path_
,
table_id_
.
database_name
,
table_id_
.
table_name
))
,
replica_name
(
global_context
.
getMacros
()
->
expand
(
replica_name_
,
table_id_
.
database_name
,
table_id_
.
table_name
))
,
reader
(
*
this
)
,
writer
(
*
this
)
,
merger_mutator
(
*
this
,
global_context
.
getBackgroundPool
().
getNumberOfThreads
())
,
queue
(
*
this
)
,
fetcher
(
*
this
)
,
cleanup_thread
(
*
this
)
,
alter_thread
(
*
this
)
,
part_check_thread
(
*
this
)
,
restarting_thread
(
*
this
)
{
if
(
!
zookeeper_path
.
empty
()
&&
zookeeper_path
.
back
()
==
'/'
)
zookeeper_path
.
resize
(
zookeeper_path
.
size
()
-
1
);
...
...
dbms/src/Storages/StorageReplicatedMergeTree.h
浏览文件 @
2e5d61cd
...
...
@@ -541,7 +541,7 @@ protected:
const
String
&
zookeeper_path_
,
const
String
&
replica_name_
,
bool
attach
,
const
St
ring
&
database_name_
,
const
String
&
name
_
,
const
St
orageID
&
table_id
_
,
const
String
&
relative_data_path_
,
const
ColumnsDescription
&
columns_
,
const
IndicesDescription
&
indices_
,
...
...
dbms/src/Storages/StorageS3.cpp
浏览文件 @
2e5d61cd
...
...
@@ -132,18 +132,18 @@ namespace
}
StorageS3
::
StorageS3
(
const
S3
::
URI
&
uri_
,
StorageS3
::
StorageS3
(
const
S3
::
URI
&
uri_
,
const
String
&
access_key_id_
,
const
String
&
secret_access_key_
,
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
String
&
format_name_
,
UInt64
min_upload_part_size_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
Context
&
context_
,
const
String
&
compression_method_
=
""
)
:
IStorage
({
database_name_
,
table_name
_
},
columns_
)
:
IStorage
({
table_id
_
},
columns_
)
,
uri
(
uri_
)
,
context_global
(
context_
)
,
format_name
(
format_name_
)
...
...
@@ -225,7 +225,7 @@ void registerStorageS3(StorageFactory & factory)
else
compression_method
=
"auto"
;
return
StorageS3
::
create
(
s3_uri
,
access_key_id
,
secret_access_key
,
args
.
database_name
,
args
.
table_name
,
format_name
,
min_upload_part_size
,
args
.
columns
,
args
.
constraints
,
args
.
context
);
return
StorageS3
::
create
(
s3_uri
,
access_key_id
,
secret_access_key
,
args
.
table_id
,
format_name
,
min_upload_part_size
,
args
.
columns
,
args
.
constraints
,
args
.
context
);
});
}
...
...
dbms/src/Storages/StorageS3.h
浏览文件 @
2e5d61cd
...
...
@@ -28,8 +28,7 @@ public:
StorageS3
(
const
S3
::
URI
&
uri
,
const
String
&
access_key_id
,
const
String
&
secret_access_key
,
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
String
&
format_name_
,
UInt64
min_upload_part_size_
,
const
ColumnsDescription
&
columns_
,
...
...
dbms/src/Storages/StorageSet.cpp
浏览文件 @
2e5d61cd
...
...
@@ -89,12 +89,11 @@ BlockOutputStreamPtr StorageSetOrJoinBase::write(const ASTPtr & /*query*/, const
StorageSetOrJoinBase
::
StorageSetOrJoinBase
(
const
String
&
relative_path_
,
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
const
Context
&
context_
)
:
IStorage
(
{
database_name_
,
table_name_
}
)
:
IStorage
(
table_id_
)
{
setColumns
(
columns_
);
setConstraints
(
constraints_
);
...
...
@@ -110,12 +109,11 @@ StorageSetOrJoinBase::StorageSetOrJoinBase(
StorageSet
::
StorageSet
(
const
String
&
relative_path_
,
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
const
Context
&
context_
)
:
StorageSetOrJoinBase
{
relative_path_
,
database_name_
,
table_name
_
,
columns_
,
constraints_
,
context_
},
:
StorageSetOrJoinBase
{
relative_path_
,
table_id
_
,
columns_
,
constraints_
,
context_
},
set
(
std
::
make_shared
<
Set
>
(
SizeLimits
(),
false
))
{
Block
header
=
getSampleBlock
();
...
...
@@ -222,7 +220,7 @@ void registerStorageSet(StorageFactory & factory)
"Engine "
+
args
.
engine_name
+
" doesn't support any arguments ("
+
toString
(
args
.
engine_args
.
size
())
+
" given)"
,
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
StorageSet
::
create
(
args
.
relative_data_path
,
args
.
database_name
,
args
.
table_name
,
args
.
columns
,
args
.
constraints
,
args
.
context
);
return
StorageSet
::
create
(
args
.
relative_data_path
,
args
.
table_id
,
args
.
columns
,
args
.
constraints
,
args
.
context
);
});
}
...
...
dbms/src/Storages/StorageSet.h
浏览文件 @
2e5d61cd
...
...
@@ -28,8 +28,7 @@ public:
protected:
StorageSetOrJoinBase
(
const
String
&
relative_path_
,
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
const
Context
&
context_
);
...
...
@@ -80,8 +79,7 @@ private:
protected:
StorageSet
(
const
String
&
relative_path_
,
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
const
Context
&
context_
);
...
...
dbms/src/Storages/StorageStripeLog.cpp
浏览文件 @
2e5d61cd
...
...
@@ -195,18 +195,18 @@ private:
StorageStripeLog
::
StorageStripeLog
(
const
std
::
string
&
relative_path_
,
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
bool
attach
,
size_t
max_compress_block_size_
,
const
Context
&
context_
)
:
IStorage
({
database_name_
,
table_name_
}),
base_path
(
context_
.
getPath
()),
path
(
base_path
+
relative_path_
),
max_compress_block_size
(
max_compress_block_size_
),
file_checker
(
path
+
"sizes.json"
),
log
(
&
Logger
::
get
(
"StorageStripeLog"
))
:
IStorage
(
table_id_
)
,
base_path
(
context_
.
getPath
())
,
path
(
base_path
+
relative_path_
)
,
max_compress_block_size
(
max_compress_block_size_
)
,
file_checker
(
path
+
"sizes.json"
)
,
log
(
&
Logger
::
get
(
"StorageStripeLog"
))
{
setColumns
(
columns_
);
setConstraints
(
constraints_
);
...
...
@@ -315,7 +315,7 @@ void registerStorageStripeLog(StorageFactory & factory)
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
StorageStripeLog
::
create
(
args
.
relative_data_path
,
args
.
database_name
,
args
.
table_name
,
args
.
columns
,
args
.
constraints
,
args
.
relative_data_path
,
args
.
table_id
,
args
.
columns
,
args
.
constraints
,
args
.
attach
,
args
.
context
.
getSettings
().
max_compress_block_size
,
args
.
context
);
});
}
...
...
dbms/src/Storages/StorageStripeLog.h
浏览文件 @
2e5d61cd
...
...
@@ -69,8 +69,7 @@ private:
protected:
StorageStripeLog
(
const
std
::
string
&
relative_path_
,
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
bool
attach
,
...
...
dbms/src/Storages/StorageTinyLog.cpp
浏览文件 @
2e5d61cd
...
...
@@ -324,17 +324,18 @@ void TinyLogBlockOutputStream::write(const Block & block)
StorageTinyLog
::
StorageTinyLog
(
const
std
::
string
&
relative_path_
,
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
bool
attach
,
size_t
max_compress_block_size_
,
const
Context
&
context_
)
:
IStorage
({
database_name_
,
table_name_
}),
base_path
(
context_
.
getPath
()),
path
(
base_path
+
relative_path_
),
max_compress_block_size
(
max_compress_block_size_
),
file_checker
(
path
+
"sizes.json"
),
log
(
&
Logger
::
get
(
"StorageTinyLog"
))
:
IStorage
(
table_id_
)
,
base_path
(
context_
.
getPath
())
,
path
(
base_path
+
relative_path_
)
,
max_compress_block_size
(
max_compress_block_size_
)
,
file_checker
(
path
+
"sizes.json"
)
,
log
(
&
Logger
::
get
(
"StorageTinyLog"
))
{
setColumns
(
columns_
);
setConstraints
(
constraints_
);
...
...
@@ -448,7 +449,7 @@ void registerStorageTinyLog(StorageFactory & factory)
ErrorCodes
::
NUMBER_OF_ARGUMENTS_DOESNT_MATCH
);
return
StorageTinyLog
::
create
(
args
.
relative_data_path
,
args
.
database_name
,
args
.
table_name
,
args
.
columns
,
args
.
constraints
,
args
.
relative_data_path
,
args
.
table_id
,
args
.
columns
,
args
.
constraints
,
args
.
attach
,
args
.
context
.
getSettings
().
max_compress_block_size
,
args
.
context
);
});
}
...
...
dbms/src/Storages/StorageTinyLog.h
浏览文件 @
2e5d61cd
...
...
@@ -72,8 +72,7 @@ private:
protected:
StorageTinyLog
(
const
std
::
string
&
relative_path_
,
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
bool
attach
,
...
...
dbms/src/Storages/StorageURL.cpp
浏览文件 @
2e5d61cd
...
...
@@ -30,13 +30,16 @@ namespace ErrorCodes
IStorageURLBase
::
IStorageURLBase
(
const
Poco
::
URI
&
uri_
,
const
Context
&
context_
,
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
String
&
format_name_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
const
String
&
compression_method_
)
:
IStorage
({
database_name_
,
table_name_
}),
uri
(
uri_
),
context_global
(
context_
),
compression_method
(
compression_method_
),
format_name
(
format_name_
)
:
IStorage
(
table_id_
)
,
uri
(
uri_
)
,
context_global
(
context_
)
,
compression_method
(
compression_method_
)
,
format_name
(
format_name_
)
{
context_global
.
getRemoteHostFilter
().
checkURL
(
uri
);
setColumns
(
columns_
);
...
...
@@ -240,7 +243,7 @@ void registerStorageURL(StorageFactory & factory)
return
StorageURL
::
create
(
uri
,
args
.
database_name
,
args
.
table_name
,
args
.
table_id
,
format_name
,
args
.
columns
,
args
.
constraints
,
args
.
context
,
compression_method
);
...
...
dbms/src/Storages/StorageURL.h
浏览文件 @
2e5d61cd
...
...
@@ -30,8 +30,7 @@ protected:
IStorageURLBase
(
const
Poco
::
URI
&
uri_
,
const
Context
&
context_
,
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
id_
,
const
String
&
format_name_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
...
...
@@ -70,14 +69,13 @@ class StorageURL : public ext::shared_ptr_helper<StorageURL>, public IStorageURL
public:
StorageURL
(
const
Poco
::
URI
&
uri_
,
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
String
&
format_name_
,
const
ColumnsDescription
&
columns_
,
const
ConstraintsDescription
&
constraints_
,
Context
&
context_
,
const
String
&
compression_method_
)
:
IStorageURLBase
(
uri_
,
context_
,
database_name_
,
table_name
_
,
format_name_
,
columns_
,
constraints_
,
compression_method_
)
:
IStorageURLBase
(
uri_
,
context_
,
table_id
_
,
format_name_
,
columns_
,
constraints_
,
compression_method_
)
{
}
...
...
dbms/src/Storages/StorageValues.cpp
浏览文件 @
2e5d61cd
...
...
@@ -7,8 +7,8 @@
namespace
DB
{
StorageValues
::
StorageValues
(
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name
_
,
const
ColumnsDescription
&
columns_
,
const
Block
&
res_block_
)
:
IStorage
(
{
database_name_
,
table_name_
}
),
res_block
(
res_block_
)
StorageValues
::
StorageValues
(
const
StorageID
&
table_id
_
,
const
ColumnsDescription
&
columns_
,
const
Block
&
res_block_
)
:
IStorage
(
table_id_
),
res_block
(
res_block_
)
{
setColumns
(
columns_
);
}
...
...
dbms/src/Storages/StorageValues.h
浏览文件 @
2e5d61cd
...
...
@@ -27,7 +27,7 @@ private:
Block
res_block
;
protected:
StorageValues
(
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name
_
,
const
ColumnsDescription
&
columns_
,
const
Block
&
res_block_
);
StorageValues
(
const
StorageID
&
table_id
_
,
const
ColumnsDescription
&
columns_
,
const
Block
&
res_block_
);
};
}
dbms/src/Storages/StorageView.cpp
浏览文件 @
2e5d61cd
...
...
@@ -27,11 +27,10 @@ namespace ErrorCodes
StorageView
::
StorageView
(
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
ASTCreateQuery
&
query
,
const
ColumnsDescription
&
columns_
)
:
IStorage
(
{
database_name_
,
table_name_
}
)
:
IStorage
(
table_id_
)
{
setColumns
(
columns_
);
...
...
@@ -106,7 +105,7 @@ void registerStorageView(StorageFactory & factory)
if
(
args
.
query
.
storage
)
throw
Exception
(
"Specifying ENGINE is not allowed for a View"
,
ErrorCodes
::
INCORRECT_QUERY
);
return
StorageView
::
create
(
args
.
database_name
,
args
.
table_name
,
args
.
query
,
args
.
columns
);
return
StorageView
::
create
(
args
.
table_id
,
args
.
query
,
args
.
columns
);
});
}
...
...
dbms/src/Storages/StorageView.h
浏览文件 @
2e5d61cd
...
...
@@ -35,8 +35,7 @@ private:
protected:
StorageView
(
const
String
&
database_name_
,
const
String
&
table_name_
,
const
StorageID
&
table_id_
,
const
ASTCreateQuery
&
query
,
const
ColumnsDescription
&
columns_
);
};
...
...
dbms/src/Storages/StorageXDBC.cpp
浏览文件 @
2e5d61cd
...
...
@@ -25,15 +25,20 @@ namespace ErrorCodes
StorageXDBC
::
StorageXDBC
(
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
const
StorageID
&
table_id_
,
const
std
::
string
&
remote_database_name_
,
const
std
::
string
&
remote_table_name_
,
const
ColumnsDescription
&
columns_
,
const
Context
&
context_
,
const
BridgeHelperPtr
bridge_helper_
)
/// Please add support for constraints as soon as StorageODBC or JDBC will support insertion.
:
IStorageURLBase
(
Poco
::
URI
(),
context_
,
database_name_
,
table_name_
,
IXDBCBridgeHelper
::
DEFAULT_FORMAT
,
columns_
,
ConstraintsDescription
{},
""
/* CompressionMethod */
)
:
IStorageURLBase
(
Poco
::
URI
(),
context_
,
table_id_
,
IXDBCBridgeHelper
::
DEFAULT_FORMAT
,
columns_
,
ConstraintsDescription
{},
""
/* CompressionMethod */
)
,
bridge_helper
(
bridge_helper_
)
,
remote_database_name
(
remote_database_name_
)
,
remote_table_name
(
remote_table_name_
)
...
...
@@ -121,7 +126,7 @@ namespace
BridgeHelperPtr
bridge_helper
=
std
::
make_shared
<
XDBCBridgeHelper
<
BridgeHelperMixin
>>
(
args
.
context
,
args
.
context
.
getSettingsRef
().
http_receive_timeout
.
value
,
engine_args
[
0
]
->
as
<
ASTLiteral
&>
().
value
.
safeGet
<
String
>
());
return
std
::
make_shared
<
StorageXDBC
>
(
args
.
database_name
,
args
.
table_name
,
return
std
::
make_shared
<
StorageXDBC
>
(
args
.
table_id
,
engine_args
[
1
]
->
as
<
ASTLiteral
&>
().
value
.
safeGet
<
String
>
(),
engine_args
[
2
]
->
as
<
ASTLiteral
&>
().
value
.
safeGet
<
String
>
(),
args
.
columns
,
...
...
dbms/src/Storages/StorageXDBC.h
浏览文件 @
2e5d61cd
...
...
@@ -24,8 +24,7 @@ public:
unsigned
num_streams
)
override
;
StorageXDBC
(
const
std
::
string
&
database_name_
,
const
std
::
string
&
table_name_
,
StorageXDBC
(
const
StorageID
&
table_id_
,
const
std
::
string
&
remote_database_name
,
const
std
::
string
&
remote_table_name
,
const
ColumnsDescription
&
columns_
,
...
...
dbms/src/Storages/tests/gtest_transform_query_for_external_database.cpp
浏览文件 @
2e5d61cd
...
...
@@ -30,7 +30,7 @@ struct State
{
registerFunctions
();
DatabasePtr
database
=
std
::
make_shared
<
DatabaseMemory
>
(
"test"
);
database
->
attachTable
(
"table"
,
StorageMemory
::
create
(
"test"
,
"table"
,
ColumnsDescription
{
columns
},
ConstraintsDescription
{}));
database
->
attachTable
(
"table"
,
StorageMemory
::
create
(
StorageID
(
"test"
,
"table"
)
,
ColumnsDescription
{
columns
},
ConstraintsDescription
{}));
context
.
makeGlobalContext
();
context
.
addDatabase
(
"test"
,
database
);
context
.
setCurrentDatabase
(
"test"
);
...
...
dbms/src/Storages/tests/storage_log.cpp
浏览文件 @
2e5d61cd
...
...
@@ -29,7 +29,7 @@ try
context
.
makeGlobalContext
();
context
.
setPath
(
"./"
);
StoragePtr
table
=
StorageLog
::
create
(
"./"
,
"test"
,
"test"
,
ColumnsDescription
{
names_and_types
},
ConstraintsDescription
{},
1048576
,
context
);
StoragePtr
table
=
StorageLog
::
create
(
"./"
,
StorageID
(
"test"
,
"test"
)
,
ColumnsDescription
{
names_and_types
},
ConstraintsDescription
{},
1048576
,
context
);
table
->
startup
();
/// write into it
...
...
dbms/src/TableFunctions/ITableFunctionXDBC.cpp
浏览文件 @
2e5d61cd
...
...
@@ -81,7 +81,7 @@ StoragePtr ITableFunctionXDBC::executeImpl(const ASTPtr & ast_function, const Co
readStringBinary
(
columns_info
,
buf
);
NamesAndTypesList
columns
=
NamesAndTypesList
::
parse
(
columns_info
);
auto
result
=
std
::
make_shared
<
StorageXDBC
>
(
getDatabaseName
(),
table_name
,
schema_name
,
remote_table_name
,
ColumnsDescription
{
columns
},
context
,
helper
);
auto
result
=
std
::
make_shared
<
StorageXDBC
>
(
StorageID
(
getDatabaseName
(),
table_name
)
,
schema_name
,
remote_table_name
,
ColumnsDescription
{
columns
},
context
,
helper
);
if
(
!
result
)
throw
Exception
(
"Failed to instantiate storage from table function "
+
getName
(),
ErrorCodes
::
UNKNOWN_EXCEPTION
);
...
...
dbms/src/TableFunctions/TableFunctionFile.cpp
浏览文件 @
2e5d61cd
...
...
@@ -9,7 +9,7 @@ namespace DB
StoragePtr
TableFunctionFile
::
getStorage
(
const
String
&
source
,
const
String
&
format
,
const
ColumnsDescription
&
columns
,
Context
&
global_context
,
const
std
::
string
&
table_name
,
const
std
::
string
&
compression_method
)
const
{
StorageFile
::
CommonArguments
args
{
getDatabaseName
(),
table_name
,
format
,
compression_method
,
columns
,
ConstraintsDescription
{},
global_context
};
StorageFile
::
CommonArguments
args
{
StorageID
(
getDatabaseName
(),
table_name
)
,
format
,
compression_method
,
columns
,
ConstraintsDescription
{},
global_context
};
return
StorageFile
::
create
(
source
,
global_context
.
getUserFilesPath
(),
args
);
}
...
...
dbms/src/TableFunctions/TableFunctionHDFS.cpp
浏览文件 @
2e5d61cd
...
...
@@ -13,8 +13,7 @@ StoragePtr TableFunctionHDFS::getStorage(
const
String
&
source
,
const
String
&
format
,
const
ColumnsDescription
&
columns
,
Context
&
global_context
,
const
std
::
string
&
table_name
,
const
String
&
compression_method
)
const
{
return
StorageHDFS
::
create
(
source
,
getDatabaseName
(),
table_name
,
StorageID
(
getDatabaseName
(),
table_name
),
format
,
columns
,
ConstraintsDescription
{},
...
...
dbms/src/TableFunctions/TableFunctionMerge.cpp
浏览文件 @
2e5d61cd
...
...
@@ -68,8 +68,7 @@ StoragePtr TableFunctionMerge::executeImpl(const ASTPtr & ast_function, const Co
String
table_name_regexp
=
args
[
1
]
->
as
<
ASTLiteral
&>
().
value
.
safeGet
<
String
>
();
auto
res
=
StorageMerge
::
create
(
getDatabaseName
(),
table_name
,
StorageID
(
getDatabaseName
(),
table_name
),
ColumnsDescription
{
chooseColumns
(
source_database
,
table_name_regexp
,
context
)},
source_database
,
table_name_regexp
,
...
...
dbms/src/TableFunctions/TableFunctionMySQL.cpp
浏览文件 @
2e5d61cd
...
...
@@ -115,8 +115,7 @@ StoragePtr TableFunctionMySQL::executeImpl(const ASTPtr & ast_function, const Co
throw
Exception
(
"MySQL table "
+
backQuoteIfNeed
(
remote_database_name
)
+
"."
+
backQuoteIfNeed
(
remote_table_name
)
+
" doesn't exist."
,
ErrorCodes
::
UNKNOWN_TABLE
);
auto
res
=
StorageMySQL
::
create
(
getDatabaseName
(),
table_name
,
StorageID
(
getDatabaseName
(),
table_name
),
std
::
move
(
pool
),
remote_database_name
,
remote_table_name
,
...
...
dbms/src/TableFunctions/TableFunctionRemote.cpp
浏览文件 @
2e5d61cd
...
...
@@ -177,13 +177,13 @@ StoragePtr TableFunctionRemote::executeImpl(const ASTPtr & ast_function, const C
StoragePtr
res
=
remote_table_function_ptr
?
StorageDistributed
::
createWithOwnCluster
(
table_name
,
StorageID
(
""
,
table_name
)
,
structure_remote_table
,
remote_table_function_ptr
,
cluster
,
context
)
:
StorageDistributed
::
createWithOwnCluster
(
table_name
,
StorageID
(
""
,
table_name
)
,
structure_remote_table
,
remote_database
,
remote_table
,
...
...
dbms/src/TableFunctions/TableFunctionS3.cpp
浏览文件 @
2e5d61cd
...
...
@@ -85,7 +85,7 @@ StoragePtr TableFunctionS3::getStorage(
S3
::
URI
s3_uri
(
uri
);
UInt64
min_upload_part_size
=
global_context
.
getSettingsRef
().
s3_min_upload_part_size
;
return
StorageS3
::
create
(
s3_uri
,
access_key_id
,
secret_access_key
,
getDatabaseName
(),
table_name
,
format
,
min_upload_part_size
,
columns
,
ConstraintsDescription
{},
global_context
,
compression_method
);
return
StorageS3
::
create
(
s3_uri
,
access_key_id
,
secret_access_key
,
StorageID
(
getDatabaseName
(),
table_name
)
,
format
,
min_upload_part_size
,
columns
,
ConstraintsDescription
{},
global_context
,
compression_method
);
}
void
registerTableFunctionS3
(
TableFunctionFactory
&
factory
)
...
...
dbms/src/TableFunctions/TableFunctionURL.cpp
浏览文件 @
2e5d61cd
...
...
@@ -12,7 +12,7 @@ StoragePtr TableFunctionURL::getStorage(
const
String
&
source
,
const
String
&
format
,
const
ColumnsDescription
&
columns
,
Context
&
global_context
,
const
std
::
string
&
table_name
,
const
String
&
compression_method
)
const
{
Poco
::
URI
uri
(
source
);
return
StorageURL
::
create
(
uri
,
getDatabaseName
(),
table_name
,
format
,
columns
,
ConstraintsDescription
{},
global_context
,
compression_method
);
return
StorageURL
::
create
(
uri
,
StorageID
(
getDatabaseName
(),
table_name
)
,
format
,
columns
,
ConstraintsDescription
{},
global_context
,
compression_method
);
}
void
registerTableFunctionURL
(
TableFunctionFactory
&
factory
)
...
...
dbms/src/TableFunctions/TableFunctionValues.cpp
浏览文件 @
2e5d61cd
...
...
@@ -88,7 +88,7 @@ StoragePtr TableFunctionValues::executeImpl(const ASTPtr & ast_function, const C
Block
res_block
=
sample_block
.
cloneWithColumns
(
std
::
move
(
res_columns
));
auto
res
=
StorageValues
::
create
(
getDatabaseName
(),
table_name
,
columns
,
res_block
);
auto
res
=
StorageValues
::
create
(
StorageID
(
getDatabaseName
(),
table_name
)
,
columns
,
res_block
);
res
->
startup
();
return
res
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录