Skip to content

Commit

Permalink
*: support new protoc w/ dtpb (pingcap#2096)
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingerZhu authored Jun 9, 2021
1 parent 42bc825 commit 7a24acf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions dbms/src/Storages/Transaction/RegionState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -48,15 +48,15 @@ void RegionState::updateRegionRange()
region_range = std::make_shared<RegionRangeKeys>(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)
{
Expand Down
7 changes: 4 additions & 3 deletions dbms/src/Storages/Transaction/RegionState.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ namespace DB

using ImutRegionRangePtr = std::shared_ptr<const RegionRangeKeys>;

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);
Expand All @@ -42,6 +42,7 @@ class RegionState : private raft_serverpb::RegionLocalState, private boost::nonc
raft_serverpb::MergeState & getMutMergeState();

private:
Base base;
void updateRegionRange();

private:
Expand Down

0 comments on commit 7a24acf

Please sign in to comment.