chaoyli closed pull request #446: Rename OlapStore to DataDir URL: https://github.com/apache/incubator-doris/pull/446
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/be/src/agent/cgroups_mgr.cpp b/be/src/agent/cgroups_mgr.cpp index 4d81fcdc..35639464 100644 --- a/be/src/agent/cgroups_mgr.cpp +++ b/be/src/agent/cgroups_mgr.cpp @@ -27,7 +27,7 @@ #include <sys/vfs.h> #include "boost/filesystem.hpp" #include "common/logging.h" -#include "olap/store.h" +#include "olap/data_dir.h" #include "olap/storage_engine.h" #include "runtime/exec_env.h" #include "runtime/load_path_mgr.h" diff --git a/be/src/agent/task_worker_pool.cpp b/be/src/agent/task_worker_pool.cpp index bd144403..a28e71ba 100644 --- a/be/src/agent/task_worker_pool.cpp +++ b/be/src/agent/task_worker_pool.cpp @@ -39,7 +39,7 @@ #include "olap/olap_common.h" #include "olap/storage_engine.h" #include "olap/tablet.h" -#include "olap/store.h" +#include "olap/data_dir.h" #include "olap/utils.h" #include "common/resource_tls.h" #include "common/status.h" @@ -1105,7 +1105,7 @@ void* TaskWorkerPool::_clone_worker_thread_callback(void* arg_this) { // Get local disk from olap string local_shard_root_path; - OlapStore* store = nullptr; + DataDir* store = nullptr; OLAPStatus olap_status = worker_pool_this->_env->olap_engine()->obtain_shard_path( clone_req.storage_medium, &local_shard_root_path, &store); if (olap_status != OLAP_SUCCESS) { diff --git a/be/src/http/action/restore_tablet_action.cpp b/be/src/http/action/restore_tablet_action.cpp index c07e2810..1030a596 100644 --- a/be/src/http/action/restore_tablet_action.cpp +++ b/be/src/http/action/restore_tablet_action.cpp @@ -35,7 +35,7 @@ #include "util/json_util.h" #include "olap/olap_define.h" #include "olap/storage_engine.h" -#include "olap/store.h" +#include "olap/data_dir.h" #include "runtime/exec_env.h" using boost::filesystem::path; @@ -176,8 +176,8 @@ Status RestoreTabletAction::_restore(const std::string& key, int64_t tablet_id, _tablet_path_map[key] = latest_tablet_path; } - std::string root_path = OlapStore::get_root_path_from_schema_hash_path_in_trash(latest_tablet_path); - OlapStore* store = StorageEngine::get_instance()->get_store(root_path); + std::string root_path = DataDir::get_root_path_from_schema_hash_path_in_trash(latest_tablet_path); + DataDir* store = StorageEngine::get_instance()->get_store(root_path); std::string restore_schema_hash_path = store->get_absolute_tablet_path(&header, true); Status s = FileUtils::create_dir(restore_schema_hash_path); if (!s.ok()) { @@ -215,7 +215,7 @@ Status RestoreTabletAction::_restore(const std::string& key, int64_t tablet_id, bool RestoreTabletAction::_get_latest_tablet_path_from_trash( int64_t tablet_id, int32_t schema_hash, std::string* path) { std::vector<std::string> tablet_paths; - std::vector<OlapStore*> stores = StorageEngine::get_instance()->get_stores(); + std::vector<DataDir*> stores = StorageEngine::get_instance()->get_stores(); for (auto& store : stores) { store->find_tablet_in_trash(tablet_id, &tablet_paths); } diff --git a/be/src/olap/CMakeLists.txt b/be/src/olap/CMakeLists.txt index 2c12d6f3..5bc442f6 100644 --- a/be/src/olap/CMakeLists.txt +++ b/be/src/olap/CMakeLists.txt @@ -72,7 +72,7 @@ add_library(Olap STATIC segment_writer.cpp serialize.cpp storage_engine.cpp - store.cpp + data_dir.cpp stream_index_common.cpp stream_index_reader.cpp stream_index_writer.cpp diff --git a/be/src/olap/store.cpp b/be/src/olap/data_dir.cpp similarity index 93% rename from be/src/olap/store.cpp rename to be/src/olap/data_dir.cpp index 501cd3f3..48540893 100755 --- a/be/src/olap/store.cpp +++ b/be/src/olap/data_dir.cpp @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -#include "olap/store.h" +#include "olap/data_dir.h" #include <ctype.h> #include <mntent.h> @@ -49,7 +49,7 @@ namespace doris { static const char* const kMtabPath = "/etc/mtab"; static const char* const kTestFilePath = "/.testfile"; -OlapStore::OlapStore(const std::string& path, int64_t capacity_bytes) +DataDir::DataDir(const std::string& path, int64_t capacity_bytes) : _path(path), _cluster_id(-1), _capacity_bytes(capacity_bytes), @@ -63,7 +63,7 @@ OlapStore::OlapStore(const std::string& path, int64_t capacity_bytes) _meta((nullptr)) { } -OlapStore::~OlapStore() { +DataDir::~DataDir() { free(_test_file_read_buf); free(_test_file_write_buf); if (_meta != nullptr) { @@ -71,7 +71,7 @@ OlapStore::~OlapStore() { } } -Status OlapStore::init() { +Status DataDir::init() { _rand_seed = static_cast<uint32_t>(time(NULL)); if (posix_memalign((void**)&_test_file_write_buf, DIRECT_IO_ALIGNMENT, @@ -101,7 +101,7 @@ Status OlapStore::init() { return Status::OK; } -Status OlapStore::_check_path_exist() { +Status DataDir::_check_path_exist() { DIR* dirp = opendir(_path.c_str()); if (dirp == nullptr) { char buf[64]; @@ -121,7 +121,7 @@ Status OlapStore::_check_path_exist() { return Status::OK; } -Status OlapStore::_init_cluster_id() { +Status DataDir::_init_cluster_id() { std::string cluster_id_path = _path + CLUSTER_ID_PREFIX; if (access(cluster_id_path.c_str(), F_OK) != 0) { int fd = open(cluster_id_path.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); @@ -155,7 +155,7 @@ Status OlapStore::_init_cluster_id() { return st; } -Status OlapStore::_read_cluster_id(const std::string& path, int32_t* cluster_id) { +Status DataDir::_read_cluster_id(const std::string& path, int32_t* cluster_id) { int32_t tmp_cluster_id = -1; std::fstream fs(path.c_str(), std::fstream::in); @@ -183,7 +183,7 @@ Status OlapStore::_read_cluster_id(const std::string& path, int32_t* cluster_id) return Status::OK; } -Status OlapStore::_init_extension_and_capacity() { +Status DataDir::_init_extension_and_capacity() { boost::filesystem::path boost_path = _path; std::string extension = boost::filesystem::canonical(boost_path).extension().string(); if (extension != "") { @@ -219,7 +219,7 @@ Status OlapStore::_init_extension_and_capacity() { return Status::OK; } -Status OlapStore::_init_file_system() { +Status DataDir::_init_file_system() { struct stat s; if (stat(_path.c_str(), &s) != 0) { char errmsg[64]; @@ -275,7 +275,7 @@ Status OlapStore::_init_file_system() { return Status::OK; } -Status OlapStore::_init_meta() { +Status DataDir::_init_meta() { // init path hash _path_hash = hash_of_path(BackendOptions::get_localhost(), _path); LOG(INFO) << "get hash of path: " << _path @@ -295,7 +295,7 @@ Status OlapStore::_init_meta() { return Status::OK; } -Status OlapStore::set_cluster_id(int32_t cluster_id) { +Status DataDir::set_cluster_id(int32_t cluster_id) { if (_cluster_id != -1) { if (_cluster_id == cluster_id) { return Status::OK; @@ -307,7 +307,7 @@ Status OlapStore::set_cluster_id(int32_t cluster_id) { return _write_cluster_id_to_path(_cluster_id_path(), cluster_id); } -Status OlapStore::_write_cluster_id_to_path(const std::string& path, int32_t cluster_id) { +Status DataDir::_write_cluster_id_to_path(const std::string& path, int32_t cluster_id) { std::fstream fs(path.c_str(), std::fstream::out); if (!fs.is_open()) { LOG(WARNING) << "fail to open cluster id path. path=" << path; @@ -318,7 +318,7 @@ Status OlapStore::_write_cluster_id_to_path(const std::string& path, int32_t clu return Status::OK; } -void OlapStore::health_check() { +void DataDir::health_check() { // check disk if (_is_used) { OLAPStatus res = OLAP_SUCCESS; @@ -331,7 +331,7 @@ void OlapStore::health_check() { } } -OLAPStatus OlapStore::_read_and_write_test_file() { +OLAPStatus DataDir::_read_and_write_test_file() { std::string test_file = _path + kTestFilePath; if (access(test_file.c_str(), F_OK) == 0) { @@ -396,7 +396,7 @@ OLAPStatus OlapStore::_read_and_write_test_file() { return res; } -OLAPStatus OlapStore::get_shard(uint64_t* shard) { +OLAPStatus DataDir::get_shard(uint64_t* shard) { OLAPStatus res = OLAP_SUCCESS; std::lock_guard<std::mutex> l(_mutex); @@ -417,11 +417,11 @@ OLAPStatus OlapStore::get_shard(uint64_t* shard) { return OLAP_SUCCESS; } -OlapMeta* OlapStore::get_meta() { +OlapMeta* DataDir::get_meta() { return _meta; } -OLAPStatus OlapStore::register_tablet(Tablet* tablet) { +OLAPStatus DataDir::register_tablet(Tablet* tablet) { std::lock_guard<std::mutex> l(_mutex); TabletInfo tablet_info(tablet->tablet_id(), tablet->schema_hash()); @@ -429,7 +429,7 @@ OLAPStatus OlapStore::register_tablet(Tablet* tablet) { return OLAP_SUCCESS; } -OLAPStatus OlapStore::deregister_tablet(Tablet* tablet) { +OLAPStatus DataDir::deregister_tablet(Tablet* tablet) { std::lock_guard<std::mutex> l(_mutex); TabletInfo tablet_info(tablet->tablet_id(), tablet->schema_hash()); @@ -437,11 +437,11 @@ OLAPStatus OlapStore::deregister_tablet(Tablet* tablet) { return OLAP_SUCCESS; } -std::string OlapStore::get_absolute_shard_path(const std::string& shard_string) { +std::string DataDir::get_absolute_shard_path(const std::string& shard_string) { return _path + DATA_PREFIX + "/" + shard_string; } -std::string OlapStore::get_absolute_tablet_path(TabletMeta* header, bool with_schema_hash) { +std::string DataDir::get_absolute_tablet_path(TabletMeta* header, bool with_schema_hash) { if (with_schema_hash) { return _path + DATA_PREFIX + "/" + std::to_string(header->shard()) + "/" + std::to_string(header->tablet_id()) + "/" + std::to_string(header->schema_hash()); @@ -452,7 +452,7 @@ std::string OlapStore::get_absolute_tablet_path(TabletMeta* header, bool with_sc } } -void OlapStore::find_tablet_in_trash(int64_t tablet_id, std::vector<std::string>* paths) { +void DataDir::find_tablet_in_trash(int64_t tablet_id, std::vector<std::string>* paths) { // path: /root_path/trash/time_label/tablet_id/schema_hash std::string trash_path = _path + TRASH_PREFIX; std::vector<std::string> sub_dirs; @@ -471,13 +471,13 @@ void OlapStore::find_tablet_in_trash(int64_t tablet_id, std::vector<std::string> } } -std::string OlapStore::get_root_path_from_schema_hash_path_in_trash( +std::string DataDir::get_root_path_from_schema_hash_path_in_trash( const std::string& schema_hash_dir_in_trash) { boost::filesystem::path schema_hash_path_in_trash(schema_hash_dir_in_trash); return schema_hash_path_in_trash.parent_path().parent_path().parent_path().parent_path().string(); } -OLAPStatus OlapStore::_load_tablet_from_header(StorageEngine* engine, TTabletId tablet_id, +OLAPStatus DataDir::_load_tablet_from_header(StorageEngine* engine, TTabletId tablet_id, TSchemaHash schema_hash, const std::string& header) { std::unique_ptr<TabletMeta> tablet_meta(new TabletMeta()); bool parsed = tablet_meta->ParseFromString(header); @@ -540,7 +540,7 @@ OLAPStatus OlapStore::_load_tablet_from_header(StorageEngine* engine, TTabletId return OLAP_SUCCESS; } -OLAPStatus OlapStore::load_tablets(StorageEngine* engine) { +OLAPStatus DataDir::load_tablets(StorageEngine* engine) { auto load_tablet_func = [this, engine](long tablet_id, long schema_hash, const std::string& value) -> bool { OLAPStatus status = _load_tablet_from_header(engine, tablet_id, schema_hash, value); diff --git a/be/src/olap/store.h b/be/src/olap/data_dir.h similarity index 94% rename from be/src/olap/store.h rename to be/src/olap/data_dir.h index 22b04708..cfd4fe78 100644 --- a/be/src/olap/store.h +++ b/be/src/olap/data_dir.h @@ -31,12 +31,12 @@ namespace doris { class StorageEngine; -// A OlapStore used to manange data in same path. -// Now, After OlapStore was created, it will never be deleted for easy implementation. -class OlapStore { +// A DataDir used to manange data in same path. +// Now, After DataDir was created, it will never be deleted for easy implementation. +class DataDir { public: - OlapStore(const std::string& path, int64_t capacity_bytes = -1); - ~OlapStore(); + DataDir(const std::string& path, int64_t capacity_bytes = -1); + ~DataDir(); Status init(); diff --git a/be/src/olap/olap_snapshot.cpp b/be/src/olap/olap_snapshot.cpp index 3daab998..4bdce393 100644 --- a/be/src/olap/olap_snapshot.cpp +++ b/be/src/olap/olap_snapshot.cpp @@ -38,7 +38,7 @@ #include "olap/tablet.h" #include "olap/tablet_meta_manager.h" #include "olap/push_handler.h" -#include "olap/store.h" +#include "olap/data_dir.h" #include "util/file_utils.h" #include "util/doris_metrics.h" @@ -358,7 +358,7 @@ OLAPStatus StorageEngine::_create_snapshot_files( } // load tablet header, in order to remove versions that not in shortest version path - OlapStore* store = ref_tablet->store(); + DataDir* store = ref_tablet->store(); new_tablet_meta = new(nothrow) TabletMeta(); if (new_tablet_meta == NULL) { OLAP_LOG_WARNING("fail to malloc TabletMeta."); @@ -557,7 +557,7 @@ OLAPStatus StorageEngine::_create_incremental_snapshot_files( } OLAPStatus StorageEngine::_append_single_delta( - const TSnapshotRequest& request, OlapStore* store) { + const TSnapshotRequest& request, DataDir* store) { OLAPStatus res = OLAP_SUCCESS; string root_path = store->path(); TabletMeta* new_tablet_meta = new(nothrow) TabletMeta(); @@ -780,7 +780,7 @@ OLAPStatus StorageEngine::storage_medium_migrate( } OLAPStatus StorageEngine::_generate_new_header( - OlapStore* store, + DataDir* store, const uint64_t new_shard, const TabletSharedPtr& tablet, const vector<VersionEntity>& version_entity_vec, TabletMeta* new_tablet_meta) { @@ -790,7 +790,7 @@ OLAPStatus StorageEngine::_generate_new_header( } OLAPStatus res = OLAP_SUCCESS; - OlapStore* ref_store = + DataDir* ref_store = StorageEngine::get_instance()->get_store(tablet->storage_root_path_name()); TabletMetaManager::get_header(ref_store, tablet->tablet_id(), tablet->schema_hash(), new_tablet_meta); _update_header_file_info(version_entity_vec, new_tablet_meta); diff --git a/be/src/olap/storage_engine.cpp b/be/src/olap/storage_engine.cpp index 2d69ef03..7e41024c 100644 --- a/be/src/olap/storage_engine.cpp +++ b/be/src/olap/storage_engine.cpp @@ -42,7 +42,7 @@ #include "olap/push_handler.h" #include "olap/reader.h" #include "olap/schema_change.h" -#include "olap/store.h" +#include "olap/data_dir.h" #include "olap/utils.h" #include "olap/data_writer.h" #include "util/time.h" @@ -123,7 +123,7 @@ StorageEngine::~StorageEngine() { clear(); } -OLAPStatus StorageEngine::_load_store(OlapStore* store) { +OLAPStatus StorageEngine::_load_store(DataDir* store) { std::string store_path = store->path(); LOG(INFO) <<"start to load tablets from store_path:" << store_path; @@ -197,13 +197,13 @@ OLAPStatus StorageEngine::_load_store(OlapStore* store) { } OLAPStatus StorageEngine::load_one_tablet( - OlapStore* store, TTabletId tablet_id, SchemaHash schema_hash, + DataDir* store, TTabletId tablet_id, SchemaHash schema_hash, const string& schema_hash_path, bool force) { return _tablet_mgr.load_one_tablet(store, tablet_id, schema_hash, schema_hash_path, force); } -void StorageEngine::load_stores(const std::vector<OlapStore*>& stores) { +void StorageEngine::load_stores(const std::vector<DataDir*>& stores) { std::vector<std::thread> threads; for (auto store : stores) { threads.emplace_back([this, store] { @@ -222,7 +222,7 @@ void StorageEngine::load_stores(const std::vector<OlapStore*>& stores) { OLAPStatus StorageEngine::open() { // init store_map for (auto& path : _options.store_paths) { - OlapStore* store = new OlapStore(path.path, path.capacity_bytes); + DataDir* store = new DataDir(path.path, path.capacity_bytes); auto st = store->init(); if (!st.ok()) { LOG(WARNING) << "Store load failed, path=" << path.path; @@ -330,8 +330,8 @@ void StorageEngine::get_all_available_root_path(std::vector<std::string>* availa } template<bool include_unused> -std::vector<OlapStore*> StorageEngine::get_stores() { - std::vector<OlapStore*> stores; +std::vector<DataDir*> StorageEngine::get_stores() { + std::vector<DataDir*> stores; stores.reserve(_store_map.size()); std::lock_guard<std::mutex> l(_store_lock); @@ -349,8 +349,8 @@ std::vector<OlapStore*> StorageEngine::get_stores() { return stores; } -template std::vector<OlapStore*> StorageEngine::get_stores<false>(); -template std::vector<OlapStore*> StorageEngine::get_stores<true>(); +template std::vector<DataDir*> StorageEngine::get_stores<false>(); +template std::vector<DataDir*> StorageEngine::get_stores<true>(); OLAPStatus StorageEngine::get_all_root_path_info(vector<RootPathInfo>* root_paths_info) { OLAPStatus res = OLAP_SUCCESS; @@ -470,9 +470,9 @@ Status StorageEngine::set_cluster_id(int32_t cluster_id) { return Status::OK; } -std::vector<OlapStore*> StorageEngine::get_stores_for_create_tablet( +std::vector<DataDir*> StorageEngine::get_stores_for_create_tablet( TStorageMedium::type storage_medium) { - std::vector<OlapStore*> stores; + std::vector<DataDir*> stores; { std::lock_guard<std::mutex> l(_store_lock); for (auto& it : _store_map) { @@ -490,7 +490,7 @@ std::vector<OlapStore*> StorageEngine::get_stores_for_create_tablet( return stores; } -OlapStore* StorageEngine::get_store(const std::string& path) { +DataDir* StorageEngine::get_store(const std::string& path) { std::lock_guard<std::mutex> l(_store_lock); auto it = _store_map.find(path); if (it == std::end(_store_map)) { @@ -873,7 +873,7 @@ TabletSharedPtr StorageEngine::create_tablet( const bool is_schema_change_tablet, const TabletSharedPtr ref_tablet) { // Get all available stores, use ref_root_path if the caller specified - std::vector<OlapStore*> stores; + std::vector<DataDir*> stores; if (ref_root_path == nullptr) { stores = get_stores_for_create_tablet(request.storage_medium); if (stores.empty()) { @@ -1097,7 +1097,7 @@ void StorageEngine::add_unused_index(SegmentGroup* segment_group) { OLAPStatus StorageEngine::create_tablet(const TCreateTabletReq& request) { // Get all available stores, use ref_root_path if the caller specified - std::vector<OlapStore*> stores; + std::vector<DataDir*> stores; stores = get_stores_for_create_tablet(request.storage_medium); if (stores.empty()) { LOG(WARNING) << "there is no available disk that can be used to create tablet."; @@ -1461,7 +1461,7 @@ OLAPStatus StorageEngine::finish_clone(TabletSharedPtr tablet, const string& clo } OLAPStatus StorageEngine::obtain_shard_path( - TStorageMedium::type storage_medium, std::string* shard_path, OlapStore** store) { + TStorageMedium::type storage_medium, std::string* shard_path, DataDir** store) { LOG(INFO) << "begin to process obtain root path. storage_medium=" << storage_medium; OLAPStatus res = OLAP_SUCCESS; @@ -1500,7 +1500,7 @@ OLAPStatus StorageEngine::load_header( << ", schema_hash=" << request.schema_hash; OLAPStatus res = OLAP_SUCCESS; - OlapStore* store = nullptr; + DataDir* store = nullptr; { // TODO(zc) try { @@ -1535,7 +1535,7 @@ OLAPStatus StorageEngine::load_header( } OLAPStatus StorageEngine::load_header( - OlapStore* store, + DataDir* store, const string& shard_path, TTabletId tablet_id, TSchemaHash schema_hash) { diff --git a/be/src/olap/storage_engine.h b/be/src/olap/storage_engine.h index 199c86c6..9d83adc0 100644 --- a/be/src/olap/storage_engine.h +++ b/be/src/olap/storage_engine.h @@ -49,7 +49,7 @@ namespace doris { class Tablet; -class OlapStore; +class DataDir; // StorageEngine singleton to manage all Table pointers. @@ -160,9 +160,9 @@ class StorageEngine { // Note: 这里只能reload原先已经存在的root path,即re-load启动时就登记的root path // 是允许的,但re-load全新的path是不允许的,因为此处没有彻底更新ce调度器信息 - void load_stores(const std::vector<OlapStore*>& stores); + void load_stores(const std::vector<DataDir*>& stores); - OLAPStatus load_one_tablet(OlapStore* store, + OLAPStatus load_one_tablet(DataDir* store, TTabletId tablet_id, SchemaHash schema_hash, const std::string& schema_hash_path, @@ -176,7 +176,7 @@ class StorageEngine { OLAPStatus start_trash_sweep(double *usage); template<bool include_unused = false> - std::vector<OlapStore*> get_stores(); + std::vector<DataDir*> get_stores(); Status set_cluster_id(int32_t cluster_id); // @brief 设置root_path是否可用 @@ -195,9 +195,9 @@ class StorageEngine { // get root path for creating tablet. The returned vector of root path should be random, // for avoiding that all the tablet would be deployed one disk. - std::vector<OlapStore*> get_stores_for_create_tablet( + std::vector<DataDir*> get_stores_for_create_tablet( TStorageMedium::type storage_medium); - OlapStore* get_store(const std::string& path); + DataDir* get_store(const std::string& path); uint32_t available_storage_medium_type_count() { return _available_storage_medium_type_count; @@ -299,7 +299,7 @@ class StorageEngine { virtual OLAPStatus obtain_shard_path( TStorageMedium::type storage_medium, std::string* shared_path, - OlapStore** store); + DataDir** store); // Load new tablet to make it effective. // @@ -309,7 +309,7 @@ class StorageEngine { virtual OLAPStatus load_header( const std::string& shard_path, const TCloneReq& request); virtual OLAPStatus load_header( - OlapStore* store, + DataDir* store, const std::string& shard_path, TTabletId tablet_id, TSchemaHash schema_hash); @@ -395,7 +395,7 @@ class StorageEngine { OLAPStatus _append_single_delta( const TSnapshotRequest& request, - OlapStore* store); + DataDir* store); std::string _construct_index_file_path( const std::string& tablet_path_prefix, @@ -410,7 +410,7 @@ class StorageEngine { int32_t segment_group_id, int32_t segment) const; OLAPStatus _generate_new_header( - OlapStore* store, + DataDir* store, const uint64_t new_shard, const TabletSharedPtr& tablet, const std::vector<VersionEntity>& version_entity_vec, TabletMeta* new_tablet_meta); @@ -452,7 +452,7 @@ class StorageEngine { typedef std::map<std::string, uint32_t> file_system_task_count_t; // 扫描目录, 加载表 - OLAPStatus _load_store(OlapStore* store); + OLAPStatus _load_store(DataDir* store); TabletSharedPtr _find_best_tablet_to_compaction(CompactionType compaction_type); @@ -461,7 +461,7 @@ class StorageEngine { EngineOptions _options; std::mutex _store_lock; - std::map<std::string, OlapStore*> _store_map; + std::map<std::string, DataDir*> _store_map; uint32_t _available_storage_medium_type_count; int32_t _effective_cluster_id; diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp index 1cabe53a..0201ac75 100644 --- a/be/src/olap/tablet.cpp +++ b/be/src/olap/tablet.cpp @@ -34,7 +34,7 @@ #include "olap/storage_engine.h" #include "olap/olap_index.h" #include "olap/reader.h" -#include "olap/store.h" +#include "olap/data_dir.h" #include "olap/row_cursor.h" #include "util/defer_op.h" #include "olap/tablet_meta_manager.h" @@ -55,7 +55,7 @@ namespace doris { TabletSharedPtr Tablet::create_from_header_file( TTabletId tablet_id, TSchemaHash schema_hash, - const string& header_file, OlapStore* store) { + const string& header_file, DataDir* store) { TabletMeta* tablet_meta = NULL; tablet_meta = new(nothrow) TabletMeta(header_file); if (tablet_meta == NULL) { @@ -91,7 +91,7 @@ TabletSharedPtr Tablet::create_from_header_file( TabletSharedPtr Tablet::create_from_header( TabletMeta* tablet_meta, - OlapStore* store) { + DataDir* store) { auto tablet = std::make_shared<Tablet>(tablet_meta, store); if (tablet == NULL) { LOG(WARNING) << "fail to malloc a tablet."; @@ -101,7 +101,7 @@ TabletSharedPtr Tablet::create_from_header( return tablet; } -Tablet::Tablet(TabletMeta* tablet_meta, OlapStore* store) : +Tablet::Tablet(TabletMeta* tablet_meta, DataDir* store) : _tablet_meta(tablet_meta), _is_dropped(false), _num_fields(0), diff --git a/be/src/olap/tablet.h b/be/src/olap/tablet.h index d3fdfa05..7458463f 100644 --- a/be/src/olap/tablet.h +++ b/be/src/olap/tablet.h @@ -41,7 +41,7 @@ class TabletMeta; class SegmentGroup; class Tablet; class RowBlockPosition; -class OlapStore; +class DataDir; // Define Tablet's shared_ptr. It is used for typedef std::shared_ptr<Tablet> TabletSharedPtr; @@ -60,12 +60,12 @@ class Tablet : public std::enable_shared_from_this<Tablet> { TTabletId tablet_id, TSchemaHash schema_hash, const std::string& header_file, - OlapStore* store = nullptr); + DataDir* store = nullptr); static TabletSharedPtr create_from_header( TabletMeta* header, - OlapStore* store = nullptr); + DataDir* store = nullptr); - explicit Tablet(TabletMeta* header, OlapStore* store); + explicit Tablet(TabletMeta* header, DataDir* store); virtual ~Tablet(); @@ -370,7 +370,7 @@ class Tablet : public std::enable_shared_from_this<Tablet> { _schema_hash = schema_hash; } - OlapStore* store() const { + DataDir* store() const { return _store; } @@ -675,7 +675,7 @@ class Tablet : public std::enable_shared_from_this<Tablet> { Mutex _base_compaction_lock; size_t _id; // uniq id, used in cache std::string _storage_root_path; - OlapStore* _store; + DataDir* _store; std::atomic<bool> _is_loaded; Mutex _load_lock; std::string _tablet_path; diff --git a/be/src/olap/tablet_manager.cpp b/be/src/olap/tablet_manager.cpp index 814e467d..7708da1e 100644 --- a/be/src/olap/tablet_manager.cpp +++ b/be/src/olap/tablet_manager.cpp @@ -42,7 +42,7 @@ #include "olap/push_handler.h" #include "olap/reader.h" #include "olap/schema_change.h" -#include "olap/store.h" +#include "olap/data_dir.h" #include "olap/utils.h" #include "olap/data_writer.h" #include "util/time.h" @@ -304,7 +304,7 @@ OLAPStatus TabletManager::create_init_version(TTabletId tablet_id, SchemaHash sc } // create_init_version OLAPStatus TabletManager::create_tablet(const TCreateTabletReq& request, - std::vector<OlapStore*> stores) { + std::vector<DataDir*> stores) { OLAPStatus res = OLAP_SUCCESS; bool is_tablet_added = false; @@ -400,7 +400,7 @@ OLAPStatus TabletManager::create_tablet(const TCreateTabletReq& request, TabletSharedPtr TabletManager::create_tablet( const TCreateTabletReq& request, const string* ref_root_path, const bool is_schema_change_tablet, const TabletSharedPtr ref_tablet, - std::vector<OlapStore*> stores) { + std::vector<DataDir*> stores) { TabletSharedPtr tablet; // Try to create tablet on each of all_available_root_path, util success @@ -689,7 +689,7 @@ TabletSharedPtr TabletManager::find_best_tablet_to_compaction(CompactionType com } OLAPStatus TabletManager::load_one_tablet( - OlapStore* store, TTabletId tablet_id, SchemaHash schema_hash, + DataDir* store, TTabletId tablet_id, SchemaHash schema_hash, const string& schema_hash_path, bool force) { stringstream header_name_stream; header_name_stream << schema_hash_path << "/" << tablet_id << ".hdr"; @@ -1013,7 +1013,7 @@ OLAPStatus TabletManager::_create_init_version( OLAPStatus TabletManager::_create_new_tablet_header( const TCreateTabletReq& request, - OlapStore* store, + DataDir* store, const bool is_schema_change_tablet, const TabletSharedPtr ref_tablet, TabletMeta* header) { diff --git a/be/src/olap/tablet_manager.h b/be/src/olap/tablet_manager.h index b2f5b7c9..4c5775d3 100644 --- a/be/src/olap/tablet_manager.h +++ b/be/src/olap/tablet_manager.h @@ -47,7 +47,7 @@ namespace doris { class Tablet; -class OlapStore; +class DataDir; // TabletManager provides get,add, delete tablet method for storage engine class TabletManager { @@ -81,7 +81,7 @@ class TabletManager { Version version, VersionHash version_hash); OLAPStatus create_tablet(const TCreateTabletReq& request, - std::vector<OlapStore*> stores); + std::vector<DataDir*> stores); // Create new tablet for StorageEngine // @@ -90,7 +90,7 @@ class TabletManager { const std::string* ref_root_path, const bool is_schema_change_tablet, const TabletSharedPtr ref_tablet, - std::vector<OlapStore*> stores); + std::vector<DataDir*> stores); // ######################### ALTER TABLE BEGIN ######################### // The following interfaces are all about alter tablet operation, @@ -129,7 +129,7 @@ class TabletManager { void get_tablet_stat(TTabletStatResult& result); - OLAPStatus load_one_tablet(OlapStore* store, + OLAPStatus load_one_tablet(DataDir* store, TTabletId tablet_id, SchemaHash schema_hash, const std::string& schema_hash_path, @@ -162,7 +162,7 @@ class TabletManager { OLAPStatus _create_new_tablet_header(const TCreateTabletReq& request, - OlapStore* store, + DataDir* store, const bool is_schema_change_tablet, const TabletSharedPtr ref_tablet, TabletMeta* header); @@ -183,7 +183,7 @@ class TabletManager { RWMutex _tablet_map_lock; tablet_map_t _tablet_map; size_t _global_tablet_id; - std::map<std::string, OlapStore*> _store_map; + std::map<std::string, DataDir*> _store_map; // cache to save tablets' statistics, such as data size and row // TODO(cmy): for now, this is a naive implementation diff --git a/be/src/olap/tablet_meta_manager.cpp b/be/src/olap/tablet_meta_manager.cpp index dbd0def9..20a02fb0 100755 --- a/be/src/olap/tablet_meta_manager.cpp +++ b/be/src/olap/tablet_meta_manager.cpp @@ -46,7 +46,7 @@ namespace doris { const std::string HEADER_PREFIX = "hdr_"; -OLAPStatus TabletMetaManager::get_header(OlapStore* store, +OLAPStatus TabletMetaManager::get_header(DataDir* store, TTabletId tablet_id, TSchemaHash schema_hash, TabletMeta* header) { OlapMeta* meta = store->get_meta(); std::stringstream key_stream; @@ -65,7 +65,7 @@ OLAPStatus TabletMetaManager::get_header(OlapStore* store, return header->init(); } -OLAPStatus TabletMetaManager::get_json_header(OlapStore* store, +OLAPStatus TabletMetaManager::get_json_header(DataDir* store, TTabletId tablet_id, TSchemaHash schema_hash, std::string* json_header) { TabletMeta header; OLAPStatus s = get_header(store, tablet_id, schema_hash, &header); @@ -79,7 +79,7 @@ OLAPStatus TabletMetaManager::get_json_header(OlapStore* store, } -OLAPStatus TabletMetaManager::save(OlapStore* store, +OLAPStatus TabletMetaManager::save(DataDir* store, TTabletId tablet_id, TSchemaHash schema_hash, const TabletMeta* header) { std::stringstream key_stream; key_stream << HEADER_PREFIX << tablet_id << "_" << schema_hash; @@ -91,7 +91,7 @@ OLAPStatus TabletMetaManager::save(OlapStore* store, return s; } -OLAPStatus TabletMetaManager::remove(OlapStore* store, TTabletId tablet_id, TSchemaHash schema_hash) { +OLAPStatus TabletMetaManager::remove(DataDir* store, TTabletId tablet_id, TSchemaHash schema_hash) { std::stringstream key_stream; key_stream << HEADER_PREFIX << tablet_id << "_" << schema_hash; std::string key = key_stream.str(); @@ -102,7 +102,7 @@ OLAPStatus TabletMetaManager::remove(OlapStore* store, TTabletId tablet_id, TSch return res; } -OLAPStatus TabletMetaManager::get_header_converted(OlapStore* store, bool& flag) { +OLAPStatus TabletMetaManager::get_header_converted(DataDir* store, bool& flag) { // get is_header_converted flag std::string value; std::string key = IS_HEADER_CONVERTED; @@ -119,7 +119,7 @@ OLAPStatus TabletMetaManager::get_header_converted(OlapStore* store, bool& flag) return OLAP_SUCCESS; } -OLAPStatus TabletMetaManager::set_converted_flag(OlapStore* store) { +OLAPStatus TabletMetaManager::set_converted_flag(DataDir* store) { OlapMeta* meta = store->get_meta(); OLAPStatus s = meta->put(DEFAULT_COLUMN_FAMILY_INDEX, IS_HEADER_CONVERTED, CONVERTED_FLAG); return s; @@ -143,7 +143,7 @@ OLAPStatus TabletMetaManager::traverse_headers(OlapMeta* meta, return status; } -OLAPStatus TabletMetaManager::load_json_header(OlapStore* store, const std::string& header_path) { +OLAPStatus TabletMetaManager::load_json_header(DataDir* store, const std::string& header_path) { std::ifstream infile(header_path); char buffer[1024]; std::string json_header; @@ -163,7 +163,7 @@ OLAPStatus TabletMetaManager::load_json_header(OlapStore* store, const std::stri return s; } -OLAPStatus TabletMetaManager::dump_header(OlapStore* store, TTabletId tablet_id, +OLAPStatus TabletMetaManager::dump_header(DataDir* store, TTabletId tablet_id, TSchemaHash schema_hash, const std::string& dump_path) { TabletMeta header; OLAPStatus res = TabletMetaManager::get_header(store, tablet_id, schema_hash, &header); diff --git a/be/src/olap/tablet_meta_manager.h b/be/src/olap/tablet_meta_manager.h index 045d4e0b..c06a8526 100644 --- a/be/src/olap/tablet_meta_manager.h +++ b/be/src/olap/tablet_meta_manager.h @@ -22,32 +22,32 @@ #include "olap/tablet_meta.h" #include "olap/olap_define.h" -#include "olap/store.h" +#include "olap/data_dir.h" namespace doris { // Helper Class for managing tablet headers of one root path. class TabletMetaManager { public: - static OLAPStatus get_header(OlapStore* store, TTabletId tablet_id, TSchemaHash schema_hash, TabletMeta* header); + static OLAPStatus get_header(DataDir* store, TTabletId tablet_id, TSchemaHash schema_hash, TabletMeta* header); - static OLAPStatus get_json_header(OlapStore* store, TTabletId tablet_id, + static OLAPStatus get_json_header(DataDir* store, TTabletId tablet_id, TSchemaHash schema_hash, std::string* json_header); - static OLAPStatus save(OlapStore* store, TTabletId tablet_id, TSchemaHash schema_hash, const TabletMeta* header); + static OLAPStatus save(DataDir* store, TTabletId tablet_id, TSchemaHash schema_hash, const TabletMeta* header); - static OLAPStatus remove(OlapStore* store, TTabletId tablet_id, TSchemaHash schema_hash); + static OLAPStatus remove(DataDir* store, TTabletId tablet_id, TSchemaHash schema_hash); static OLAPStatus traverse_headers(OlapMeta* meta, std::function<bool(long, long, const std::string&)> const& func); - static OLAPStatus get_header_converted(OlapStore* store, bool& flag); + static OLAPStatus get_header_converted(DataDir* store, bool& flag); - static OLAPStatus set_converted_flag(OlapStore* store); + static OLAPStatus set_converted_flag(DataDir* store); - static OLAPStatus load_json_header(OlapStore* store, const std::string& header_path); + static OLAPStatus load_json_header(DataDir* store, const std::string& header_path); - static OLAPStatus dump_header(OlapStore* store, TTabletId tablet_id, + static OLAPStatus dump_header(DataDir* store, TTabletId tablet_id, TSchemaHash schema_hash, const std::string& path); }; diff --git a/be/src/olap/txn_manager.cpp b/be/src/olap/txn_manager.cpp index d5003b2b..ddbce658 100644 --- a/be/src/olap/txn_manager.cpp +++ b/be/src/olap/txn_manager.cpp @@ -42,7 +42,7 @@ #include "olap/push_handler.h" #include "olap/reader.h" #include "olap/schema_change.h" -#include "olap/store.h" +#include "olap/data_dir.h" #include "olap/utils.h" #include "olap/data_writer.h" #include "util/time.h" diff --git a/be/src/runtime/snapshot_loader.cpp b/be/src/runtime/snapshot_loader.cpp index cd836a06..41af825b 100644 --- a/be/src/runtime/snapshot_loader.cpp +++ b/be/src/runtime/snapshot_loader.cpp @@ -660,7 +660,7 @@ Status SnapshotLoader::move( // fixme: there is no header now and can not call load_one_tablet here // reload header - OlapStore* store = StorageEngine::get_instance()->get_store(store_path); + DataDir* store = StorageEngine::get_instance()->get_store(store_path); if (store == nullptr) { std::stringstream ss; ss << "failed to get store by path: " << store_path; diff --git a/be/src/tools/meta_tool.cpp b/be/src/tools/meta_tool.cpp index dc6cf61a..af39e2d6 100644 --- a/be/src/tools/meta_tool.cpp +++ b/be/src/tools/meta_tool.cpp @@ -24,7 +24,7 @@ #include <gflags/gflags.h> #include "common/status.h" -#include "olap/store.h" +#include "olap/data_dir.h" #include "olap/tablet_meta_manager.h" #include "olap/olap_define.h" #include "olap/tablet_meta.h" @@ -32,7 +32,7 @@ #include "olap/utils.h" #include "json2pb/pb_to_json.h" -using doris::OlapStore; +using doris::DataDir; using doris::OlapMeta; using doris::TabletMetaManager; using doris::TabletMeta; @@ -83,7 +83,7 @@ int main(int argc, char** argv) { root_path = path_prefix + root_path_postfix; } - std::unique_ptr<OlapStore> store(new(std::nothrow) OlapStore(root_path)); + std::unique_ptr<DataDir> store(new(std::nothrow) DataDir(root_path)); if (store.get() == NULL) { std::cout << "new store failed" << std::endl; return -1; diff --git a/be/test/olap/tablet_meta_manager_test.cpp b/be/test/olap/tablet_meta_manager_test.cpp index af5a044d..4dc4d8de 100755 --- a/be/test/olap/tablet_meta_manager_test.cpp +++ b/be/test/olap/tablet_meta_manager_test.cpp @@ -21,7 +21,7 @@ #include "gtest/gtest.h" #include "gmock/gmock.h" -#include "olap/store.h" +#include "olap/data_dir.h" #include "olap/tablet_meta_manager.h" #include "olap/olap_define.h" #include "boost/filesystem.hpp" @@ -45,7 +45,7 @@ class TabletMetaManagerTest : public testing::Test { virtual void SetUp() { std::string root_path = "./store"; ASSERT_TRUE(boost::filesystem::create_directory(root_path)); - _store = new(std::nothrow) OlapStore(root_path); + _store = new(std::nothrow) DataDir(root_path); ASSERT_NE(nullptr, _store); Status st = _store->init(); ASSERT_TRUE(st.ok()); @@ -68,7 +68,7 @@ class TabletMetaManagerTest : public testing::Test { } private: - OlapStore* _store; + DataDir* _store; std::string _json_header; }; ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org For additional commands, e-mail: dev-h...@doris.apache.org