From 544bfd105be64860bb3d59187884a8b5af4baf4e Mon Sep 17 00:00:00 2001 From: Alexander Burmak Date: Wed, 25 Dec 2019 11:24:13 +0300 Subject: [PATCH] Corrected naming based on review feedback --- dbms/src/Storages/StorageLog.cpp | 26 +++++++++++++------------- dbms/src/Storages/StorageLog.h | 22 +++++++++++----------- dbms/src/Storages/StorageStripeLog.cpp | 10 +++++----- dbms/src/Storages/StorageStripeLog.h | 4 ++-- dbms/src/Storages/StorageTinyLog.cpp | 12 ++++++------ dbms/src/Storages/StorageTinyLog.h | 4 ++-- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/dbms/src/Storages/StorageLog.cpp b/dbms/src/Storages/StorageLog.cpp index 5531ea14124..cff5fd31534 100644 --- a/dbms/src/Storages/StorageLog.cpp +++ b/dbms/src/Storages/StorageLog.cpp @@ -113,7 +113,7 @@ public: explicit LogBlockOutputStream(StorageLog & storage_) : storage(storage_), lock(storage.rwlock), - marks_stream(fullPath(storage.disk, storage.marks_file), 4096, O_APPEND | O_CREAT | O_WRONLY) + marks_stream(fullPath(storage.disk, storage.marks_file_path), 4096, O_APPEND | O_CREAT | O_WRONLY) { } @@ -248,7 +248,7 @@ void LogBlockInputStream::readData(const String & name, const IDataType & type, if (!stream_for_prefix && mark_number) offset = file_it->second.marks[mark_number].offset; - auto & data_file_path = file_it->second.data_file; + auto & data_file_path = file_it->second.data_file_path; auto it = streams.try_emplace(stream_name, storage.disk, data_file_path, offset, max_read_buffer_size).first; return &it->second.compressed; }; @@ -311,8 +311,8 @@ void LogBlockOutputStream::writeSuffix() Strings column_files; for (const auto & name_stream : streams) - column_files.push_back(storage.files[name_stream.first].data_file); - column_files.push_back(storage.marks_file); + column_files.push_back(storage.files[name_stream.first].data_file_path); + column_files.push_back(storage.marks_file_path); storage.file_checker.update(column_files.begin(), column_files.end()); @@ -353,7 +353,7 @@ void LogBlockOutputStream::writeData(const String & name, const IDataType & type streams.try_emplace( stream_name, storage.disk, - storage.files[stream_name].data_file, + storage.files[stream_name].data_file_path, columns.getCodecOrDefault(name), storage.max_compress_block_size); }, settings.path); @@ -433,7 +433,7 @@ StorageLog::StorageLog( for (const auto & column : getColumns().getAllPhysical()) addFiles(column.name, *column.type); - marks_file = table_path + DBMS_STORAGE_LOG_MARKS_FILE_NAME; + marks_file_path = table_path + DBMS_STORAGE_LOG_MARKS_FILE_NAME; } @@ -451,7 +451,7 @@ void StorageLog::addFiles(const String & column_name, const IDataType & type) { ColumnData & column_data = files[stream_name]; column_data.column_index = file_count; - column_data.data_file = table_path + stream_name + DBMS_STORAGE_LOG_DATA_FILE_EXTENSION; + column_data.data_file_path = table_path + stream_name + DBMS_STORAGE_LOG_DATA_FILE_EXTENSION; column_names_by_idx.push_back(stream_name); ++file_count; @@ -476,9 +476,9 @@ void StorageLog::loadMarks() for (Files::iterator it = files.begin(); it != files.end(); ++it) files_by_index[it->second.column_index] = it; - if (disk->exists(marks_file)) + if (disk->exists(marks_file_path)) { - size_t file_size = disk->getFileSize(marks_file); + size_t file_size = disk->getFileSize(marks_file_path); if (file_size % (file_count * sizeof(Mark)) != 0) throw Exception("Size of marks file is inconsistent", ErrorCodes::SIZES_OF_MARKS_FILES_ARE_INCONSISTENT); @@ -487,7 +487,7 @@ void StorageLog::loadMarks() for (auto & file : files_by_index) file->second.marks.reserve(marks_count); - std::unique_ptr marks_rb = disk->read(marks_file, 32768); + std::unique_ptr marks_rb = disk->read(marks_file_path, 32768); while (!marks_rb->eof()) { for (size_t i = 0; i < files_by_index.size(); ++i) @@ -518,9 +518,9 @@ void StorageLog::rename(const String & /*new_path_to_db*/, const String & new_da file_checker.setPath(table_path + "sizes.json"); for (auto & file : files) - file.second.data_file = table_path + Poco::Path(file.second.data_file).getFileName(); + file.second.data_file_path = table_path + Poco::Path(file.second.data_file_path).getFileName(); - marks_file = table_path + DBMS_STORAGE_LOG_MARKS_FILE_NAME; + marks_file_path = table_path + DBMS_STORAGE_LOG_MARKS_FILE_NAME; } void StorageLog::truncate(const ASTPtr &, const Context &, TableStructureWriteLockHolder &) @@ -537,7 +537,7 @@ void StorageLog::truncate(const ASTPtr &, const Context &, TableStructureWriteLo addFiles(column.name, *column.type); file_checker = FileChecker{disk, table_path + "sizes.json"}; - marks_file = table_path + DBMS_STORAGE_LOG_MARKS_FILE_NAME; + marks_file_path = table_path + DBMS_STORAGE_LOG_MARKS_FILE_NAME; } diff --git a/dbms/src/Storages/StorageLog.h b/dbms/src/Storages/StorageLog.h index 5d5815eda8b..e2e1785e712 100644 --- a/dbms/src/Storages/StorageLog.h +++ b/dbms/src/Storages/StorageLog.h @@ -62,13 +62,6 @@ protected: size_t max_compress_block_size_); private: - DiskPtr disk; - String database_name; - String table_name; - String table_path; - - mutable std::shared_mutex rwlock; - /** Offsets to some row number in a file for column in table. * They are needed so that you can read the data in several threads. */ @@ -86,16 +79,23 @@ private: /// Does not necessarily match the column number among the columns of the table: columns with lengths of arrays are also numbered here. size_t column_index; - String data_file; + String data_file_path; Marks marks; }; - using Files = std::map; + using Files = std::map; /// file name -> column data - Files files; /// name -> data + DiskPtr disk; + String database_name; + String table_name; + String table_path; + + mutable std::shared_mutex rwlock; + + Files files; Names column_names_by_idx; /// column_index -> name - String marks_file; + String marks_file_path; /// The order of adding files should not change: it corresponds to the order of the columns in the marks file. void addFiles(const String & column_name, const IDataType & type); diff --git a/dbms/src/Storages/StorageStripeLog.cpp b/dbms/src/Storages/StorageStripeLog.cpp index 92b76afd182..873fd14b827 100644 --- a/dbms/src/Storages/StorageStripeLog.cpp +++ b/dbms/src/Storages/StorageStripeLog.cpp @@ -117,10 +117,10 @@ private: { started = true; - String data_file = storage.table_path + "data.bin"; - size_t buffer_size = std::min(max_read_buffer_size, storage.disk->getFileSize(data_file)); + String data_file_path = storage.table_path + "data.bin"; + size_t buffer_size = std::min(max_read_buffer_size, storage.disk->getFileSize(data_file_path)); - data_in.emplace(fullPath(storage.disk, data_file), 0, 0, buffer_size); + data_in.emplace(fullPath(storage.disk, data_file_path), 0, 0, buffer_size); block_in.emplace(*data_in, 0, index_begin, index_end); } } @@ -202,8 +202,8 @@ StorageStripeLog::StorageStripeLog( const ConstraintsDescription & constraints_, bool attach, size_t max_compress_block_size_) - : disk(disk_), database_name(database_name_), table_name(table_name_), - table_path("data/" + escapeForFileName(database_name_) + '/' + escapeForFileName(table_name_) + '/'), + : disk(std::move(disk_)), database_name(database_name_), table_name(table_name_), + table_path("data/" + escapeForFileName(database_name_) + '/' + escapeForFileName(table_name_) + '/'), max_compress_block_size(max_compress_block_size_), file_checker(disk, table_path + "sizes.json"), log(&Logger::get("StorageStripeLog")) diff --git a/dbms/src/Storages/StorageStripeLog.h b/dbms/src/Storages/StorageStripeLog.h index 3d95f0f1f42..28f25c1c3c6 100644 --- a/dbms/src/Storages/StorageStripeLog.h +++ b/dbms/src/Storages/StorageStripeLog.h @@ -62,9 +62,9 @@ protected: private: struct ColumnData { - String data_file; + String data_file_path; }; - using Files = std::map; + using Files = std::map; /// file name -> column data DiskPtr disk; String database_name; diff --git a/dbms/src/Storages/StorageTinyLog.cpp b/dbms/src/Storages/StorageTinyLog.cpp index 20084b74d61..3b0053a9af7 100644 --- a/dbms/src/Storages/StorageTinyLog.cpp +++ b/dbms/src/Storages/StorageTinyLog.cpp @@ -217,7 +217,7 @@ void TinyLogBlockInputStream::readData(const String & name, const IDataType & ty String stream_name = IDataType::getFileNameForStream(name, path); if (!streams.count(stream_name)) - streams[stream_name] = std::make_unique(storage.disk, storage.files[stream_name].data_file, max_read_buffer_size); + streams[stream_name] = std::make_unique(storage.disk, storage.files[stream_name].data_file_path, max_read_buffer_size); return &streams[stream_name]->compressed; }; @@ -242,7 +242,7 @@ IDataType::OutputStreamGetter TinyLogBlockOutputStream::createStreamGetter(const const auto & columns = storage.getColumns(); if (!streams.count(stream_name)) streams[stream_name] = std::make_unique(storage.disk, - storage.files[stream_name].data_file, + storage.files[stream_name].data_file_path, columns.getCodecOrDefault(name), storage.max_compress_block_size); @@ -291,7 +291,7 @@ void TinyLogBlockOutputStream::writeSuffix() Strings column_files; for (auto & pair : streams) - column_files.push_back(storage.files[pair.first].data_file); + column_files.push_back(storage.files[pair.first].data_file_path); storage.file_checker.update(column_files.begin(), column_files.end()); @@ -322,7 +322,7 @@ StorageTinyLog::StorageTinyLog( const ConstraintsDescription & constraints_, bool attach, size_t max_compress_block_size_) - : disk(disk_), database_name(database_name_), table_name(table_name_), + : disk(std::move(disk_)), database_name(database_name_), table_name(table_name_), table_path("data/" + escapeForFileName(database_name_) + '/' + escapeForFileName(table_name_) + '/'), max_compress_block_size(max_compress_block_size_), file_checker(disk, table_path + "sizes.json"), @@ -355,7 +355,7 @@ void StorageTinyLog::addFiles(const String & column_name, const IDataType & type { ColumnData column_data; files.insert(std::make_pair(stream_name, column_data)); - files[stream_name].data_file = table_path + stream_name + DBMS_STORAGE_LOG_DATA_FILE_EXTENSION; + files[stream_name].data_file_path = table_path + stream_name + DBMS_STORAGE_LOG_DATA_FILE_EXTENSION; } }; @@ -378,7 +378,7 @@ void StorageTinyLog::rename(const String & /*new_path_to_db*/, const String & ne file_checker.setPath(table_path + "sizes.json"); for (auto & file : files) - file.second.data_file = table_path + Poco::Path(file.second.data_file).getFileName(); + file.second.data_file_path = table_path + Poco::Path(file.second.data_file_path).getFileName(); } diff --git a/dbms/src/Storages/StorageTinyLog.h b/dbms/src/Storages/StorageTinyLog.h index dbfe2884d64..5e6a6f70786 100644 --- a/dbms/src/Storages/StorageTinyLog.h +++ b/dbms/src/Storages/StorageTinyLog.h @@ -61,9 +61,9 @@ protected: private: struct ColumnData { - String data_file; + String data_file_path; }; - using Files = std::map; + using Files = std::map; /// file name -> column data DiskPtr disk; String database_name;