yiguolei commented on a change in pull request #454: Refactor Tablet and TabletMeta URL: https://github.com/apache/incubator-doris/pull/454#discussion_r243486057
########## File path: be/src/olap/tablet.cpp ########## @@ -202,917 +63,145 @@ Tablet::~Tablet() { } // ensure that there is nobody using Tablet, like acquiring OLAPData(SegmentGroup) - obtain_header_wrlock(); - for (auto& it : _data_sources) { - for (SegmentGroup* segment_group : it.second) { - SAFE_DELETE(segment_group); - } - } - _data_sources.clear(); - - // clear the transactions in memory - for (auto& it : _pending_data_sources) { - // false means can't remove the transaction from tablet_meta, also prevent the loading of tablet - for (SegmentGroup* segment_group : it.second) { - StorageEngine::get_instance()->delete_transaction( - segment_group->partition_id(), segment_group->transaction_id(), - _tablet_id, _schema_hash, false); - SAFE_DELETE(segment_group); - } - } - _pending_data_sources.clear(); - release_header_lock(); - - SAFE_DELETE(_tablet_meta); - - // 移动数据目录 - if (_is_dropped) { - LOG(INFO) << "drop tablet:" << full_name() << ", tablet path:" << _tablet_path; - path table_path(_tablet_path); - std::string tablet_meta_path = _tablet_path + "/" + std::to_string(_tablet_id) + ".hdr"; - OLAPStatus s = TabletMetaManager::dump_header(_store, _tablet_id, _schema_hash, tablet_meta_path); - LOG(INFO) << "dump tablet_meta to path:" << tablet_meta_path << ", status:" << s; - LOG(INFO) << "start to remove tablet tablet_meta:" << full_name(); - s = TabletMetaManager::remove(_store, _tablet_id, _schema_hash); - LOG(INFO) << "finish remove tablet tablet_meta:" << full_name() << ", res:" << s; - if (move_to_trash(table_path, table_path) != OLAP_SUCCESS) { - LOG(WARNING) << "fail to delete tablet. [table_path=" << _tablet_path << "]"; - } - LOG(INFO) << "finish drop tablet:" << full_name(); + WriteLock wrlock(_meta_lock); + for (auto& it : _version_rowset_map) { + SAFE_DELETE(it.second); } + _version_rowset_map.clear(); } -OLAPStatus Tablet::load() { +OLAPStatus Tablet::init_once() { OLAPStatus res = OLAP_SUCCESS; - MutexLock l(&_load_lock); - - string one_schema_root = _tablet_path; - set<string> files; - set<string> index_files; - set<string> data_files; - - if (_is_loaded) { - goto EXIT; + ReadLock rdlock(&_meta_lock); + for (int ser = 0; ser < _tablet_meta.rowset_size(); ++ser) { + const RowsetMeta* rs_meta = _tablet_meta.get_rs_meta(ser); + Version version = rs_meta->version(); + Rowset* rowset = new Rowset(rs_meta); + _version_rowset_map[version] = rowset; Review comment: all ptr should use shared ptr? ---------------------------------------------------------------- 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