diff --git a/src/storage/CMakeLists.txt b/src/storage/CMakeLists.txt index 51255508b2..f4dc5fd04f 100644 --- a/src/storage/CMakeLists.txt +++ b/src/storage/CMakeLists.txt @@ -404,6 +404,7 @@ ob_set_subtarget(ob_storage tablet tablet/ob_tablet_space_usage.cpp tablet/ob_tablet_block_aggregated_info.cpp tablet/ob_tablet_macro_info_iterator.cpp + tablet/ob_tablet_ddl_complete_mds_data.cpp ) ob_set_subtarget(ob_storage tx_wrs diff --git a/src/storage/multi_data_source/compile_utility/mds_register.h b/src/storage/multi_data_source/compile_utility/mds_register.h index 7b00c35178..f7f9fee736 100644 --- a/src/storage/multi_data_source/compile_utility/mds_register.h +++ b/src/storage/multi_data_source/compile_utility/mds_register.h @@ -81,6 +81,7 @@ #include "src/storage/mview/ob_major_mv_merge_info.h" #include "src/storage/truncate_info/ob_truncate_info.h" #include "src/storage/mview/ob_mview_mds.h" + #include "src/storage/tablet/ob_tablet_ddl_complete_mds_data.h" #endif /**************************************************************************************************/ @@ -288,9 +289,9 @@ _GENERATE_MDS_UNIT_(KEY_TYPE, VALUE_TYPE, NEED_MULTI_VERSION) GENERATE_MDS_UNIT(::oceanbase::storage::ObTruncateInfoKey,\ ::oceanbase::storage::ObTruncateInfo,\ false) - // GENERATE_MDS_UNIT(::oceanbase::storage::mds::DummyKey,\ - // ::oceanbase::storage::ObTabletDDLCompleteMdsUserData,\ - // false) + GENERATE_MDS_UNIT(::oceanbase::storage::mds::DummyKey,\ + ::oceanbase::storage::ObTabletDDLCompleteMdsUserData,\ + false) // # 余留位置(此行之前占位) #endif diff --git a/src/storage/tablet/ob_tablet_ddl_complete_mds_data.cpp b/src/storage/tablet/ob_tablet_ddl_complete_mds_data.cpp new file mode 100644 index 0000000000..258f393168 --- /dev/null +++ b/src/storage/tablet/ob_tablet_ddl_complete_mds_data.cpp @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ +#include "storage/tablet/ob_tablet_ddl_complete_mds_data.h" +#include "lib/oblog/ob_log_module.h" +#include "lib/utility/ob_unify_serialize.h" +#include "share/ob_errno.h" +#include "storage/tx/ob_trans_define.h" +#include "storage/tx_storage/ob_ls_handle.h" +#include "storage/tx_storage/ob_ls_service.h" +#include "storage/ddl/ob_direct_load_struct.h" + +#define USING_LOG_PREFIX MDS + +using namespace oceanbase::common; +using namespace oceanbase::transaction; + +namespace oceanbase +{ +namespace storage +{ +ObTabletDDLCompleteMdsUserData::ObTabletDDLCompleteMdsUserData(): + has_complete_(false), direct_load_type_(ObDirectLoadType::DIRECT_LOAD_INVALID), data_format_version_(0), snapshot_version_(0), table_key_() +{} + +bool ObTabletDDLCompleteMdsUserData::is_valid() const +{ + return (!has_complete_) || + (has_complete_ && table_key_.is_valid() && + direct_load_type_ > ObDirectLoadType::DIRECT_LOAD_INVALID && + direct_load_type_ < ObDirectLoadType::DIRECT_LOAD_MAX); +} + +int ObTabletDDLCompleteMdsUserData::assign(const ObTabletDDLCompleteMdsUserData &other) +{ + int ret = OB_SUCCESS; + if (!other.is_valid()) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid argument", K(ret), K(other)); + } else { + has_complete_ = other.has_complete_; + direct_load_type_ = other.direct_load_type_; + data_format_version_ = other.data_format_version_; + snapshot_version_ = other.snapshot_version_; + table_key_ = other.table_key_; + } + return ret; +} + +void ObTabletDDLCompleteMdsUserData::reset() +{ + has_complete_ = false; + direct_load_type_ = ObDirectLoadType::DIRECT_LOAD_INVALID; + data_format_version_ = 0; + snapshot_version_ = 0; + table_key_.reset(); +} + +OB_SERIALIZE_MEMBER( + ObTabletDDLCompleteMdsUserData, + has_complete_, + direct_load_type_, + data_format_version_, + snapshot_version_, + table_key_ +) +} // namespace storage +} // namespace oceanbase \ No newline at end of file diff --git a/src/storage/tablet/ob_tablet_ddl_complete_mds_data.h b/src/storage/tablet/ob_tablet_ddl_complete_mds_data.h new file mode 100644 index 0000000000..2bda8df4ad --- /dev/null +++ b/src/storage/tablet/ob_tablet_ddl_complete_mds_data.h @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OCEANBASE_STORAGE_OB_TABLET_DDL_COMPLETE_MDS_DATA +#define OCEANBASE_STORAGE_OB_TABLET_DDL_COMPLETE_MDS_DATA + +#include +#include "lib/utility/ob_print_utils.h" +#include "share/ob_ls_id.h" +#include "share/scn.h" +#include "common/ob_tablet_id.h" +#include "storage/tablet/ob_tablet_common.h" +#include "storage/ob_i_table.h" +#include "storage/ddl/ob_ddl_struct.h" + +namespace oceanbase +{ +namespace storage +{ +class ObDDLTableMergeDagParam; +class ObTabletDDLCompleteArg; +class ObTabletDDLCompleteMdsUserData +{ + OB_UNIS_VERSION(1); +public: + ObTabletDDLCompleteMdsUserData(); + void reset(); + bool is_valid() const ; + int assign(const ObTabletDDLCompleteMdsUserData &other); + TO_STRING_KV(K_(has_complete), K_(direct_load_type), K_(has_complete), + K_(data_format_version), K_(snapshot_version), + K_(table_key)); +public: + bool has_complete_; + /* for merge param */ + ObDirectLoadType direct_load_type_; + uint64_t data_format_version_; + int64_t snapshot_version_; + ObITable::TableKey table_key_; +}; +} // namespace storage +} // namespace oceanbase + +#endif // OCEANBASE_STORAGE_OB_TABLET_CREATE_DELETE_MDS_USER_DATA