From a31d9e0ff0f854e1b5e2fcef06b2e39631e302e0 Mon Sep 17 00:00:00 2001 From: htt1997 Date: Thu, 18 May 2023 10:10:26 +0800 Subject: [PATCH] update Signed-off-by: htt1997 --- .../framework/include/store/general_store.h | 4 +--- .../service/cloud/cloud_service_impl.cpp | 14 +++++++------- .../service/rdb/rdb_general_store.cpp | 7 +------ .../service/rdb/rdb_general_store.h | 3 +-- .../service/test/cloud_data_test.cpp | 3 ++- .../frameworks/native/rdb/src/rdb_types_util.cpp | 15 --------------- .../inner_api/rdb/include/rdb_service.h | 2 +- 7 files changed, 13 insertions(+), 35 deletions(-) diff --git a/datamgr_service/services/distributeddataservice/framework/include/store/general_store.h b/datamgr_service/services/distributeddataservice/framework/include/store/general_store.h index 097f8d9a..e31eb889 100644 --- a/datamgr_service/services/distributeddataservice/framework/include/store/general_store.h +++ b/datamgr_service/services/distributeddataservice/framework/include/store/general_store.h @@ -32,9 +32,7 @@ public: virtual ~GeneralStore() = default; - virtual int32_t Bind(std::shared_ptr cloudDb) = 0; - - virtual int32_t SetSchema(const SchemaMeta &schemaMeta) = 0; + virtual int32_t Bind(const SchemaMeta &schemaMeta, std::shared_ptr cloudDb) = 0; virtual int32_t Execute(const std::string &table, const std::string &sql) = 0; diff --git a/datamgr_service/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/datamgr_service/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index f1c4186f..cd3c8d16 100644 --- a/datamgr_service/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/datamgr_service/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -399,13 +399,13 @@ void CloudServiceImpl::GetSchema(const Event &event) rdbEvent.GetStoreInfo().instanceId); auto instance = CloudServer::GetInstance(); if (instance == nullptr) { - ZLOGE("instance is nullptr"); + ZLOGE("instance is nullptr"); return; } - auto database = std::find_if(schemaMeta.databases.begin(),schemaMeta.databases.end(), - [&rdbEvent](const auto &database){ - return database.name == rdbEvent.GetStoreInfo().storeName; - }); + auto database = + std::find_if(schemaMeta.databases.begin(), schemaMeta.databases.end(), [&rdbEvent](const auto &database) { + return database.name == rdbEvent.GetStoreInfo().storeName; + }); if (database == schemaMeta.databases.end()) { return; } @@ -422,10 +422,10 @@ void CloudServiceImpl::GetSchema(const Event &event) ZLOGE("store is nullptr"); return; } - store->SetSchema(schemaMeta); - store->Bind(cloudDB); + store->Bind(schemaMeta, cloudDB); for (const auto &table : database->tables) { ZLOGD("table: %{public}s sync start", table.name.c_str()); + // do sync } return; } diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp b/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp index f69051ca..0f79fc62 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp @@ -70,7 +70,7 @@ RdbGeneralStore::RdbGeneralStore(const StoreMetaData &meta) : manager_(meta.appI } } -int32_t RdbGeneralStore::Bind(std::shared_ptr cloudDb) +int32_t RdbGeneralStore::Bind(const SchemaMeta &schemaMeta, std::shared_ptr cloudDb) { cloudDb_ = std::move(cloudDb); return 0; @@ -168,9 +168,4 @@ int32_t RdbGeneralStore::Unwatch(int32_t origin, Watcher &watcher) return GeneralError::E_NOT_SUPPORT; } -int32_t RdbGeneralStore::SetSchema(const SchemaMeta &schemaMeta) -{ - //SetSchema - return GeneralError::E_OK; -} } // namespace OHOS::DistributedRdb diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.h b/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.h index a77e7e33..051115e2 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.h +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.h @@ -39,8 +39,7 @@ public: using RdbManager = DistributedDB::RelationalStoreManager; explicit RdbGeneralStore(const StoreMetaData &metaData); - int32_t Bind(std::shared_ptr cloudDb) override; - int32_t SetSchema(const SchemaMeta &schemaMeta) override; + int32_t Bind(const SchemaMeta &schemaMeta, std::shared_ptr cloudDb) override; int32_t Execute(const std::string &table, const std::string &sql) override; int32_t BatchInsert(const std::string &table, VBuckets &&values) override; int32_t BatchUpdate(const std::string &table, const std::string &sql, VBuckets &&values) override; diff --git a/datamgr_service/services/distributeddataservice/service/test/cloud_data_test.cpp b/datamgr_service/services/distributeddataservice/service/test/cloud_data_test.cpp index 781ed158..32057e30 100644 --- a/datamgr_service/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/datamgr_service/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -90,6 +90,7 @@ SchemaMeta CloudServerMock::GetAppSchema(int32_t userId, const std::string &bund } std::shared_ptr CloudDataTest::dbStoreMock_ = std::make_shared(); +SchemaMeta CloudDataTest::schemaMeta_; void CloudDataTest::InitMetaData() { @@ -148,6 +149,7 @@ void CloudDataTest::TearDownTestCase() {} void CloudDataTest::SetUp() { InitMetaData(); + InitSchemaMeta(); MetaDataManager::GetInstance().SaveMeta(metaData_.GetKey(), metaData_); StoreMetaData storeMetaData; @@ -162,7 +164,6 @@ void CloudDataTest::SetUp() storeMetaData.user = std::to_string(DistributedKv::AccountDelegate::GetInstance()->GetUserByToken(storeMetaData.tokenId)); MetaDataManager::GetInstance().SaveMeta(storeMetaData.GetKey(), storeMetaData); - InitSchemaMeta(); } void CloudDataTest::TearDown() {} diff --git a/relational_store/frameworks/native/rdb/src/rdb_types_util.cpp b/relational_store/frameworks/native/rdb/src/rdb_types_util.cpp index f269f84a..907d1223 100644 --- a/relational_store/frameworks/native/rdb/src/rdb_types_util.cpp +++ b/relational_store/frameworks/native/rdb/src/rdb_types_util.cpp @@ -115,19 +115,4 @@ bool Unmarshalling(Asset &output, MessageParcel &data) { return Unmarshal(data, output.version, output.name, output.size, output.modifyTime, output.uri); } - -template<> -bool Marshalling(const SubOption &input, MessageParcel &data) -{ - return ITypesUtil::Marshal(data, static_cast(input.mode)); -} - -template<> -bool Unmarshalling(SubOption &output, MessageParcel &data) -{ - int32_t mode = static_cast(output.mode); - auto ret = ITypesUtil::Unmarshal(data, mode); - output.mode = static_cast(mode); - return ret; -} } diff --git a/relational_store/interfaces/inner_api/rdb/include/rdb_service.h b/relational_store/interfaces/inner_api/rdb/include/rdb_service.h index 9e82eda3..4d9ec559 100644 --- a/relational_store/interfaces/inner_api/rdb/include/rdb_service.h +++ b/relational_store/interfaces/inner_api/rdb/include/rdb_service.h @@ -64,7 +64,7 @@ public: virtual int32_t GetSchema(const RdbSyncerParam ¶m) = 0; - static constexpr const char *SERVICE_NAME = "relational_store"; + inline static constexpr const char *SERVICE_NAME = "relational_store"; protected: virtual int32_t DoSync(const RdbSyncerParam ¶m, const SyncOption &option, const RdbPredicates &predicates, SyncResult &result) = 0; -- Gitee