1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef MULTI_VER_COMMIT_H 17 #define MULTI_VER_COMMIT_H 18 19 #ifndef OMIT_MULTI_VER 20 #include <cstddef> 21 #include "ikvdb_commit.h" 22 23 #include "multi_ver_def.h" 24 #include "macro_utils.h" 25 26 namespace DistributedDB { 27 class MultiVerCommit final : public IKvDBCommit { 28 public: 29 MultiVerCommit(); 30 ~MultiVerCommit() override; 31 32 DISABLE_COPY_ASSIGN_MOVE(MultiVerCommit); 33 34 Version GetCommitVersion() const override; 35 void SetCommitVersion(const Version &versionInfo) override; 36 37 CommitID GetCommitId() const override; 38 void SetCommitId(const CommitID &id) override; 39 40 CommitID GetLeftParentId() const override; 41 void SetLeftParentId(const CommitID &id) override; 42 43 CommitID GetRightParentId() const override; 44 void SetRightParentId(const CommitID &id) override; 45 46 Timestamp GetTimestamp() const override; 47 void SetTimestamp(Timestamp timestamp) override; 48 49 bool GetLocalFlag() const override; 50 void SetLocalFlag(bool localFlag) override; 51 52 DeviceID GetDeviceInfo() const override; 53 void SetDeviceInfo(const DeviceID &deviceInfo) override; 54 55 bool CheckCommit() const; 56 57 private: 58 static const size_t MAX_VERSION_INFO_LENGTH = 4096; 59 static const size_t MAX_COMMIT_ID_LENGTH = 128; 60 static const size_t MAX_COMMIT_DEV_LENGTH = 256; 61 Version versionInfo_; 62 CommitID commitID_; 63 CommitID leftParentID_; 64 CommitID rightParentID_; 65 Timestamp timestamp_; 66 bool localFlag_; 67 DeviceID deviceInfo_; 68 }; 69 } 70 71 #endif 72 #endif