1 /* 2 * Copyright (c) 2023 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 SINGLE_VER_NATURAL_STORE_CONNECTION_H 17 #define SINGLE_VER_NATURAL_STORE_CONNECTION_H 18 #include "sync_able_kvdb_connection.h" 19 20 namespace DistributedDB { 21 class SingleVerNaturalStoreConnection : public SyncAbleKvDBConnection { 22 public: 23 explicit SingleVerNaturalStoreConnection(SyncAbleKvDB *kvDB); 24 25 virtual ~SingleVerNaturalStoreConnection(); 26 27 int Put(const IOption &option, const Key &key, const Value &value) override; 28 29 int PutBatch(const IOption &option, const std::vector<Entry> &entries) override; 30 31 virtual bool IsExtendedCacheDBMode() const; 32 33 int Get(const IOption &option, const Key &key, Value &value) const override; 34 35 // Delete the value from the database 36 int Delete(const IOption &option, const Key &key) override; 37 38 // Delete the batch values from the database. 39 int DeleteBatch(const IOption &option, const std::vector<Key> &keys) override; 40 protected: 41 virtual int CheckSyncEntriesValid(const std::vector<Entry> &entries) const; 42 43 virtual int CheckWritePermission() const; 44 45 virtual int PutBatchInner(const IOption &option, const std::vector<Entry> &entries) = 0; 46 47 virtual int CheckSyncKeysValid(const std::vector<Key> &keys) const = 0; 48 49 virtual int DeleteBatchInner(const IOption &option, const std::vector<Key> &keys) = 0; 50 51 bool CheckAndGetEntryLen(const std::vector<Entry> &entries, uint32_t limit, uint32_t &keyLen) const; 52 53 bool CheckAndGetKeyLen(const std::vector<Key> &keys, const uint32_t limit, uint32_t &keyLen) const; 54 }; 55 } // namespace DistributedDB 56 57 #endif // SINGLE_VER_NATURAL_STORE_CONNECTION_H