Better naming

This commit is contained in:
alesapin 2020-06-19 18:39:41 +03:00
parent a2e7e9f232
commit c9fa5d2ec3
32 changed files with 114 additions and 115 deletions

View File

@ -80,8 +80,7 @@ class IStorage : public std::enable_shared_from_this<IStorage>, public TypePromo
{
public:
IStorage() = delete;
/// Storage fields should be initialized in separate methods like setColumns
/// or setTableTTLs.
/// Storage metadata can be set separately in setInMemoryMetadata method
explicit IStorage(StorageID storage_id_) : storage_id(std::move(storage_id_)), metadata(std::make_unique<StorageInMemoryMetadata>()) {} //-V730
virtual ~IStorage() = default;

View File

@ -137,9 +137,9 @@ StorageKafka::StorageKafka(
, intermediate_commit(kafka_settings->kafka_commit_every_batch.value)
, settings_adjustments(createSettingsAdjustments())
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
setInMemoryMetadata(storage_metadata);
task = global_context.getSchedulePool().createTask(log->name(), [this]{ threadFunc(); });
task->deactivate();

View File

@ -255,9 +255,9 @@ StorageLiveView::StorageLiveView(
live_view_context = std::make_unique<Context>(global_context);
live_view_context->makeQueryContext();
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
setInMemoryMetadata(storage_metadata);
if (!query.select)
throw Exception("SELECT query is not specified for " + getName(), ErrorCodes::INCORRECT_QUERY);

View File

@ -77,10 +77,10 @@ StorageBuffer::StorageBuffer(
, log(&Poco::Logger::get("StorageBuffer (" + table_id_.getFullTableName() + ")"))
, bg_pool(global_context.getBufferFlushSchedulePool())
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
metadata_.setConstraints(constraints_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
storage_metadata.setConstraints(constraints_);
setInMemoryMetadata(storage_metadata);
}

View File

@ -100,9 +100,9 @@ StorageDictionary::StorageDictionary(
: IStorage(table_id_)
, dictionary_name(dictionary_name_)
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(ColumnsDescription{getNamesAndTypes(dictionary_structure_)});
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(ColumnsDescription{getNamesAndTypes(dictionary_structure_)});
setInMemoryMetadata(storage_metadata);
}

View File

@ -290,14 +290,14 @@ StorageDistributed::StorageDistributed(
, storage_policy(storage_policy_)
, relative_data_path(relative_data_path_)
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
metadata_.setConstraints(constraints_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
storage_metadata.setConstraints(constraints_);
setInMemoryMetadata(storage_metadata);
if (sharding_key_)
{
sharding_key_expr = buildShardingKeyExpression(sharding_key_, *global_context, metadata_.getColumns().getAllPhysical(), false);
sharding_key_expr = buildShardingKeyExpression(sharding_key_, *global_context, storage_metadata.getColumns().getAllPhysical(), false);
sharding_key_column_name = sharding_key_->getColumnName();
}

View File

@ -167,9 +167,9 @@ StorageFile::StorageFile(const std::string & table_path_, const std::string & us
Block header = StorageDistributedDirectoryMonitor::createStreamFromFile(first_path)->getHeader();
StorageInMemoryMetadata metadata_;
metadata_.setColumns(ColumnsDescription(header.getNamesAndTypesList()));
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(ColumnsDescription(header.getNamesAndTypesList()));
setInMemoryMetadata(storage_metadata);
}
}
}
@ -191,12 +191,12 @@ StorageFile::StorageFile(CommonArguments args)
, compression_method(args.compression_method)
, base_path(args.context.getPath())
{
StorageInMemoryMetadata metadata_;
StorageInMemoryMetadata storage_metadata;
if (args.format_name != "Distributed")
metadata_.setColumns(args.columns);
storage_metadata.setColumns(args.columns);
metadata_.setConstraints(args.constraints);
setInMemoryMetadata(metadata_);
storage_metadata.setConstraints(args.constraints);
setInMemoryMetadata(storage_metadata);
}
class StorageFileSource : public SourceWithProgress

View File

@ -388,9 +388,9 @@ StorageGenerateRandom::StorageGenerateRandom(const StorageID & table_id_, const
: IStorage(table_id_), max_array_length(max_array_length_), max_string_length(max_string_length_)
{
random_seed = random_seed_ ? sipHash64(*random_seed_) : randomSeed();
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
setInMemoryMetadata(storage_metadata);
}

View File

@ -50,10 +50,10 @@ StorageHDFS::StorageHDFS(const String & uri_,
{
context.getRemoteHostFilter().checkURL(Poco::URI(uri));
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
metadata_.setConstraints(constraints_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
storage_metadata.setConstraints(constraints_);
setInMemoryMetadata(storage_metadata);
}
namespace

View File

@ -21,9 +21,9 @@ namespace ErrorCodes
StorageInput::StorageInput(const StorageID & table_id, const ColumnsDescription & columns_)
: IStorage(table_id)
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
setInMemoryMetadata(storage_metadata);
}

View File

@ -434,10 +434,10 @@ StorageLog::StorageLog(
, max_compress_block_size(max_compress_block_size_)
, file_checker(disk, table_path + "sizes.json")
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
metadata_.setConstraints(constraints_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
storage_metadata.setConstraints(constraints_);
setInMemoryMetadata(storage_metadata);
if (relative_path_.empty())
throw Exception("Storage " + getName() + " requires data path", ErrorCodes::INCORRECT_FILE_NAME);
@ -445,7 +445,7 @@ StorageLog::StorageLog(
/// create directories if they do not exist
disk->createDirectories(table_path);
for (const auto & column : metadata_.getColumns().getAllPhysical())
for (const auto & column : storage_metadata.getColumns().getAllPhysical())
addFiles(column.name, *column.type);
marks_file_path = table_path + DBMS_STORAGE_LOG_MARKS_FILE_NAME;

View File

@ -50,8 +50,8 @@ StorageMaterializedView::StorageMaterializedView(
bool attach_)
: IStorage(table_id_), global_context(local_context.getGlobalContext())
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
if (!query.select)
throw Exception("SELECT query is not specified for " + getName(), ErrorCodes::INCORRECT_QUERY);
@ -67,8 +67,8 @@ StorageMaterializedView::StorageMaterializedView(
throw Exception("UNION is not supported for MATERIALIZED VIEW", ErrorCodes::QUERY_IS_NOT_SUPPORTED_IN_MATERIALIZED_VIEW);
auto select = SelectQueryDescription::getSelectQueryFromASTForMatView(query.select->clone(), local_context);
metadata_.setSelectQuery(select);
setInMemoryMetadata(metadata_);
storage_metadata.setSelectQuery(select);
setInMemoryMetadata(storage_metadata);
if (!has_inner_table)
target_table_id = query.to_table_id;

View File

@ -94,10 +94,10 @@ private:
StorageMemory::StorageMemory(const StorageID & table_id_, ColumnsDescription columns_description_, ConstraintsDescription constraints_)
: IStorage(table_id_)
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(std::move(columns_description_));
metadata_.setConstraints(std::move(constraints_));
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(std::move(columns_description_));
storage_metadata.setConstraints(std::move(constraints_));
setInMemoryMetadata(storage_metadata);
}

View File

@ -51,9 +51,9 @@ StorageMerge::StorageMerge(
, table_name_regexp(table_name_regexp_)
, global_context(context_)
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
setInMemoryMetadata(storage_metadata);
}
template <typename F>

View File

@ -56,10 +56,10 @@ StorageMySQL::StorageMySQL(
, pool(std::move(pool_))
, global_context(context_)
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
metadata_.setConstraints(constraints_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
storage_metadata.setConstraints(constraints_);
setInMemoryMetadata(storage_metadata);
}

View File

@ -206,10 +206,10 @@ StorageS3::StorageS3(
, compression_method(compression_method_)
{
context_global.getRemoteHostFilter().checkURL(uri_.uri);
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
metadata_.setConstraints(constraints_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
storage_metadata.setConstraints(constraints_);
setInMemoryMetadata(storage_metadata);
auto settings = context_.getStorageS3Settings().getSettings(uri.endpoint);
Aws::Auth::AWSCredentials credentials(access_key_id_, secret_access_key_);

View File

@ -105,10 +105,10 @@ StorageSetOrJoinBase::StorageSetOrJoinBase(
const Context & context_)
: IStorage(table_id_)
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
metadata_.setConstraints(constraints_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
storage_metadata.setConstraints(constraints_);
setInMemoryMetadata(storage_metadata);
if (relative_path_.empty())

View File

@ -237,10 +237,10 @@ StorageStripeLog::StorageStripeLog(
, file_checker(disk, table_path + "sizes.json")
, log(&Poco::Logger::get("StorageStripeLog"))
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
metadata_.setConstraints(constraints_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
storage_metadata.setConstraints(constraints_);
setInMemoryMetadata(storage_metadata);
if (relative_path_.empty())
throw Exception("Storage " + getName() + " requires data path", ErrorCodes::INCORRECT_FILE_NAME);

View File

@ -339,10 +339,10 @@ StorageTinyLog::StorageTinyLog(
, file_checker(disk, table_path + "sizes.json")
, log(&Poco::Logger::get("StorageTinyLog"))
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
metadata_.setConstraints(constraints_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
storage_metadata.setConstraints(constraints_);
setInMemoryMetadata(storage_metadata);
if (relative_path_.empty())
throw Exception("Storage " + getName() + " requires data path", ErrorCodes::INCORRECT_FILE_NAME);
@ -353,7 +353,7 @@ StorageTinyLog::StorageTinyLog(
disk->createDirectories(table_path);
}
for (const auto & col : metadata_.getColumns().getAllPhysical())
for (const auto & col : storage_metadata.getColumns().getAllPhysical())
addFiles(col.name, *col.type);
}

View File

@ -44,10 +44,10 @@ IStorageURLBase::IStorageURLBase(
{
context_global.getRemoteHostFilter().checkURL(uri);
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
metadata_.setConstraints(constraints_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
storage_metadata.setConstraints(constraints_);
setInMemoryMetadata(storage_metadata);
}
namespace

View File

@ -16,9 +16,9 @@ StorageValues::StorageValues(
const NamesAndTypesList & virtuals_)
: IStorage(table_id_), res_block(res_block_), virtuals(virtuals_)
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
setInMemoryMetadata(storage_metadata);
}
Pipes StorageValues::read(

View File

@ -38,8 +38,8 @@ StorageView::StorageView(
const ColumnsDescription & columns_)
: IStorage(table_id_)
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(columns_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
if (!query.select)
throw Exception("SELECT query is not specified for " + getName(), ErrorCodes::INCORRECT_QUERY);
@ -47,8 +47,8 @@ StorageView::StorageView(
SelectQueryDescription description;
description.inner_query = query.select->ptr();
metadata_.setSelectQuery(description);
setInMemoryMetadata(metadata_);
storage_metadata.setSelectQuery(description);
setInMemoryMetadata(storage_metadata);
}

View File

@ -26,8 +26,8 @@ namespace ErrorCodes
StorageSystemColumns::StorageSystemColumns(const std::string & name_)
: IStorage({"system", name_})
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(ColumnsDescription(
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(ColumnsDescription(
{
{ "database", std::make_shared<DataTypeString>() },
{ "table", std::make_shared<DataTypeString>() },
@ -46,7 +46,7 @@ StorageSystemColumns::StorageSystemColumns(const std::string & name_)
{ "is_in_sampling_key", std::make_shared<DataTypeUInt8>() },
{ "compression_codec", std::make_shared<DataTypeString>() },
}));
setInMemoryMetadata(metadata_);
setInMemoryMetadata(storage_metadata);
}

View File

@ -30,8 +30,8 @@ protected:
explicit StorageSystemDetachedParts()
: IStorage({"system", "detached_parts"})
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(ColumnsDescription{{
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(ColumnsDescription{{
{"database", std::make_shared<DataTypeString>()},
{"table", std::make_shared<DataTypeString>()},
{"partition_id", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeString>())},
@ -42,7 +42,7 @@ protected:
{"max_block_number", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeInt64>())},
{"level", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt32>())}
}});
setInMemoryMetadata(metadata_);
setInMemoryMetadata(storage_metadata);
}
Pipes read(

View File

@ -14,8 +14,8 @@ namespace ErrorCodes
StorageSystemDisks::StorageSystemDisks(const std::string & name_)
: IStorage({"system", name_})
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(ColumnsDescription(
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(ColumnsDescription(
{
{"name", std::make_shared<DataTypeString>()},
{"path", std::make_shared<DataTypeString>()},
@ -23,7 +23,7 @@ StorageSystemDisks::StorageSystemDisks(const std::string & name_)
{"total_space", std::make_shared<DataTypeUInt64>()},
{"keep_free_space", std::make_shared<DataTypeUInt64>()},
}));
setInMemoryMetadata(metadata_);
setInMemoryMetadata(storage_metadata);
}
Pipes StorageSystemDisks::read(

View File

@ -118,9 +118,9 @@ private:
StorageSystemNumbers::StorageSystemNumbers(const StorageID & table_id, bool multithreaded_, std::optional<UInt64> limit_, UInt64 offset_, bool even_distribution_)
: IStorage(table_id), multithreaded(multithreaded_), even_distribution(even_distribution_), limit(limit_), offset(offset_)
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(ColumnsDescription({{"number", std::make_shared<DataTypeUInt64>()}}));
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(ColumnsDescription({{"number", std::make_shared<DataTypeUInt64>()}}));
setInMemoryMetadata(storage_metadata);
}
Pipes StorageSystemNumbers::read(

View File

@ -14,9 +14,9 @@ namespace DB
StorageSystemOne::StorageSystemOne(const std::string & name_)
: IStorage({"system", name_})
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(ColumnsDescription({{"dummy", std::make_shared<DataTypeUInt8>()}}));
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(ColumnsDescription({{"dummy", std::make_shared<DataTypeUInt8>()}}));
setInMemoryMetadata(storage_metadata);
}

View File

@ -278,9 +278,9 @@ StorageSystemPartsBase::StorageSystemPartsBase(std::string name_, NamesAndTypesL
add_alias("bytes", "bytes_on_disk");
add_alias("marks_size", "marks_bytes");
StorageInMemoryMetadata metadata_;
metadata_.setColumns(tmp_columns);
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(tmp_columns);
setInMemoryMetadata(storage_metadata);
}
NamesAndTypesList StorageSystemPartsBase::getVirtuals() const

View File

@ -19,8 +19,8 @@ namespace DB
StorageSystemReplicas::StorageSystemReplicas(const std::string & name_)
: IStorage({"system", name_})
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(ColumnsDescription({
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(ColumnsDescription({
{ "database", std::make_shared<DataTypeString>() },
{ "table", std::make_shared<DataTypeString>() },
{ "engine", std::make_shared<DataTypeString>() },
@ -53,7 +53,7 @@ StorageSystemReplicas::StorageSystemReplicas(const std::string & name_)
{ "active_replicas", std::make_shared<DataTypeUInt8>() },
{ "zookeeper_exception", std::make_shared<DataTypeString>() },
}));
setInMemoryMetadata(metadata_);
setInMemoryMetadata(storage_metadata);
}

View File

@ -17,8 +17,8 @@ namespace ErrorCodes
StorageSystemStoragePolicies::StorageSystemStoragePolicies(const std::string & name_)
: IStorage({"system", name_})
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(
ColumnsDescription({
{"policy_name", std::make_shared<DataTypeString>()},
{"volume_name", std::make_shared<DataTypeString>()},
@ -27,7 +27,7 @@ StorageSystemStoragePolicies::StorageSystemStoragePolicies(const std::string & n
{"max_data_part_size", std::make_shared<DataTypeUInt64>()},
{"move_factor", std::make_shared<DataTypeFloat32>()}
}));
setInMemoryMetadata(metadata_);
setInMemoryMetadata(storage_metadata);
}
Pipes StorageSystemStoragePolicies::read(

View File

@ -33,8 +33,8 @@ namespace ErrorCodes
StorageSystemTables::StorageSystemTables(const std::string & name_)
: IStorage({"system", name_})
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(ColumnsDescription(
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(ColumnsDescription(
{
{"database", std::make_shared<DataTypeString>()},
{"name", std::make_shared<DataTypeString>()},
@ -56,7 +56,7 @@ StorageSystemTables::StorageSystemTables(const std::string & name_)
{"total_rows", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt64>())},
{"total_bytes", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt64>())},
}));
setInMemoryMetadata(metadata_);
setInMemoryMetadata(storage_metadata);
}

View File

@ -84,9 +84,9 @@ private:
StorageSystemZeros::StorageSystemZeros(const StorageID & table_id_, bool multithreaded_, std::optional<UInt64> limit_)
: IStorage(table_id_), multithreaded(multithreaded_), limit(limit_)
{
StorageInMemoryMetadata metadata_;
metadata_.setColumns(ColumnsDescription({{"zero", std::make_shared<DataTypeUInt8>()}}));
setInMemoryMetadata(metadata_);
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(ColumnsDescription({{"zero", std::make_shared<DataTypeUInt8>()}}));
setInMemoryMetadata(storage_metadata);
}