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 OHOS_DISTRIBUTED_DATA_DATAMGR_SERVICE_RDB_CLOUD_H 17 #define OHOS_DISTRIBUTED_DATA_DATAMGR_SERVICE_RDB_CLOUD_H 18 #include "cloud/cloud_db.h" 19 #include "cloud/cloud_store_types.h" 20 #include "cloud/icloud_db.h" 21 #include "error/general_error.h" 22 23 namespace OHOS::DistributedRdb { 24 class RdbCloud : public DistributedDB::ICloudDb { 25 public: 26 using DBStatus = DistributedDB::DBStatus; 27 using DBVBucket = DistributedDB::VBucket; 28 29 explicit RdbCloud(std::shared_ptr<DistributedData::CloudDB> cloudDB); 30 virtual ~RdbCloud() = default; 31 DBStatus BatchInsert(const std::string &tableName, std::vector<DBVBucket> &&record, 32 std::vector<DBVBucket> &extend) override; 33 DBStatus BatchUpdate(const std::string &tableName, std::vector<DBVBucket> &&record, 34 std::vector<DBVBucket> &extend) override; 35 DBStatus BatchDelete(const std::string &tableName, std::vector<DBVBucket> &extend) override; 36 DBStatus Query(const std::string &tableName, DBVBucket &extend, std::vector<DBVBucket> &data) override; 37 std::pair<DBStatus, uint32_t> Lock() override; 38 DBStatus UnLock() override; 39 DBStatus HeartBeat() override; 40 DBStatus Close() override; 41 static DBStatus ConvertStatus(DistributedData::GeneralError error); 42 43 private: 44 static constexpr int32_t TO_MS = 1000; // s > ms 45 std::shared_ptr<DistributedData::CloudDB> cloudDB_; 46 }; 47 } // namespace OHOS::DistributedRdb 48 #endif // OHOS_DISTRIBUTED_DATA_DATAMGR_SERVICE_RDB_CLOUD_H 49