diff --git a/README.md b/README.md index b29f7bb86e1..73ede11947a 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,11 @@ $ popd $ pushd contrib/tipb $ ./generate-cpp.sh $ popd + +# Additionally if you want to update dtpb +$ pushd dbms/src/Storages/DeltaMerge/File/dtpb +$ ./generate_cpp.sh +$ popd ``` ### Build tiflash-proxy diff --git a/dbms/src/Storages/Transaction/RegionState.cpp b/dbms/src/Storages/Transaction/RegionState.cpp index 608f3634f0a..be1d4e90062 100644 --- a/dbms/src/Storages/Transaction/RegionState.cpp +++ b/dbms/src/Storages/Transaction/RegionState.cpp @@ -4,15 +4,15 @@ namespace DB { -RegionState::RegionState(RegionState && region_state) : Base(std::move(region_state)), region_range(region_state.region_range) {} -RegionState::RegionState(Base && region_state) : Base(std::move(region_state)) { updateRegionRange(); } -RegionState & RegionState::operator=(RegionState && from) +RegionState::RegionState(RegionState && region_state) noexcept : base(std::move(region_state.base)), region_range(std::move(region_state.region_range)) {} +RegionState::RegionState(Base && region_state) : base(std::move(region_state)) { updateRegionRange(); } +RegionState & RegionState::operator=(RegionState && from) noexcept { - if (&from == this) + if (this == std::addressof(from)) return *this; - (Base &)* this = (Base &&) from; - region_range = std::move(from.region_range); + this->base = std::move(from.base); + this->region_range = std::move(from.region_range); return *this; } @@ -48,15 +48,15 @@ void RegionState::updateRegionRange() region_range = std::make_shared(TiKVKey::copyFrom(getRegion().start_key()), TiKVKey::copyFrom(getRegion().end_key())); } -metapb::Region & RegionState::getMutRegion() { return *mutable_region(); } -const metapb::Region & RegionState::getRegion() const { return region(); } -raft_serverpb::PeerState RegionState::getState() const { return state(); } -void RegionState::setState(raft_serverpb::PeerState value) { set_state(value); } -void RegionState::clearMergeState() { clear_merge_state(); } +metapb::Region & RegionState::getMutRegion() { return *base.mutable_region(); } +const metapb::Region & RegionState::getRegion() const { return base.region(); } +raft_serverpb::PeerState RegionState::getState() const { return base.state(); } +void RegionState::setState(raft_serverpb::PeerState value) { base.set_state(value); } +void RegionState::clearMergeState() { base.clear_merge_state(); } bool RegionState::operator==(const RegionState & region_state) const { return getBase() == region_state.getBase(); } -const RegionState::Base & RegionState::getBase() const { return *this; } -const raft_serverpb::MergeState & RegionState::getMergeState() const { return merge_state(); } -raft_serverpb::MergeState & RegionState::getMutMergeState() { return *mutable_merge_state(); } +const RegionState::Base & RegionState::getBase() const { return base; } +const raft_serverpb::MergeState & RegionState::getMergeState() const { return base.merge_state(); } +raft_serverpb::MergeState & RegionState::getMutMergeState() { return *base.mutable_merge_state(); } bool computeMappedTableID(const DecodedTiKVKey & key, TableID & table_id) { diff --git a/dbms/src/Storages/Transaction/RegionState.h b/dbms/src/Storages/Transaction/RegionState.h index c359fab9e1c..aec68174528 100644 --- a/dbms/src/Storages/Transaction/RegionState.h +++ b/dbms/src/Storages/Transaction/RegionState.h @@ -13,15 +13,15 @@ namespace DB using ImutRegionRangePtr = std::shared_ptr; -class RegionState : private raft_serverpb::RegionLocalState, private boost::noncopyable +class RegionState : private boost::noncopyable { public: using Base = raft_serverpb::RegionLocalState; RegionState() = default; - explicit RegionState(RegionState && region_state); + RegionState(RegionState && region_state) noexcept; explicit RegionState(Base && region_state); - RegionState & operator=(RegionState && from); + RegionState & operator=(RegionState && from) noexcept; void setRegion(metapb::Region region); void setVersion(const UInt64 version); @@ -42,6 +42,7 @@ class RegionState : private raft_serverpb::RegionLocalState, private boost::nonc raft_serverpb::MergeState & getMutMergeState(); private: + Base base; void updateRegionRange(); private: