From fa5c9a4e8c99d0f921edf4f5f714697d7fd9c608 Mon Sep 17 00:00:00 2001 From: lizhuojun Date: Mon, 16 Dec 2024 10:29:36 +0800 Subject: [PATCH] store by slice Signed-off-by: lizhuojun --- .../service/udmf/BUILD.gn | 1 + .../service/udmf/preprocess/data_handler.cpp | 139 ++++++++++++++++++ .../service/udmf/preprocess/data_handler.h | 37 +++++ .../udmf/preprocess/preprocess_utils.cpp | 102 ++++++++----- .../udmf/preprocess/preprocess_utils.h | 4 +- .../service/udmf/store/runtime_store.cpp | 88 +++-------- .../service/udmf/udmf_service_impl.cpp | 45 +++--- .../service/udmf/udmf_service_stub.cpp | 4 - 8 files changed, 288 insertions(+), 132 deletions(-) create mode 100644 services/distributeddataservice/service/udmf/preprocess/data_handler.cpp create mode 100644 services/distributeddataservice/service/udmf/preprocess/data_handler.h diff --git a/services/distributeddataservice/service/udmf/BUILD.gn b/services/distributeddataservice/service/udmf/BUILD.gn index c791f4bfb..06f52a549 100644 --- a/services/distributeddataservice/service/udmf/BUILD.gn +++ b/services/distributeddataservice/service/udmf/BUILD.gn @@ -54,6 +54,7 @@ ohos_shared_library("udmf_server") { "permission/checker_manager.cpp", "permission/data_checker.cpp", "permission/uri_permission_manager.cpp", + "preprocess/data_handler.cpp", "preprocess/preprocess_utils.cpp", "store/runtime_store.cpp", "store/store_account_observer.cpp", diff --git a/services/distributeddataservice/service/udmf/preprocess/data_handler.cpp b/services/distributeddataservice/service/udmf/preprocess/data_handler.cpp new file mode 100644 index 000000000..cf4b13901 --- /dev/null +++ b/services/distributeddataservice/service/udmf/preprocess/data_handler.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define LOG_TAG "DataHandler" + +#include "data_handler.h" +#include "log_print.h" +#include "tlv_object.h" +#include "tlv_util.h" + +namespace OHOS::UDMF { +constexpr const char *SLICE_SEPARATOR = "-"; +constexpr const char *UD_KEY_SEPARATOR = "/"; +static constexpr size_t MAX_KV_DATA_SIZE = 4 * 1024 * 1024; + +Status DataHandler::MarshalToEntries(const UnifiedData &unifiedData, std::vector &entries) +{ + std::string unifiedKey = unifiedData.GetRuntime()->key.GetUnifiedKey(); + std::vector runtimeBytes; + auto runtimeTlv = TLVObject(runtimeBytes); + if (!TLVUtil::Writing(*unifiedData.GetRuntime(), runtimeTlv, TAG::TAG_RUNTIME)) { + ZLOGE("Marshall runtime info failed, dataPrefix: %{public}s.", unifiedKey.c_str()); + return E_WRITE_PARCEL_ERROR; + } + std::vector udKeyBytes = { unifiedKey.begin(), unifiedKey.end() }; + Entry entry = { udKeyBytes, runtimeBytes }; + entries.emplace_back(entry); + + return Split(unifiedData.GetRecords(), unifiedKey, entries); +} + +Status DataHandler::UnmarshalEntries(const std::string &key, const std::vector &entries, + UnifiedData &unifiedData) +{ + std::map>> sliceMap; + for (const auto &entry : entries) { + std::string keyStr = { entry.key.begin(), entry.key.end() }; + if (keyStr == key) { + Runtime runtime; + auto runtimeTlv = TLVObject(const_cast &>(entry.value)); + if (!TLVUtil::ReadTlv(runtime, runtimeTlv, TAG::TAG_RUNTIME)) { + ZLOGE("Unmarshall runtime info failed."); + return E_READ_PARCEL_ERROR; + } + unifiedData.SetRuntime(runtime); + continue; + } + if (keyStr.find(key) == 0) { + auto status = Assembler(entry, keyStr, sliceMap, unifiedData); + if (status != E_OK) { + return status; + } + } + } + for (auto [uid, slice] : sliceMap) { + std::vector rawData; + for (auto sliceData : slice) { + rawData.insert(rawData.end(), sliceData.begin(), sliceData.end()); + } + std::shared_ptr record; + auto recordTlv = TLVObject(rawData); + if (!TLVUtil::ReadTlv(record, recordTlv, TAG::TAG_UNIFIED_RECORD)) { + ZLOGE("Unmarshall unified record failed for slice data."); + return E_READ_PARCEL_ERROR; + } + unifiedData.AddRecord(std::move(record)); + } + return E_OK; +} + +Status DataHandler::Split(const std::vector> &records, const std::string &unifiedKey, + std::vector &entries) +{ + for (const auto &record : records) { + std::vector recordBytes; + auto recordTlv = TLVObject(recordBytes); + if (!TLVUtil::Writing(record, recordTlv, TAG::TAG_UNIFIED_RECORD)) { + ZLOGI("Marshall unified record failed."); + return E_WRITE_PARCEL_ERROR; + } + std::string recordKey = unifiedKey + UD_KEY_SEPARATOR + record->GetUid(); + auto recordSize = recordBytes.size(); + if (recordSize <= MAX_KV_DATA_SIZE) { + std::vector keyBytes = { recordKey.begin(), recordKey.end() }; + Entry entry = { keyBytes, recordBytes }; + entries.emplace_back(entry); + continue; + } + size_t offset = 0; + int sliceNum = 1; + while (offset < recordSize) { + auto chunkSize = std::min(MAX_KV_DATA_SIZE, recordSize - offset); + std::vector chunk(recordBytes.begin() + offset, recordBytes.begin() + offset + chunkSize); + std::string recordKeySplitSeq = recordKey + SLICE_SEPARATOR + std::to_string(sliceNum); + std::vector keyBytes = { recordKeySplitSeq.begin(), recordKeySplitSeq.end() }; + Entry entry = { keyBytes, chunk }; + entries.emplace_back(entry); + sliceNum++; + offset += chunkSize; + } + } + return E_OK; +} + +Status DataHandler::Assembler(const Entry &entry, const std::string &keyStr, + std::map>> &sliceMap, UnifiedData &unifiedData) +{ + auto suffixKey = keyStr.substr(keyStr.rfind(UD_KEY_SEPARATOR) + 1); + if (suffixKey.rfind(SLICE_SEPARATOR) == std::string::npos) { + std::shared_ptr record; + auto recordTlv = TLVObject(const_cast &>(entry.value)); + if (!TLVUtil::ReadTlv(record, recordTlv, TAG::TAG_UNIFIED_RECORD)) { + ZLOGE("Unmarshall unified record failed."); + return E_READ_PARCEL_ERROR; + } + unifiedData.AddRecord(std::move(record)); + return E_OK; + } + auto separatorPos = suffixKey.rfind(SLICE_SEPARATOR); + size_t sliceNum = std::stoull(suffixKey.substr(separatorPos + 1)); + std::string uid = suffixKey.substr(0, separatorPos); + if (sliceMap[uid].size() < sliceNum) { + sliceMap[uid].resize(sliceNum); + } + sliceMap[uid][sliceNum - 1] = std::move(entry.value); + return E_OK; +} +} // namespace UDMF::OHOS \ No newline at end of file diff --git a/services/distributeddataservice/service/udmf/preprocess/data_handler.h b/services/distributeddataservice/service/udmf/preprocess/data_handler.h new file mode 100644 index 000000000..07c13298a --- /dev/null +++ b/services/distributeddataservice/service/udmf/preprocess/data_handler.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef DATA_HANDLER_H +#define DATA_HANDLER_H + +#include "error_code.h" +#include "unified_data.h" +#include "types_export.h" + +namespace OHOS::UDMF { +using namespace DistributedDB; + +class DataHandler { +public: + static Status MarshalToEntries(const UnifiedData &unifiedData, std::vector &entries); + static Status UnmarshalEntries(const std::string &key, const std::vector &entries, UnifiedData &unifiedData); + +private: + static Status Split(const std::vector> &records, const std::string &unifiedKey, + std::vector &entries); + static Status Assembler(const Entry &entry, const std::string &keyStr, + std::map>> &sliceMap, UnifiedData &unifiedData); +}; +} // namespace UDMF::OHOS +#endif // DATA_HANDLER_H \ No newline at end of file diff --git a/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.cpp b/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.cpp index 17c906e03..6ec3d40b8 100644 --- a/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.cpp +++ b/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.cpp @@ -23,7 +23,6 @@ #include "bundlemgr/bundle_mgr_client_impl.h" #include "device_manager_adapter.h" #include "error_code.h" -#include "file.h" #include "ipc_skeleton.h" #include "log_print.h" #include "udmf_radar_reporter.h" @@ -153,44 +152,54 @@ void PreProcessUtils::SetRemoteData(UnifiedData &data) } ZLOGD("is remote data."); auto records = data.GetRecords(); - for (auto record : records) { - auto type = record->GetType(); - if (IsFileType(type)) { - auto file = static_cast(record.get()); - UDDetails details = file->GetDetails(); - details.insert({ "isRemote", "true" }); - file->SetDetails(details); + ProcessFileType(records, [] (std::shared_ptr obj) { + std::shared_ptr detailObj; + obj->GetValue(DETAILS, detailObj); + if (detailObj == nullptr) { + ZLOGE("Not contain details for object!"); + return false; } - } + UDDetails details = ObjectUtils::ConvertToUDDetails(detailObj); + details.insert({ "isRemote", "true" }); + obj->value_[DETAILS] = ObjectUtils::ConvertToObject(details); + return true; + }); } -bool PreProcessUtils::IsFileType(UDType udType) +bool PreProcessUtils::IsFileType(std::shared_ptr record) { - return (udType == UDType::FILE || udType == UDType::IMAGE || udType == UDType::VIDEO || udType == UDType::AUDIO - || udType == UDType::FOLDER); + if (record == nullptr) { + return false; + } + if (!std::holds_alternative>(record->GetOriginValue())) { + return false; + } + auto obj = std::get>(record->GetOriginValue()); + return obj->value_.find(ORI_URI) != obj->value_.end(); } int32_t PreProcessUtils::SetRemoteUri(uint32_t tokenId, UnifiedData &data) { std::vector uris; - for (const auto &record : data.GetRecords()) { - if (record != nullptr && IsFileType(record->GetType())) { - auto file = static_cast(record.get()); - if (file->GetUri().empty()) { - ZLOGW("Get uri empty, plase check the uri."); - continue; - } - Uri uri(file->GetUri()); - std::string scheme = uri.GetScheme(); - std::transform(scheme.begin(), scheme.end(), scheme.begin(), ::tolower); - if (uri.GetAuthority().empty() || scheme != FILE_SCHEME) { - ZLOGW("Get uri authority empty or uri scheme not equals to file."); - continue; - } - uris.push_back(file->GetUri()); + ProcessFileType(data.GetRecords(), [&uris](std::shared_ptr obj) { + std::string oriUri; + obj->GetValue(ORI_URI, oriUri); + if (oriUri.empty()) { + ZLOGW("Get uri empty, plase check the uri."); + return false; } - } + Uri uri(oriUri); + std::string scheme = uri.GetScheme(); + std::transform(scheme.begin(), scheme.end(), scheme.begin(), ::tolower); + if (uri.GetAuthority().empty() || scheme != FILE_SCHEME) { + ZLOGW("Get uri authority empty or uri scheme not equals to file."); + return false; + } + uris.push_back(oriUri); + return true; + }); if (!uris.empty()) { + ZLOGI("Read to check uri authorization"); if (!CheckUriAuthorization(uris, tokenId)) { ZLOGE("CheckUriAuthorization failed, bundleName:%{public}s, tokenId: %{public}d, uris size:%{public}zu.", data.GetRuntime()->createPackage.c_str(), tokenId, uris.size()); @@ -218,15 +227,15 @@ int32_t PreProcessUtils::GetDfsUrisFromLocal(const std::vector &uri ret, userId, uris.size()); return E_FS_ERROR; } - for (const auto &record : data.GetRecords()) { - if (record != nullptr && IsFileType(record->GetType())) { - auto file = static_cast(record.get()); - auto iter = dfsUris.find(file->GetUri()); - if (iter != dfsUris.end()) { - file->SetRemoteUri((iter->second).uriStr); - } + ProcessFileType(data.GetRecords(), [&dfsUris] (std::shared_ptr obj) { + std::string oriUri; + obj->GetValue(ORI_URI, oriUri); + auto iter = dfsUris.find(oriUri); + if (iter != dfsUris.end()) { + obj->value_[REMOTE_URI] = (iter->second).uriStr; } - } + return true; + }); return E_OK; } @@ -271,5 +280,26 @@ bool PreProcessUtils::IsNetworkingEnabled() } return true; } + +void PreProcessUtils::ProcessFileType(std::vector> records, + std::function)> callback) +{ + for (auto record : records) { + if (record == nullptr) { + continue; + } + if (!PreProcessUtils::IsFileType(record)) { + continue; + } + auto obj = std::get>(record->GetOriginValue()); + if (obj == nullptr) { + ZLOGE("ValueType is not Object, Not convert to remote uri!"); + continue; + } + if (!callback(obj)) { + continue; + } + } +} } // namespace UDMF } // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.h b/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.h index 19d749439..9d3770b65 100644 --- a/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.h +++ b/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.h @@ -35,13 +35,15 @@ public: static bool GetNativeProcessNameByToken(int tokenId, std::string &processName); static std::string GetLocalDeviceId(); static void SetRemoteData(UnifiedData &data); - static bool IsFileType(UDType udType); static int32_t SetRemoteUri(uint32_t tokenId, UnifiedData &data); static bool GetInstIndex(uint32_t tokenId, int32_t &instIndex); static bool IsNetworkingEnabled(); + static void ProcessFileType(std::vector> records, + std::function)> callback); private: static bool CheckUriAuthorization(const std::vector& uris, uint32_t tokenId); static int32_t GetDfsUrisFromLocal(const std::vector &uris, int32_t userId, UnifiedData &data); + static bool IsFileType(std::shared_ptr record); }; } // namespace UDMF } // namespace OHOS diff --git a/services/distributeddataservice/service/udmf/store/runtime_store.cpp b/services/distributeddataservice/service/udmf/store/runtime_store.cpp index 0bb3c23b9..8e50220da 100644 --- a/services/distributeddataservice/service/udmf/store/runtime_store.cpp +++ b/services/distributeddataservice/service/udmf/store/runtime_store.cpp @@ -21,10 +21,10 @@ #include #include +#include "data_handler.h" #include "log_print.h" #include "ipc_skeleton.h" -#include "file.h" -#include "udmf_conversion.h" +#include "unified_data_helper.h" #include "udmf_radar_reporter.h" #include "unified_meta.h" #include "tlv_util.h" @@ -107,33 +107,11 @@ Status RuntimeStore::Put(const UnifiedData &unifiedData) { UpdateTime(); std::vector entries; - std::string unifiedKey = unifiedData.GetRuntime()->key.GetUnifiedKey(); - // add runtime info - std::vector runtimeBytes; - auto runtimeTlv = TLVObject(runtimeBytes); - if (!TLVUtil::Writing(*unifiedData.GetRuntime(), runtimeTlv, TAG::TAG_RUNTIME)) { - ZLOGE("Marshall runtime info failed, dataPrefix: %{public}s.", unifiedKey.c_str()); - return E_WRITE_PARCEL_ERROR; - } - std::vector udKeyBytes = {unifiedKey.begin(), unifiedKey.end()}; - Entry entry = {udKeyBytes, runtimeBytes}; - entries.push_back(entry); - - // add unified record - for (const auto &record : unifiedData.GetRecords()) { - std::vector recordBytes; - auto recordTlv = TLVObject(recordBytes); - if (!TLVUtil::Writing(record, recordTlv, TAG::TAG_UNIFIED_RECORD)) { - ZLOGI("Marshall unified record failed."); - return E_WRITE_PARCEL_ERROR; - } - std::string recordKey = unifiedKey + "/" + record->GetUid(); - std::vector keyBytes = {recordKey.begin(), recordKey.end() }; - Entry entry = { keyBytes, recordBytes }; - entries.push_back(entry); + auto status = DataHandler::MarshalToEntries(unifiedData, entries); + if (status != E_OK) { + return status; } - auto status = PutEntries(entries); - return status; + return PutEntries(entries); } Status RuntimeStore::Get(const std::string &key, UnifiedData &unifiedData) @@ -148,7 +126,7 @@ Status RuntimeStore::Get(const std::string &key, UnifiedData &unifiedData) ZLOGW("entries is empty, dataPrefix: %{public}s", key.c_str()); return E_NOT_FOUND; } - return UnmarshalEntries(key, entries, unifiedData); + return DataHandler::UnmarshalEntries(key, entries, unifiedData); } bool RuntimeStore::GetDetailsFromUData(UnifiedData &data, UDDetails &details) @@ -160,11 +138,18 @@ bool RuntimeStore::GetDetailsFromUData(UnifiedData &data, UDDetails &details) if (records[0] == nullptr || records[0]->GetType() != UDType::FILE) { return false; } - auto file = static_cast(records[0].get()); - if (file == nullptr) { + auto obj = std::get>(records[0]->GetOriginValue()); + if (obj == nullptr) { + ZLOGE("ValueType is not Object!"); return false; } - auto result = file->GetDetails(); + std::shared_ptr detailObj; + obj->GetValue(DETAILS, detailObj); + if (detailObj == nullptr) { + ZLOGE("Not contain details for object!"); + return false; + } + auto result = ObjectUtils::ConvertToUDDetails(detailObj); if (result.find(TEMP_UNIFIED_DATA_FLAG) == result.end()) { return false; } @@ -200,17 +185,7 @@ Status RuntimeStore::GetSummary(const std::string &key, Summary &summary) if (GetDetailsFromUData(unifiedData, details)) { return GetSummaryFromDetails(details, summary); } - for (const auto &record : unifiedData.GetRecords()) { - int64_t recordSize = record->GetSize(); - auto udType = UtdUtils::GetUtdIdFromUtdEnum(record->GetType()); - auto it = summary.summary.find(udType); - if (it == summary.summary.end()) { - summary.summary[udType] = recordSize; - } else { - summary.summary[udType] += recordSize; - } - summary.totalSize += recordSize; - } + UnifiedDataHelper::GetSummary(unifiedData, summary); return E_OK; } @@ -382,7 +357,7 @@ Status RuntimeStore::GetBatchData(const std::string &dataPrefix, std::vector &keys) return E_OK; } -Status RuntimeStore::UnmarshalEntries(const std::string &key, std::vector &entries, UnifiedData &unifiedData) -{ - for (const auto &entry : entries) { - std::string keyStr = {entry.key.begin(), entry.key.end()}; - if (keyStr == key) { - Runtime runtime; - auto runtimeTlv = TLVObject(const_cast &>(entry.value)); - if (!TLVUtil::ReadTlv(runtime, runtimeTlv, TAG::TAG_RUNTIME)) { - ZLOGE("Unmarshall runtime info failed."); - return E_READ_PARCEL_ERROR; - } - unifiedData.SetRuntime(runtime); - } else if (keyStr.find(key) == 0) { - std::shared_ptr record; - auto recordTlv = TLVObject(const_cast &>(entry.value)); - if (!TLVUtil::ReadTlv(record, recordTlv, TAG::TAG_UNIFIED_RECORD)) { - ZLOGE("Unmarshall unified record failed."); - return E_READ_PARCEL_ERROR; - } - unifiedData.AddRecord(record); - } - } - UdmfConversion::ConvertRecordToSubclass(unifiedData); - return E_OK; -} } // namespace UDMF } // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp index 6d879155e..ac6a7aee5 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp +++ b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp @@ -25,7 +25,6 @@ #include "checker_manager.h" #include "dfx_types.h" #include "distributed_kv_data_manager.h" -#include "file.h" #include "lifecycle/lifecycle_manager.h" #include "log_print.h" #include "preprocess_utils.h" @@ -156,7 +155,6 @@ int32_t UdmfServiceImpl::SaveData(CustomOption &option, UnifiedData &unifiedData return E_DB_ERROR; } - UdmfConversion::InitValueObject(unifiedData); if (store->Put(unifiedData) != E_OK) { ZLOGE("Put unified data failed, intention: %{public}s.", intention.c_str()); return E_DB_ERROR; @@ -317,38 +315,43 @@ int32_t UdmfServiceImpl::ProcessCrossDeviceData(UnifiedData &unifiedData, std::v std::string localDeviceId = PreProcessUtils::GetLocalDeviceId(); std::string sourceDeviceId = unifiedData.GetRuntime()->deviceId; auto records = unifiedData.GetRecords(); - for (auto record : records) { - if (record == nullptr || !PreProcessUtils::IsFileType(record->GetType())) { - continue; + bool hasError = false; + PreProcessUtils::ProcessFileType(records, [&] (std::shared_ptr obj) { + if (hasError) { + return false; } - auto file = static_cast(record.get()); - if (file->GetUri().empty()) { + std::string oriUri; + obj->GetValue(ORI_URI, oriUri); + if (oriUri.empty()) { ZLOGW("Get uri is empty."); - continue; + return false; } - Uri uri(file->GetUri()); + Uri uri(oriUri); std::string scheme = uri.GetScheme(); std::transform(scheme.begin(), scheme.end(), scheme.begin(), ::tolower); - std::string remoteUri = file->GetRemoteUri(); if (localDeviceId != sourceDeviceId) { + std::string remoteUri; + obj->GetValue(REMOTE_URI, remoteUri); if (remoteUri.empty() && scheme == FILE_SCHEME) { ZLOGE("when cross devices, remote uri is required!"); - return E_ERROR; + hasError = true; + return false; } if (!remoteUri.empty()) { - file->SetUri(remoteUri); // cross dev, need dis path. + obj->value_.insert_or_assign(ORI_URI, remoteUri); // cross dev, need dis path. + uri = Uri(remoteUri); + scheme = uri.GetScheme(); + std::transform(scheme.begin(), scheme.end(), scheme.begin(), ::tolower); } } - Uri newUri(file->GetUri()); - scheme = newUri.GetScheme(); - std::transform(scheme.begin(), scheme.end(), scheme.begin(), ::tolower); - if (newUri.GetAuthority().empty() || scheme != FILE_SCHEME) { + if (uri.GetAuthority().empty() || scheme != FILE_SCHEME) { ZLOGW("Get authority is empty or uri scheme not equals to file."); - continue; + return false; } - uris.push_back(newUri); - } - return E_OK; + uris.push_back(uri); + return true; + }); + return hasError ? E_ERROR : E_OK; } int32_t UdmfServiceImpl::GetBatchData(const QueryOption &query, std::vector &unifiedDataSet) @@ -413,7 +416,6 @@ int32_t UdmfServiceImpl::UpdateData(const QueryOption &query, UnifiedData &unifi for (auto &record : unifiedData.GetRecords()) { record->SetUid(PreProcessUtils::GenerateId()); } - UdmfConversion::InitValueObject(unifiedData); if (store->Update(unifiedData) != E_OK) { ZLOGE("Update unified data failed, intention: %{public}s.", key.intention.c_str()); return E_DB_ERROR; @@ -527,7 +529,6 @@ int32_t UdmfServiceImpl::AddPrivilege(const QueryOption &query, Privilege &privi return E_DB_ERROR; } data.GetRuntime()->privileges.emplace_back(privilege); - UdmfConversion::InitValueObject(data); if (store->Update(data) != E_OK) { ZLOGE("Update unified data failed, intention: %{public}s.", key.intention.c_str()); return E_DB_ERROR; diff --git a/services/distributeddataservice/service/udmf/udmf_service_stub.cpp b/services/distributeddataservice/service/udmf/udmf_service_stub.cpp index e8224c93c..010806bf4 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_stub.cpp +++ b/services/distributeddataservice/service/udmf/udmf_service_stub.cpp @@ -63,7 +63,6 @@ int32_t UdmfServiceStub::OnSetData(MessageParcel &data, MessageParcel &reply) customOption.tokenId = token; std::string key; int32_t status = SetData(customOption, unifiedData, key); - UdmfConversion::InitValueObject(unifiedData); if (!ITypesUtil::Marshal(reply, status, key)) { ZLOGE("Marshal status or key failed, status: %{public}d, key: %{public}s", status, key.c_str()); return E_WRITE_PARCEL_ERROR; @@ -83,7 +82,6 @@ int32_t UdmfServiceStub::OnGetData(MessageParcel &data, MessageParcel &reply) query.tokenId = token; UnifiedData unifiedData; int32_t status = GetData(query, unifiedData); - UdmfConversion::InitValueObject(unifiedData); if (!ITypesUtil::Marshal(reply, status, unifiedData)) { ZLOGE("Marshal status or unifiedData failed, status: %{public}d", status); return E_WRITE_PARCEL_ERROR; @@ -103,7 +101,6 @@ int32_t UdmfServiceStub::OnGetBatchData(MessageParcel &data, MessageParcel &repl query.tokenId = token; std::vector unifiedDataSet; int32_t status = GetBatchData(query, unifiedDataSet); - UdmfConversion::InitValueObject(unifiedDataSet); if (!ITypesUtil::Marshal(reply, status, unifiedDataSet)) { ZLOGE("Marshal status or unifiedDataSet failed, status: %{public}d", status); return E_WRITE_PARCEL_ERROR; @@ -142,7 +139,6 @@ int32_t UdmfServiceStub::OnDeleteData(MessageParcel &data, MessageParcel &reply) query.tokenId = token; std::vector unifiedDataSet; int32_t status = DeleteData(query, unifiedDataSet); - UdmfConversion::InitValueObject(unifiedDataSet); if (!ITypesUtil::Marshal(reply, status, unifiedDataSet)) { ZLOGE("Marshal status or unifiedDataSet failed, status: %{public}d", status); return E_WRITE_PARCEL_ERROR; -- Gitee