From f6e8dbb6657ab5eae5741727bf11568d96f332d3 Mon Sep 17 00:00:00 2001 From: lianhuix Date: Mon, 21 Mar 2022 16:19:12 +0800 Subject: [PATCH 01/20] Fix log format Signed-off-by: lianhuix --- .../distributeddb/common/include/log_print.h | 2 + .../distributeddb/common/src/auto_launch.cpp | 41 ++++++++++--------- .../distributeddb/common/src/db_ability.cpp | 4 +- .../libs/distributeddb/common/src/parcel.cpp | 20 +++++---- .../relational/relational_schema_object.cpp | 3 +- .../common/src/schema_object.cpp | 16 ++++---- .../distributeddb/common/src/schema_utils.cpp | 2 +- .../distributeddb/common/src/value_object.cpp | 2 +- .../common/src/zlib_compression.cpp | 4 +- .../communicator/src/frame_combiner.cpp | 4 +- .../common/distributeddb_auto_launch_test.cpp | 6 +-- .../common/distributeddb_tools_unit_test.cpp | 16 ++++---- ...teddb_interfaces_space_management_test.cpp | 3 +- 13 files changed, 66 insertions(+), 57 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/common/include/log_print.h b/services/distributeddataservice/libs/distributeddb/common/include/log_print.h index 8cdffe88b..697a2986c 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/log_print.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/log_print.h @@ -16,6 +16,8 @@ #ifndef DISTRIBUTEDDB_LOG_PRINT_H #define DISTRIBUTEDDB_LOG_PRINT_H +#define __STDC_FORMAT_MACROS +#include #include #include #include diff --git a/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp b/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp index 3ad52cb03..6085a9d98 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp @@ -179,7 +179,7 @@ int AutoLaunch::EnableKvStoreAutoLaunch(const KvDBProperties &properties, AutoLa if (isDualTupleMode && !RuntimeContext::GetInstance()->IsSyncerNeedActive(userId, appId, storeId)) { std::lock_guard autoLock(dataLock_); std::string tmpIdentifier = isDualTupleMode ? dualTupleIdentifier : identifier; - LOGI("[AutoLaunch] GetDoOpenMap identifier=%0.6s no need to open", STR_TO_HEX(tmpIdentifier)); + LOGI("[AutoLaunch] GetDoOpenMap identifier=%.6s no need to open", STR_TO_HEX(tmpIdentifier)); autoLaunchItemMap_[tmpIdentifier][userId].state = AutoLaunchItemState::IDLE; return errCode; } @@ -285,7 +285,7 @@ void AutoLaunch::TryCloseConnection(AutoLaunchItem &autoLaunchItem) TryCloseRelationConnection(autoLaunchItem); break; default: - LOGD("[AutoLaunch] Unknown type[%d] when try to close connection", autoLaunchItem.type); + LOGD("[AutoLaunch] Unknown type[%d] when try to close connection", static_cast(autoLaunchItem.type)); break; } } @@ -321,7 +321,7 @@ int AutoLaunch::RegisterObserver(AutoLaunchItem &autoLaunchItem, const std::stri LOGE("[AutoLaunch] autoLaunchItem.conn is nullptr"); return -E_INTERNAL_ERROR; } - LOGI("[AutoLaunch] RegisterObserver type=%d", autoLaunchItem.type); + LOGI("[AutoLaunch] RegisterObserver type=%d", static_cast(autoLaunchItem.type)); if (autoLaunchItem.type == DBType::DB_RELATION) { RelationalStoreConnection *conn = static_cast(autoLaunchItem.conn); conn->RegisterObserverAction([autoLaunchItem](const std::string &changedDevice) { @@ -366,7 +366,7 @@ int AutoLaunch::RegisterObserver(AutoLaunchItem &autoLaunchItem, const std::stri void AutoLaunch::ObserverFunc(const KvDBCommitNotifyData ¬ifyData, const std::string &identifier, const std::string &userId) { - LOGD("[AutoLaunch] ObserverFunc identifier=%0.6s", STR_TO_HEX(identifier)); + LOGD("[AutoLaunch] ObserverFunc identifier=%.6s", STR_TO_HEX(identifier)); AutoLaunchItem autoLaunchItem; std::string appId; std::string storeId; @@ -420,7 +420,7 @@ int AutoLaunch::DisableKvStoreAutoLaunch(const std::string &normalIdentifier, co const std::string &userId) { std::string identifier = (autoLaunchItemMap_.count(normalIdentifier) == 0) ? dualTupleIdentifier : normalIdentifier; - LOGI("[AutoLaunch] DisableKvStoreAutoLaunch identifier=%0.6s", STR_TO_HEX(identifier)); + LOGI("[AutoLaunch] DisableKvStoreAutoLaunch identifier=%.6s", STR_TO_HEX(identifier)); AutoLaunchItem autoLaunchItem; { std::unique_lock autoLock(dataLock_); @@ -499,7 +499,7 @@ void AutoLaunch::CloseNotifier(const AutoLaunchItem &autoLaunchItem) void AutoLaunch::ConnectionLifeCycleCallbackTask(const std::string &identifier, const std::string &userId) { - LOGI("[AutoLaunch] ConnectionLifeCycleCallbackTask identifier=%0.6s", STR_TO_HEX(identifier)); + LOGI("[AutoLaunch] ConnectionLifeCycleCallbackTask identifier=%.6s", STR_TO_HEX(identifier)); AutoLaunchItem autoLaunchItem; { std::lock_guard autoLock(dataLock_); @@ -513,7 +513,7 @@ void AutoLaunch::ConnectionLifeCycleCallbackTask(const std::string &identifier, } if (autoLaunchItemMap_[identifier][userId].state != AutoLaunchItemState::IDLE) { LOGI("[AutoLaunch] ConnectionLifeCycleCallback state:%d is not idle, do nothing", - autoLaunchItemMap_[identifier][userId].state); + static_cast(autoLaunchItemMap_[identifier][userId].state)); return; } autoLaunchItemMap_[identifier][userId].state = AutoLaunchItemState::IN_LIFE_CYCLE_CALL_BACK; @@ -537,7 +537,7 @@ void AutoLaunch::ConnectionLifeCycleCallbackTask(const std::string &identifier, void AutoLaunch::ConnectionLifeCycleCallback(const std::string &identifier, const std::string &userId) { - LOGI("[AutoLaunch] ConnectionLifeCycleCallback identifier=%0.6s", STR_TO_HEX(identifier)); + LOGI("[AutoLaunch] ConnectionLifeCycleCallback identifier=%.6s", STR_TO_HEX(identifier)); int errCode = RuntimeContext::GetInstance()->ScheduleTask(std::bind(&AutoLaunch::ConnectionLifeCycleCallbackTask, this, identifier, userId)); if (errCode != E_OK) { @@ -601,7 +601,8 @@ void AutoLaunch::GetDoOpenMap(std::map(iter.second.state)); continue; } else if (iter.second.conn != nullptr) { LOGI("[AutoLaunch] GetDoOpenMap this item is opened"); @@ -620,7 +621,7 @@ void AutoLaunch::GetDoOpenMap(std::map> &doOpenMap) { - LOGI("[AutoLaunch] GetConnInDoOpenMap doOpenMap.size():%llu", doOpenMap.size()); + LOGI("[AutoLaunch] GetConnInDoOpenMap doOpenMap.size():%zu", doOpenMap.size()); if (doOpenMap.empty()) { return; } @@ -681,7 +682,7 @@ void AutoLaunch::UpdateGlobalMap(std::map autoLock(dataLock_); @@ -731,7 +732,7 @@ int AutoLaunch::ReceiveUnknownIdentifierCallBack(const LabelType &label, const s // normal tuple mode userId = autoLaunchItemMap_[identifier].begin()->first; } - LOGI("[AutoLaunch] ReceiveUnknownIdentifierCallBack identifier=%0.6s", STR_TO_HEX(identifier)); + LOGI("[AutoLaunch] ReceiveUnknownIdentifierCallBack identifier=%.6s", STR_TO_HEX(identifier)); int errCode; { std::lock_guard autoLock(dataLock_); @@ -746,7 +747,7 @@ int AutoLaunch::ReceiveUnknownIdentifierCallBack(const LabelType &label, const s return E_OK; } else if (autoLaunchItemMap_[identifier][userId].state != AutoLaunchItemState::IDLE) { LOGI("[AutoLaunch] ReceiveUnknownIdentifierCallBack state:%d is not idle, do nothing", - autoLaunchItemMap_[identifier][userId].state); + static_cast(autoLaunchItemMap_[identifier][userId].state)); return E_OK; } autoLaunchItemMap_[identifier][userId].state = AutoLaunchItemState::IN_COMMUNICATOR_CALL_BACK; @@ -768,7 +769,7 @@ EXT: void AutoLaunch::SetAutoLaunchRequestCallback(const AutoLaunchRequestCallback &callback, DBType type) { - LOGI("[AutoLaunch] SetAutoLaunchRequestCallback type[%d]", type); + LOGI("[AutoLaunch] SetAutoLaunchRequestCallback type[%d]", static_cast(type)); std::lock_guard lock(extLock_); if (callback) { autoLaunchRequestCallbackMap_[type] = callback; @@ -865,7 +866,7 @@ void AutoLaunch::AutoLaunchExtTask(const std::string identifier, const std::stri void AutoLaunch::ExtObserverFunc(const KvDBCommitNotifyData ¬ifyData, const std::string &identifier, const std::string &userId) { - LOGD("[AutoLaunch] ExtObserverFunc identifier=%0.6s", STR_TO_HEX(identifier)); + LOGD("[AutoLaunch] ExtObserverFunc identifier=%.6s", STR_TO_HEX(identifier)); AutoLaunchItem autoLaunchItem; AutoLaunchNotifier notifier; { @@ -907,7 +908,7 @@ void AutoLaunch::ExtObserverFunc(const KvDBCommitNotifyData ¬ifyData, const s void AutoLaunch::ExtConnectionLifeCycleCallback(const std::string &identifier, const std::string &userId) { - LOGI("[AutoLaunch] ExtConnectionLifeCycleCallback identifier=%0.6s", STR_TO_HEX(identifier)); + LOGI("[AutoLaunch] ExtConnectionLifeCycleCallback identifier=%.6s", STR_TO_HEX(identifier)); int errCode = RuntimeContext::GetInstance()->ScheduleTask(std::bind( &AutoLaunch::ExtConnectionLifeCycleCallbackTask, this, identifier, userId)); if (errCode != E_OK) { @@ -917,7 +918,7 @@ void AutoLaunch::ExtConnectionLifeCycleCallback(const std::string &identifier, c void AutoLaunch::ExtConnectionLifeCycleCallbackTask(const std::string &identifier, const std::string &userId) { - LOGI("[AutoLaunch] ExtConnectionLifeCycleCallbackTask identifier=%0.6s", STR_TO_HEX(identifier)); + LOGI("[AutoLaunch] ExtConnectionLifeCycleCallbackTask identifier=%.6s", STR_TO_HEX(identifier)); AutoLaunchItem autoLaunchItem; { std::lock_guard autoLock(extLock_); @@ -941,7 +942,7 @@ void AutoLaunch::ExtConnectionLifeCycleCallbackTask(const std::string &identifie int AutoLaunch::SetConflictNotifier(AutoLaunchItem &autoLaunchItem) { if (autoLaunchItem.type != DBType::DB_KV) { - LOGD("[AutoLaunch] Current Type[%d] Not Support ConflictNotifier Now", autoLaunchItem.type); + LOGD("[AutoLaunch] Current Type[%d] Not Support ConflictNotifier Now", static_cast(autoLaunchItem.type)); return E_OK; } @@ -1131,7 +1132,7 @@ int AutoLaunch::RegisterLifeCycleCallback(AutoLaunchItem &autoLaunchItem, const static_cast(autoLaunchItem.conn)->RegisterLifeCycleCallback(notifier); break; default: - LOGD("[AutoLaunch] Unknown Type[%d]", autoLaunchItem.type); + LOGD("[AutoLaunch] Unknown Type[%d]", static_cast(autoLaunchItem.type)); break; } return errCode; @@ -1141,7 +1142,7 @@ int AutoLaunch::PragmaAutoSync(AutoLaunchItem &autoLaunchItem) { int errCode = E_OK; if (autoLaunchItem.type != DBType::DB_KV) { - LOGD("[AutoLaunch] Current Type[%d] Not Support AutoSync Now", autoLaunchItem.type); + LOGD("[AutoLaunch] Current Type[%d] Not Support AutoSync Now", static_cast(autoLaunchItem.type)); return errCode; } diff --git a/services/distributeddataservice/libs/distributeddb/common/src/db_ability.cpp b/services/distributeddataservice/libs/distributeddb/common/src/db_ability.cpp index 87d0ca7eb..54631a3cc 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/db_ability.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/db_ability.cpp @@ -131,8 +131,8 @@ uint8_t DbAbility::GetAbilityItem(const AbilityItem &abilityType) const auto iter = dbAbilityItemSet_.find(abilityType); if (iter != dbAbilityItemSet_.end()) { if ((iter->first + iter->second) > dbAbility_.size()) { - LOGE("[DbAbility] abilityType is error, start=%d, use_bit=%d, totalLen=%d", iter->first, iter->second, - dbAbility_.size()); + LOGE("[DbAbility] abilityType is error, start=%" PRIu32 ", use_bit=%" PRIu32 ", totalLen=%zu", + iter->first, iter->second, dbAbility_.size()); return 0; } uint32_t skip = 0; diff --git a/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp b/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp index 9fedced19..d7eb4d9ee 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp @@ -164,13 +164,15 @@ int Parcel::WriteString(const std::string &inVal) uint64_t stepLen = sizeof(uint32_t) + static_cast(inVal.size()); len = HostToNet(len); if (stepLen > INT32_MAX || parcelLen_ + BYTE_8_ALIGN(stepLen) > totalLen_) { - LOGE("[WriteString] stepLen:%llu, totalLen:%llu, parcelLen:%llu", stepLen, totalLen_, parcelLen_); + LOGE("[WriteString] stepLen:%" PRIu64 ", totalLen:%" PRIu64 ", parcelLen:%" PRIu64 , stepLen, totalLen_, + parcelLen_); isError_ = true; return -E_PARSE_FAIL; } errno_t errCode = memcpy_s(bufPtr_, totalLen_ - parcelLen_, &len, sizeof(uint32_t)); if (errCode != EOK) { - LOGE("[WriteString] bufPtr:%d, totalLen:%llu, parcelLen:%llu", bufPtr_ != nullptr, totalLen_, parcelLen_); + LOGE("[WriteString] bufPtr:%d, totalLen:%" PRIu64 ", parcelLen:%" PRIu64 , bufPtr_ != nullptr, totalLen_, + parcelLen_); isError_ = true; return -E_SECUREC_ERROR; } @@ -182,7 +184,7 @@ int Parcel::WriteString(const std::string &inVal) } errCode = memcpy_s(bufPtr_, totalLen_ - parcelLen_ - sizeof(uint32_t), inVal.c_str(), inVal.size()); if (errCode != EOK) { - LOGE("[WriteString] totalLen:%llu, parcelLen:%llu, inVal.size:%zu.", + LOGE("[WriteString] totalLen:%" PRIu64 ", parcelLen:%" PRIu64 ", inVal.size:%zu.", totalLen_, parcelLen_, inVal.size()); isError_ = true; return -E_SECUREC_ERROR; @@ -199,7 +201,8 @@ uint32_t Parcel::ReadString(std::string &outVal) return 0; } if (bufPtr_ == nullptr || parcelLen_ + sizeof(uint32_t) > totalLen_) { - LOGE("[ReadString] bufPtr:%d, totalLen:%llu, parcelLen:%llu", bufPtr_ != nullptr, totalLen_, parcelLen_); + LOGE("[ReadString] bufPtr:%d, totalLen:%" PRIu64 ", parcelLen:%" PRIu64, bufPtr_ != nullptr, totalLen_, + parcelLen_); isError_ = true; return 0; } @@ -207,7 +210,8 @@ uint32_t Parcel::ReadString(std::string &outVal) len = NetToHost(len); uint64_t stepLen = static_cast(len) + sizeof(uint32_t); if (stepLen > INT32_MAX || parcelLen_ + BYTE_8_ALIGN(stepLen) > totalLen_) { - LOGE("[ReadString] stepLen:%llu, totalLen:%llu, parcelLen:%llu", stepLen, totalLen_, parcelLen_); + LOGE("[ReadString] stepLen:%" PRIu64 ", totalLen:%" PRIu64 ", parcelLen:%" PRIu64, stepLen, totalLen_, + parcelLen_); isError_ = true; return 0; } @@ -344,7 +348,7 @@ uint32_t Parcel::ReadMultiVerCommits(std::vector &commits) } if (size > DBConstant::MAX_COMMIT_SIZE) { isError_ = true; - LOGE("Parcel::ReadMultiVerCommits commits size too large: %llu", size); + LOGE("Parcel::ReadMultiVerCommits commits size too large: %" PRIu64, size); return 0; } for (uint64_t i = 0; i < size; i++) { @@ -381,7 +385,7 @@ int Parcel::WriteBlob(const char *buffer, uint32_t bufLen) return -E_PARSE_FAIL; } if (parcelLen_ + bufLen > totalLen_) { - LOGE("[WriteBlob] bufLen:%u, totalLen:%llu, parcelLen:%llu", bufLen, totalLen_, parcelLen_); + LOGE("[WriteBlob] bufLen:%" PRIu32 ", totalLen:%" PRIu64 ", parcelLen:%" PRIu64, bufLen, totalLen_, parcelLen_); isError_ = true; return -E_PARSE_FAIL; } @@ -409,7 +413,7 @@ uint32_t Parcel::ReadBlob(char *buffer, uint32_t bufLen) } uint32_t leftLen = static_cast(totalLen_ - parcelLen_); if (parcelLen_ + bufLen > totalLen_) { - LOGE("[ReadBlob] bufLen:%u, totalLen:%llu, parcelLen:%llu", bufLen, totalLen_, parcelLen_); + LOGE("[ReadBlob] bufLen:%" PRIu32 ", totalLen:%" PRIu64 ", parcelLen:%" PRIu64, bufLen, totalLen_, parcelLen_); isError_ = true; return 0; } diff --git a/services/distributeddataservice/libs/distributeddb/common/src/relational/relational_schema_object.cpp b/services/distributeddataservice/libs/distributeddb/common/src/relational/relational_schema_object.cpp index c087a3a53..3642c7fb2 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/relational/relational_schema_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/relational/relational_schema_object.cpp @@ -510,7 +510,8 @@ int GetMemberFromJsonObject(const JsonObject &inJsonObject, const std::string &f } if (fieldType != expectType) { - LOGE("[RelationalSchema][Parse] Expect %s fieldType %d but: %d.", fieldName.c_str(), expectType, fieldType); + LOGE("[RelationalSchema][Parse] Expect %s fieldType %d but: %d.", fieldName.c_str(), + static_cast(expectType), static_cast(fieldType)); return -E_SCHEMA_PARSE_FAIL; } diff --git a/services/distributeddataservice/libs/distributeddb/common/src/schema_object.cpp b/services/distributeddataservice/libs/distributeddb/common/src/schema_object.cpp index 07565295a..e8bb982d6 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/schema_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/schema_object.cpp @@ -323,7 +323,7 @@ int SchemaObject::VerifyValue(ValueSource sourceType, const RawValue &inValue) c return -E_NOT_PERMIT; } if (inValue.second <= schemaSkipSize_) { - LOGE("[Schema][Verify] Value length=%zu invalid, skipsize=%u.", inValue.second, schemaSkipSize_); + LOGE("[Schema][Verify] Value length=%" PRIu32 " invalid, skipsize=%" PRIu32, inValue.second, schemaSkipSize_); return -E_FLATBUFFER_VERIFY_FAIL; } @@ -442,8 +442,8 @@ int CheckOptionalMetaFieldCountAndType(const std::map &met } if (metaFieldPathType.size() != (SchemaConstant::SCHEMA_META_FEILD_COUNT_MIN + indexMetaFieldCount + skipSizeMetaFieldCount)) { - LOGE("[Schema][CheckMeta] Unrecognized metaField exist: total=%u, indexField=%u, skipSizeField=%u.", - metaFieldPathType.size(), indexMetaFieldCount, skipSizeMetaFieldCount); + LOGE("[Schema][CheckMeta] Unrecognized metaField exist: total=%zu, indexField=%" PRIu32 ", skipSizeField=%" + PRIu32, metaFieldPathType.size(), indexMetaFieldCount, skipSizeMetaFieldCount); return -E_SCHEMA_PARSE_FAIL; } return E_OK; @@ -791,14 +791,14 @@ int SchemaObject::CompareSchemaDefine(const SchemaObject &newSchema) const } // No matter strict or compatible mode, newSchema can't have less field than oldSchema if (defineInNewSchema.size() < defineInOldSchema.size()) { - LOGE("[Schema][CompareDefine] newSize=%u less than oldSize=%u at depth=%u.", defineInNewSchema.size(), - defineInOldSchema.size(), depth); + LOGE("[Schema][CompareDefine] newSize=%zu less than oldSize=%zu at depth=%" PRIu32, + defineInNewSchema.size(), defineInOldSchema.size(), depth); return -E_SCHEMA_UNEQUAL_INCOMPATIBLE; } if (defineInNewSchema.size() > defineInOldSchema.size()) { // Strict mode not support increase fieldDefine if (schemaMode_ == SchemaMode::STRICT) { - LOGE("[Schema][CompareDefine] newSize=%u more than oldSize=%u at depth=%u in STRICT mode.", + LOGE("[Schema][CompareDefine] newSize=%zu more than oldSize=%zu at depth=%" PRIu32 " in STRICT mode.", defineInNewSchema.size(), defineInOldSchema.size(), depth); return -E_SCHEMA_UNEQUAL_INCOMPATIBLE; } @@ -916,8 +916,8 @@ int SchemaObject::CompareSchemaDefaultValue(const SchemaAttribute &oldAttr, cons } } else if (oldAttr.type == FieldType::LEAF_FIELD_LONG) { if (oldAttr.defaultValue.longValue != newAttr.defaultValue.longValue) { - LOGE("[Schema][CompareDefault] OldDefault=%lld mismatch newDefault=%lld.", oldAttr.defaultValue.longValue, - newAttr.defaultValue.longValue); + LOGE("[Schema][CompareDefault] OldDefault=%" PRId64 " mismatch newDefault=%" PRId64 ".", + oldAttr.defaultValue.longValue, newAttr.defaultValue.longValue); return -E_SCHEMA_UNEQUAL_INCOMPATIBLE; } } else if (oldAttr.type == FieldType::LEAF_FIELD_DOUBLE) { diff --git a/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp b/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp index 802d9f6ad..cb6fbb42d 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp @@ -269,7 +269,7 @@ int SchemaUtils::TransformDefaultValue(std::string &defaultContent, SchemaAttrib break; } - LOGD("SchemaAttribute type is [%d], transfer result is [%d]", outAttr.type, errCode); + LOGD("SchemaAttribute type is [%d], transfer result is [%d]", static_cast(outAttr.type), errCode); return errCode; } diff --git a/services/distributeddataservice/libs/distributeddb/common/src/value_object.cpp b/services/distributeddataservice/libs/distributeddb/common/src/value_object.cpp index def2c810b..9a91eec91 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/value_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/value_object.cpp @@ -61,7 +61,7 @@ int ValueObject::Parse(const uint8_t *dataBegin, const uint8_t *dataEnd, uint32_ return -E_NOT_PERMIT; } if (dataBegin == nullptr || dataBegin >= dataEnd || offset >= static_cast(dataEnd - dataBegin)) { - LOGE("[Value][Parse] Data range invalid: dataEnd - dataBegin=%lld, offset=%u", + LOGE("[Value][Parse] Data range invalid: dataEnd - dataBegin=%" PRId64 ", offset=%" PRIu32, static_cast(dataEnd - dataBegin), offset); return -E_INVALID_ARGS; } diff --git a/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp b/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp index aeef6b3ea..045fc6d2d 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp @@ -35,7 +35,7 @@ int ZlibCompression::Compress(const std::vector &srcData, std::vector DBConstant::MAX_SYNC_BLOCK_SIZE || destLen > DBConstant::MAX_SYNC_BLOCK_SIZE) { - LOGE("Too long to compress, srcLen:%u, destLen:%u.", srcLen, destLen); + LOGE("Too long to compress, srcLen:%zu, destLen:%lu.", srcLen, destLen); return -E_INVALID_ARGS; } @@ -59,7 +59,7 @@ int ZlibCompression::Uncompress(const std::vector &srcData, std::vector { auto srcLen = srcData.size(); if (srcLen > DBConstant::MAX_SYNC_BLOCK_SIZE || destLen > DBConstant::MAX_SYNC_BLOCK_SIZE) { - LOGE("Too long to uncompress, srcLen:%u, destLen:%u.", srcLen, destLen); + LOGE("Too long to uncompress, srcLen:%zu, destLen:%lu.", srcLen, destLen); return -E_INVALID_ARGS; } diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/frame_combiner.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/frame_combiner.cpp index 44a7c8ab4..bbca21648 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/frame_combiner.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/frame_combiner.cpp @@ -129,7 +129,7 @@ int FrameCombiner::ContinueExistCombineWork(const uint8_t *bytes, uint32_t lengt uint32_t frameId = inPacketInfo.GetFrameId(); CombineWork &oriWork = combineWorkPool_[sourceId][frameId]; // Be care here must be reference if (!CheckPacketWithOriWork(inPacketInfo, oriWork)) { - LOGE("[Combiner][ContinueWork] Check packet fail, sourceId=%llu, frameId=%u.", ULL(sourceId), ULL(frameId)); + LOGE("[Combiner][ContinueWork] Check packet fail, sourceId=%" PRIu64 ", frameId=%" PRIu32, sourceId, frameId); return -E_COMBINE_FAIL; } @@ -138,7 +138,7 @@ int FrameCombiner::ContinueExistCombineWork(const uint8_t *bytes, uint32_t lengt int errCode = ProtocolProto::CombinePacketIntoFrame(oriWork.buffer, bytes, length, fragOffset, fragLength); if (errCode != E_OK) { // We can consider abort this work, but here we choose not to affect it - LOGE("[Combiner][ContinueWork] Combine packet fail, sourceId=%llu, frameId=%u.", ULL(sourceId), ULL(frameId)); + LOGE("[Combiner][ContinueWork] Combine packet fail, sourceId=%" PRIu64 ", frameId=%" PRIu32, sourceId, frameId); return -E_COMBINE_FAIL; } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_auto_launch_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_auto_launch_test.cpp index dfd911c58..e75c7cd63 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_auto_launch_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_auto_launch_test.cpp @@ -175,7 +175,7 @@ static void PutSyncData(const KvDBProperties &prop, const Key &key, const Value TimeStamp time; kvStore->GetMaxTimeStamp(time); time += TIME_ADD; - LOGD("time:%lld", time); + LOGD("time:%" PRIu64, time); vect.push_back({key, value, time, 0, DBCommon::TransferHashString(REMOTE_DEVICE_ID)}); EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(kvStore, vect, REMOTE_DEVICE_ID), E_OK); } @@ -350,7 +350,7 @@ HWTEST_F(DistributedDBAutoLaunchUnitTest, AutoLaunch003, TestSize.Level3) std::string identifier = DBCommon::TransferHashString(userId + "-" + appId + "-" + storeId); std::unique_lock lock(cvMutex); statusMap[identifier] = status; - LOGD("int AutoLaunch002 notifier statusMap.size():%d", statusMap.size()); + LOGD("int AutoLaunch002 notifier statusMap.size():%zu", statusMap.size()); finished = true; cv.notify_one(); }; @@ -494,7 +494,7 @@ HWTEST_F(DistributedDBAutoLaunchUnitTest, AutoLaunch005, TestSize.Level3) std::string identifier = DBCommon::TransferHashString(userId + "-" + appId + "-" + storeId); std::unique_lock lock(cvMutex); statusMap[identifier] = status; - LOGD("int AutoLaunch002 notifier statusMap.size():%d", statusMap.size()); + LOGD("int AutoLaunch002 notifier statusMap.size():%zu", statusMap.size()); finished = true; cv.notify_one(); }; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_tools_unit_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_tools_unit_test.cpp index cb4d16398..e3c5551a3 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_tools_unit_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_tools_unit_test.cpp @@ -372,13 +372,13 @@ bool DistributedDBToolsUnitTest::IsEntryEqual(const DistributedDB::Entry &entryO const DistributedDB::Entry &entryRet) { if (entryOrg.key != entryRet.key) { - LOGD("key not equal, entryOrg key size is [%d], entryRet key size is [%d]", entryOrg.key.size(), + LOGD("key not equal, entryOrg key size is [%zu], entryRet key size is [%zu]", entryOrg.key.size(), entryRet.key.size()); return false; } if (entryOrg.value != entryRet.value) { - LOGD("value not equal, entryOrg value size is [%d], entryRet value size is [%d]", entryOrg.value.size(), + LOGD("value not equal, entryOrg value size is [%zu], entryRet value size is [%zu]", entryOrg.value.size(), entryRet.value.size()); return false; } @@ -389,7 +389,7 @@ bool DistributedDBToolsUnitTest::IsEntryEqual(const DistributedDB::Entry &entryO bool DistributedDBToolsUnitTest::IsEntriesEqual(const std::vector &entriesOrg, const std::vector &entriesRet, bool needSort) { - LOGD("entriesOrg size is [%d], entriesRet size is [%d]", entriesOrg.size(), + LOGD("entriesOrg size is [%zu], entriesRet size is [%zu]", entriesOrg.size(), entriesRet.size()); if (entriesOrg.size() != entriesRet.size()) { @@ -405,11 +405,11 @@ bool DistributedDBToolsUnitTest::IsEntriesEqual(const std::vector &orgEntries, const std::list &resultLst) { - LOGD("orgEntries.size() is [%d], resultLst.size() is [%d]", orgEntries.size(), + LOGD("orgEntries.size() is [%zu], resultLst.size() is [%zu]", orgEntries.size(), resultLst.size()); if (orgEntries.size() != resultLst.size()) { @@ -537,7 +537,7 @@ int DistributedDBToolsUnitTest::ModifyDatabaseFile(const std::string &fileDir, u } else { fileSize = static_cast(pos); if (fileSize < 1024) { // the least page size is 1024 bytes. - LOGE("Invalid database file:%llu.", fileSize); + LOGE("Invalid database file:%" PRIu64 ".", fileSize); return -E_UNEXPECTED_DATA; } } @@ -674,7 +674,7 @@ void KvStoreObserverUnitTest::OnChange(const KvStoreChangedData& data) updated_ = data.GetEntriesUpdated(); deleted_ = data.GetEntriesDeleted(); isCleared_ = data.IsCleared(); - LOGD("Onchangedata :%lu -- %lu -- %lu -- %d", inserted_.size(), updated_.size(), deleted_.size(), isCleared_); + LOGD("Onchangedata :%zu -- %zu -- %zu -- %d", inserted_.size(), updated_.size(), deleted_.size(), isCleared_); LOGD("Onchange() called success!"); } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_space_management_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_space_management_test.cpp index c2de7b7ee..818c81bab 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_space_management_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_space_management_test.cpp @@ -270,7 +270,8 @@ HWTEST_F(DistributedDBInterfacesSpaceManagementTest, GetKvStoreDiskSize002, Test ASSERT_TRUE(dbSizeForCheck != singleAndMultiDbSize); dbSizeForCheck = CheckRealFileSize(g_singleVerFileNames) + CheckRealFileSize(GetMultiVerFilelist()); EXPECT_EQ(dbSizeForCheck, singleAndMultiDbSize); - LOGE("single:%lld,mul:%lld", CheckRealFileSize(g_singleVerFileNames), CheckRealFileSize(GetMultiVerFilelist())); + LOGE("single:%" PRIu64 ",mul:%" PRIu64, CheckRealFileSize(g_singleVerFileNames), + CheckRealFileSize(GetMultiVerFilelist())); /** * @tc.steps: step7. Close and Delete Db. -- Gitee From ac398a4a1909e44b7c6fac40b9a57dd63c68de1c Mon Sep 17 00:00:00 2001 From: lianhuix Date: Mon, 21 Mar 2022 21:55:35 +0800 Subject: [PATCH 02/20] Fix code reviews Signed-off-by: lianhuix --- .../libs/distributeddb/common/include/db_ability.h | 2 +- .../libs/distributeddb/common/include/macro_utils.h | 2 +- .../libs/distributeddb/common/include/schema_object.h | 4 ++-- .../libs/distributeddb/communicator/include/message.h | 2 +- .../libs/distributeddb/communicator/include/network_adapter.h | 2 +- .../distributeddb/communicator/include/object_holder_typed.h | 2 +- .../libs/distributeddb/communicator/src/communicator.cpp | 2 +- .../libs/distributeddb/communicator/src/protocol_proto.cpp | 2 +- .../distributeddataservice/libs/distributeddb/include/query.h | 2 +- .../libs/distributeddb/storage/include/kvdb_pragma.h | 2 +- .../sqlite/sqlite_single_ver_relational_storage_executor.cpp | 4 ++-- .../common/distributeddb_relational_schema_object_test.cpp | 2 +- .../distributeddb_interfaces_relational_sync_test.cpp | 2 +- .../common/storage/distributeddb_storage_encrypt_test.cpp | 1 - ...istributeddb_storage_single_ver_natural_store_testcase.cpp | 2 +- .../syncer/distributeddb_single_ver_p2p_sync_check_test.cpp | 4 ++-- .../test/common/distributeddb/include/distributed_rdb_tools.h | 2 +- .../common/distributeddb/src/distributeddb_kv_create_test.cpp | 2 +- .../src/distributeddb_nb_predicate_query_expand_test.cpp | 2 +- 19 files changed, 21 insertions(+), 22 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/common/include/db_ability.h b/services/distributeddataservice/libs/distributeddb/common/include/db_ability.h index 16c5abcb5..a1bb45eb9 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/db_ability.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/db_ability.h @@ -29,7 +29,7 @@ public: DbAbility(); DbAbility(const DbAbility &other); DbAbility& operator=(const DbAbility &other); - ~DbAbility() {}; + ~DbAbility() = default; bool operator==(const DbAbility &other) const; // translate dbAbility_ to std::vector diff --git a/services/distributeddataservice/libs/distributeddb/common/include/macro_utils.h b/services/distributeddataservice/libs/distributeddb/common/include/macro_utils.h index dc36c2faa..ec2ccd61c 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/macro_utils.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/macro_utils.h @@ -24,7 +24,7 @@ namespace DistributedDB { ClassName& operator=(ClassName &&) = delete #define DECLARE_OBJECT_TAG(ClassName) \ - virtual std::string GetObjectTag() const override; \ + std::string GetObjectTag() const override; \ constexpr static const char * const classTag = "Class-"#ClassName #define DEFINE_OBJECT_TAG_FACILITIES(ClassName) \ diff --git a/services/distributeddataservice/libs/distributeddb/common/include/schema_object.h b/services/distributeddataservice/libs/distributeddb/common/include/schema_object.h index b788def45..2cf9091a6 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/schema_object.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/schema_object.h @@ -51,7 +51,7 @@ public: SchemaObject(const SchemaObject &); SchemaObject& operator=(const SchemaObject &); #ifdef RELATIONAL_STORE - SchemaObject(const TableInfo &tableInfo); // The construct func can only be used for query. + explicit SchemaObject(const TableInfo &tableInfo); // The construct func can only be used for query. #endif // RELATIONAL_STORE // Move constructor and move assignment is not need currently @@ -145,7 +145,7 @@ private: // Choose inner-class other than friend-class to avoid forward declaration and using pointer. class FlatBufferSchema { public: - FlatBufferSchema(SchemaObject &owner) : owner_(owner) {}; + explicit FlatBufferSchema(SchemaObject &owner) : owner_(owner) {}; ~FlatBufferSchema() = default; DISABLE_COPY_ASSIGN_MOVE(FlatBufferSchema); // Copy-Constructor can not define due to Const-Ref member. Code standard require copy assignment be deleted. diff --git a/services/distributeddataservice/libs/distributeddb/communicator/include/message.h b/services/distributeddataservice/libs/distributeddb/communicator/include/message.h index 7c99c9def..416e08316 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/include/message.h +++ b/services/distributeddataservice/libs/distributeddb/communicator/include/message.h @@ -39,7 +39,7 @@ class Message { public: Message() = default; - Message(uint32_t inMsgId) + explicit Message(uint32_t inMsgId) { messageId_ = inMsgId; } diff --git a/services/distributeddataservice/libs/distributeddb/communicator/include/network_adapter.h b/services/distributeddataservice/libs/distributeddb/communicator/include/network_adapter.h index 620814acb..580e48c0d 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/include/network_adapter.h +++ b/services/distributeddataservice/libs/distributeddb/communicator/include/network_adapter.h @@ -29,7 +29,7 @@ namespace DistributedDB { class NetworkAdapter : public IAdapter { public: NetworkAdapter(); - NetworkAdapter(const std::string &inProcessLabel); + explicit NetworkAdapter(const std::string &inProcessLabel); NetworkAdapter(const std::string &inProcessLabel, const std::shared_ptr &inCommunicator); ~NetworkAdapter() override; diff --git a/services/distributeddataservice/libs/distributeddb/communicator/include/object_holder_typed.h b/services/distributeddataservice/libs/distributeddb/communicator/include/object_holder_typed.h index abb8dad9c..4156e3dc7 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/include/object_holder_typed.h +++ b/services/distributeddataservice/libs/distributeddb/communicator/include/object_holder_typed.h @@ -23,7 +23,7 @@ template class ObjectHolderTyped : public ObjectHolder { public: // Accept a heap object - ObjectHolderTyped(T *inObject) + explicit ObjectHolderTyped(T *inObject) { objectPtr_ = inObject; } diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp index 0a2161a96..4478696e4 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp @@ -103,7 +103,7 @@ int Communicator::SendMessage(const std::string &dstTarget, const Message *inMsg int Communicator::SendMessage(const std::string &dstTarget, const Message *inMsg, SendConfig &config, const OnSendEnd &onEnd) { - if (dstTarget.size() == 0 || inMsg == nullptr) { + if (dstTarget.empty() || inMsg == nullptr) { return -E_INVALID_ARGS; } std::shared_ptr extendHandle = nullptr; diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp index 93c7e14a9..a31c2689b 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp @@ -51,7 +51,7 @@ void SetFrameType(uint8_t &inPacketType, FrameType inFrameType) } FrameType GetFrameType(uint8_t inPacketType) { - uint8_t frameType = ((inPacketType & 0xF0) >> 4); // Use 0x0F to get high 4 bits + uint8_t frameType = ((inPacketType & 0xF0) >> 4); // Use 0xF0 to get high 4 bits if (frameType >= static_cast(FrameType::INVALID_MAX_FRAME_TYPE)) { return FrameType::INVALID_MAX_FRAME_TYPE; } diff --git a/services/distributeddataservice/libs/distributeddb/include/query.h b/services/distributeddataservice/libs/distributeddb/include/query.h index 5480939c3..2f01c676c 100644 --- a/services/distributeddataservice/libs/distributeddb/include/query.h +++ b/services/distributeddataservice/libs/distributeddb/include/query.h @@ -148,7 +148,7 @@ public: private: Query() = default; - Query(const std::string &tableName); + explicit Query(const std::string &tableName); DB_SYMBOL void ExecuteCompareOperation(QueryObjType operType, const std::string &field, const QueryValueType type, const FieldValue &fieldValue); diff --git a/services/distributeddataservice/libs/distributeddb/storage/include/kvdb_pragma.h b/services/distributeddataservice/libs/distributeddb/storage/include/kvdb_pragma.h index fca5abdfd..649ae2c15 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/include/kvdb_pragma.h +++ b/services/distributeddataservice/libs/distributeddb/storage/include/kvdb_pragma.h @@ -87,7 +87,7 @@ struct PragmaSync { }; struct PragmaRemotePushNotify { - PragmaRemotePushNotify(RemotePushFinishedNotifier notifier) : notifier_(notifier) {} + explicit PragmaRemotePushNotify(RemotePushFinishedNotifier notifier) : notifier_(notifier) {} RemotePushFinishedNotifier notifier_; }; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp index 3ca30a82b..22a8f3f35 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp @@ -204,7 +204,7 @@ std::map GetChangedIndexes(const TableInfo &oldTab itOld++; itNew++; } else if (itOld->first < itNew->first) { - indexes.insert({itOld->first,{}}); + indexes.insert({itOld->first, {}}); itOld++; } else if (itOld->first > itNew->first) { indexes.insert({itNew->first, itNew->second}); @@ -213,7 +213,7 @@ std::map GetChangedIndexes(const TableInfo &oldTab } while (itOld != itOldEnd) { - indexes.insert({itOld->first,{}}); + indexes.insert({itOld->first, {}}); itOld++; } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_relational_schema_object_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_relational_schema_object_test.cpp index d71962ed1..2192f0688 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_relational_schema_object_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_relational_schema_object_test.cpp @@ -186,7 +186,7 @@ class DistributedDBRelationalSchemaObjectTest : public testing::Test { public: static void SetUpTestCase(void) {}; static void TearDownTestCase(void) {}; - void SetUp() override ; + void SetUp() override; void TearDown() override {}; }; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_relational_sync_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_relational_sync_test.cpp index 6ca71a9a4..dda185f9a 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_relational_sync_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_relational_sync_test.cpp @@ -58,7 +58,7 @@ class DistributedDBInterfacesRelationalSyncTest : public testing::Test { public: static void SetUpTestCase(void); static void TearDownTestCase(void); - void SetUp() override ; + void SetUp() override; void TearDown() override; protected: sqlite3 *db = nullptr; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_encrypt_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_encrypt_test.cpp index 8b3a0b7e4..ca927e8b6 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_encrypt_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_encrypt_test.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include "db_types.h" #include "log_print.h" diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp index bdaf46efb..889ffe032 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp @@ -1146,7 +1146,7 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::DeleteUserKeyValue003(SQ DataItem dataItem1; dataItem1.key = KV_ENTRY_1.key; dataItem1.value = KV_ENTRY_3.value; - dataItem1.timeStamp= timeStamp - 100UL; // less than current timeStamp + dataItem1.timeStamp = timeStamp - 100UL; // less than current timeStamp dataItem1.writeTimeStamp = dataItem1.timeStamp; dataItem1.flag = 0; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp index b869131ec..8e050440f 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp @@ -526,7 +526,7 @@ void RegOnDispatchWithOffline(bool &offlineFlag, bool &invalid, condition_variab offlineFlag = true; conditionOffline.notify_all(); LOGW("[Dispatch] NOTIFY OFFLINE"); - std::this_thread::sleep_for(std::chrono::microseconds (EIGHT_HUNDRED)); + std::this_thread::sleep_for(std::chrono::microseconds(EIGHT_HUNDRED)); } } else if (!invalid && inMsg->GetMessageType() == TYPE_REQUEST) { LOGW("[Dispatch] NOW INVALID THIS MSG"); @@ -1002,7 +1002,7 @@ HWTEST_F(DistributedDBSingleVerP2PSyncCheckTest, SyncMergeCheck005, TestSize.Lev * @tc.steps: step2. deviceA call sync and don't wait * @tc.expected: step2. sync should return TIME_OUT. */ - status =g_kvDelegatePtr->Sync(devices, SYNC_MODE_PUSH_ONLY, + status = g_kvDelegatePtr->Sync(devices, SYNC_MODE_PUSH_ONLY, [&sendRequestCount, devices, this](const std::map& statusMap) { ASSERT_TRUE(statusMap.size() == devices.size()); for (const auto &deviceId : devices) { diff --git a/services/distributeddataservice/test/common/distributeddb/include/distributed_rdb_tools.h b/services/distributeddataservice/test/common/distributeddb/include/distributed_rdb_tools.h index 45b007bd6..95b15b9d3 100644 --- a/services/distributeddataservice/test/common/distributeddb/include/distributed_rdb_tools.h +++ b/services/distributeddataservice/test/common/distributeddb/include/distributed_rdb_tools.h @@ -44,7 +44,7 @@ const static std::string NON_EXISTENT_PATH = "/data/test/nonExistent_rdb/"; const static std::string UNREADABLE_PATH = "/data/test/unreadable_rdb/"; const static std::string UNWRITABLE_PATH = "/data/test/unwritable_rdb/"; -const static std::string NULL_STOREID = ""; +const static std::string NULL_STOREID = {}; const static std::string ILLEGAL_STOREID = "rdb_$%#@~%"; const static std::string MODE_STOREID = "rdb_mode"; const static std::string FULL_STOREID = "rdb_full"; diff --git a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_kv_create_test.cpp b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_kv_create_test.cpp index c2ef56631..68418f442 100644 --- a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_kv_create_test.cpp +++ b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_kv_create_test.cpp @@ -1939,7 +1939,7 @@ HWTEST_F(DistributeddbKvCreateTest, MergeRepeat001, TestSize.Level2) vector entriesBatch; vector allKeys; DistributedDB::Entry entry; - int putCount=0; + int putCount = 0; entry.value.assign(TWO_M_LONG_STRING, 'v'); GenerateTenThousandRecords(OPER_CNT_END, DEFAULT_START, allKeys, entriesBatch); for (vector::iterator iter = entriesBatch.begin(); iter != entriesBatch.end(); iter++) { diff --git a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp index 8c39c277b..d5301b6e9 100644 --- a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp +++ b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp @@ -568,7 +568,7 @@ HWTEST_F(DistributeddbNbPredicateQueryExpandTest, NotNullTest003, TestSize.Level * and check the query use GetEntries(query, Entries), GetEntries(query, resultSet), GetCount(). * @tc.expected: step6. query success but the GetEntries will return INVALID_QUERY_FORMAT. */ - Query query5= Query::Select().IsNotNull(".field2.field3"); + Query query5 = Query::Select().IsNotNull(".field2.field3"); EXPECT_TRUE(DistributedDBSchemaTestTools::CombinationCheckQueryResult(*g_nbQueryDelegate, query5, entriesExpect, DBStatus::INVALID_QUERY_FORMAT, true)); } -- Gitee From 302bca68a9de7be84647a835f858dc8f712d5583 Mon Sep 17 00:00:00 2001 From: lianhuix Date: Tue, 22 Mar 2022 20:16:36 +0800 Subject: [PATCH 03/20] Fix code reviews Signed-off-by: lianhuix --- .../libs/distributeddb/syncer/src/sync_engine.cpp | 1 + .../test/unittest/common/communicator/adapter_stub.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp index 8f5ac620a..4b4821e9d 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp @@ -140,6 +140,7 @@ int SyncEngine::Close() if (inMsg != nullptr) { queueCacheSize_ -= GetMsgSize(inMsg); delete inMsg; + inMsg = nullptr; } } // close db, rekey or import scene, need clear all remote query info diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/adapter_stub.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/adapter_stub.cpp index dbc76c0b0..6304efdd2 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/adapter_stub.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/adapter_stub.cpp @@ -54,6 +54,7 @@ uint32_t AdapterStub::GetMtuSize() uint32_t AdapterStub::GetMtuSize(const std::string &target) { + (void)target; return GetMtuSize(); } @@ -64,7 +65,7 @@ uint32_t AdapterStub::GetTimeout() uint32_t AdapterStub::GetTimeout(const std::string &target) { - (void) target; + (void)target; return GetTimeout(); } @@ -129,7 +130,7 @@ int AdapterStub::RegSendableCallback(const SendableCallback &onSendable, const F bool AdapterStub::IsDeviceOnline(const std::string &device) { - (void) device; + (void)device; return true; } -- Gitee From a247c365d7b3e28588135162a9b0f12ee48e5b46 Mon Sep 17 00:00:00 2001 From: lidwchn Date: Mon, 21 Mar 2022 19:26:04 +0800 Subject: [PATCH 04/20] Fix log format. Signed-off-by: lidwchn --- .../storage/src/data_transformer.cpp | 2 +- .../distributeddb/storage/src/kvdb_manager.cpp | 2 +- .../src/multiver/multi_ver_natural_store.cpp | 4 ---- .../multi_ver_natural_store_commit_storage.cpp | 2 +- .../src/multiver/multi_ver_storage_executor.cpp | 10 +++++----- .../storage/src/multiver/multi_ver_vacuum.cpp | 16 ++++++++-------- .../storage/src/sqlite/query_object.cpp | 6 ++++-- .../src/sqlite/sqlite_multi_ver_transaction.cpp | 10 +++++----- .../sqlite/sqlite_single_ver_natural_store.cpp | 14 +++++++------- ...qlite_single_ver_natural_store_connection.cpp | 4 ++-- ...te_single_ver_relational_storage_executor.cpp | 6 +++--- .../src/sqlite/sqlite_single_ver_result_set.cpp | 6 +++--- .../sqlite/sqlite_single_ver_storage_engine.cpp | 13 +++++++------ .../sqlite_single_ver_storage_executor.cpp | 6 ++++-- .../sqlite_single_ver_storage_executor_cache.cpp | 16 ++++++++-------- ...ite_single_ver_storage_executor_subscribe.cpp | 5 +++-- .../distributeddb/storage/src/storage_engine.cpp | 16 +++++++++------- .../distributeddb_interfaces_database_test.cpp | 1 - ...ributeddb_storage_single_ver_upgrade_test.cpp | 1 - ...istributeddb_storage_subscribe_query_test.cpp | 2 +- ...stributeddb_storage_transaction_data_test.cpp | 6 +++--- ...tributeddb_single_ver_p2p_sync_check_test.cpp | 1 - 22 files changed, 75 insertions(+), 74 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.cpp index a019cbda9..70f8d33c2 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.cpp @@ -261,7 +261,7 @@ int SerializeDataValue(const DataValue &dataValue, Parcel &parcel) StorageType type = dataValue.GetType(); parcel.WriteUInt32(static_cast(type)); if (type < StorageType::STORAGE_TYPE_NULL || type > StorageType::STORAGE_TYPE_BLOB) { - LOGE("Cannot serialize %u", type); + LOGE("Cannot serialize %u", static_cast(type)); return -E_NOT_SUPPORT; } return funcs[static_cast(type) - 1](dataValue, parcel); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_manager.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_manager.cpp index b6b589db4..49603ad0c 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_manager.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_manager.cpp @@ -442,7 +442,7 @@ int KvDBManager::CalculateKvStoreSize(const KvDBProperties &properties, uint64_t if (innerErrCode != E_OK && innerErrCode != -E_NOT_FOUND) { return innerErrCode; } - LOGD("DB type [%d], size[%llu]", kvDbType, dbSize); + LOGD("DB type [%u], size[%" PRIu64 "]", static_cast(kvDbType), dbSize); totalSize = totalSize + dbSize; } // This represent Db file size(Unit is byte), It is small than max size(max uint64_t represent 2^64B) diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp index a492db363..709724567 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp @@ -423,10 +423,6 @@ int MultiVerNaturalStore::Open(const KvDBProperties &kvDBProp) } multiVerEngine_ = std::make_unique(); - if (multiVerEngine_ == nullptr) { - errCode = -E_OUT_OF_MEMORY; - goto ERROR; - } errCode = multiVerEngine_->InitDatabases(this, multiVerData_, commitHistory_, multiVerKvStorage_, poolSize); if (errCode != E_OK) { goto ERROR; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp index 85f76b10e..abc5cd470 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp @@ -706,7 +706,7 @@ int MultiVerNaturalStoreCommitStorage::TransferValueToCommit(const Value &value, { size_t valueLength = value.size(); if (valueLength == 0 || valueLength >= MAX_COMMIT_ST_LENGTH) { - LOGE("Failed to transfer value to commit struct! invalid value length:%ul.", valueLength); + LOGE("Failed to transfer value to commit struct! invalid value length:%zu.", valueLength); return -E_UNEXPECTED_DATA; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp index 6f52d8e30..65d7ed518 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp @@ -409,7 +409,7 @@ int MultiVerStorageExecutor::ReInitTransactionVersion(const MultiVerCommitNode & errCode = E_OK; } } else { - LOGD("Reput the version:%llu", readCommit->GetCommitVersion()); + LOGD("Reput the version:%" PRIu64 "", readCommit->GetCommitVersion()); transaction_->SetVersion(readCommit->GetCommitVersion()); commitStorage_->ReleaseCommit(readCommit); } @@ -559,7 +559,7 @@ int MultiVerStorageExecutor::MergeCommits(const std::vector } if (item.deviceInfo.size() == MULTI_VER_TAG_SIZE || item.deviceInfo.compare(0, SHA256_DIGEST_LENGTH, rootNodeDeviceInfo, 0, SHA256_DIGEST_LENGTH) != 0) { - LOGD("Skip the version:%llu", item.version); + LOGD("Skip the version:%" PRIu64 "", item.version); continue; } errCode = MergeOneCommit(item); @@ -871,7 +871,7 @@ int MultiVerStorageExecutor::CommitTransaction(MultiTransactionType type) dataStorage_->RollbackWritePhaseOne(transaction_, commitVersion); goto END; } - LOGD("local commit version:%llu", commitVersion); + LOGD("local commit version:%" PRIu64 "", commitVersion); static_cast(kvDB_)->SetMaxTimeStamp(multiVerTimeStamp.timestamp); dataStorage_->CommitWritePhaseTwo(transaction_); static_cast(kvDB_)->SetMaxCommitVersion(commitVersion); @@ -1107,7 +1107,7 @@ int MultiVerStorageExecutor::GetResolvedConflictEntries(const MultiVerCommitNode entries.clear(); entries.shrink_to_fit(); Version version = commit->GetCommitVersion(); - LOGD("Version is %llu", version); + LOGD("Version is %" PRIu64 "", version); if (transaction_ != nullptr) { errCode = transaction_->GetEntriesByVersion(version, entries); if (errCode != E_OK) { @@ -1318,7 +1318,7 @@ int MultiVerStorageExecutor::CommitTransaction(const MultiVerCommitNode &multiVe dataStorage_->CommitWritePhaseTwo(transaction_); static_cast(kvDB_)->SetMaxTimeStamp(multiVerTimeStamp.timestamp); static_cast(kvDB_)->SetMaxCommitVersion(commitVersion); - LOGD("sync commit version:%llu", commitVersion); + LOGD("sync commit version:%" PRIu64 "", commitVersion); END: dataStorage_->ReleaseTransaction(transaction_); transaction_ = nullptr; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp index e5b63ee42..791bc7e16 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp @@ -356,8 +356,8 @@ int MultiVerVacuum::DealWithLeftBranchVacuumNeedRecord(VacuumTaskContext &inTask // No other thread will access handle, node and record field of a RUN_NING, PAUSE_WAIT, ABORT_WAIT status task // So it is concurrency safe to access or change these field without protection of lockguard const MultiVerRecordInfo &record = inTask.vacuumNeedRecords.front(); - LOGD("[Vacuum][DealLeftRecord] Type=%d, Version=%llu, HashKey=%s.", record.type, ULL(record.version), - VEC_TO_STR(record.hashKey)); + LOGD("[Vacuum][DealLeftRecord] Type=%u, Version=%llu, HashKey=%s.", static_cast(record.type), + ULL(record.version), VEC_TO_STR(record.hashKey)); if (inTask.shadowRecords.empty()) { if (record.type == RecordType::CLEAR) { errCode = inTask.databaseHandle->GetShadowRecordsOfClearTypeRecord(record.version, record.hashKey, @@ -368,7 +368,7 @@ int MultiVerVacuum::DealWithLeftBranchVacuumNeedRecord(VacuumTaskContext &inTask } if (errCode != E_OK) { LOGE("[Vacuum][DealLeftRecord] GetShadowRecords fail, Type=%d, Version=%llu, HashKey=%s, errCode=%d.", - record.type, ULL(record.version), VEC_TO_STR(record.hashKey), errCode); + static_cast(record.type), ULL(record.version), VEC_TO_STR(record.hashKey), errCode); DoRollBackAndFinish(inTask); return errCode; } @@ -391,7 +391,7 @@ int MultiVerVacuum::DealWithLeftBranchVacuumNeedRecord(VacuumTaskContext &inTask errCode = inTask.databaseHandle->MarkRecordAsVacuumDone(record.version, record.hashKey); if (errCode != E_OK) { LOGE("[Vacuum][DealLeftRecord] MarkRecordAsVacuumDone fail, Type=%d, Version=%llu, HashKey=%s, errCode=%d.", - record.type, ULL(record.version), VEC_TO_STR(record.hashKey), errCode); + static_cast(record.type), ULL(record.version), VEC_TO_STR(record.hashKey), errCode); DoRollBackAndFinish(inTask); return errCode; } @@ -477,8 +477,8 @@ int MultiVerVacuum::DoDeleteRecordOfLeftShadowOrRightVacuumNeed(VacuumTaskContex // No other thread will access handle, node and record field of a RUN_NING, PAUSE_WAIT, ABORT_WAIT status task // So it is concurrency safe to access or change these field without protection of lockguard const MultiVerRecordInfo &record = recordList.front(); - LOGD("[Vacuum][DoDeleteRecord] Type=%d, Version=%llu, HashKey=%s.", record.type, ULL(record.version), - VEC_TO_STR(record.hashKey)); + LOGD("[Vacuum][DoDeleteRecord] Type=%u, Version=%llu, HashKey=%s.", static_cast(record.type), + ULL(record.version), VEC_TO_STR(record.hashKey)); errCode = StartTransactionIfNotYet(inTask); if (errCode != E_OK) { std::lock_guard vacuumTaskLockGuard(vacuumTaskMutex_); @@ -487,8 +487,8 @@ int MultiVerVacuum::DoDeleteRecordOfLeftShadowOrRightVacuumNeed(VacuumTaskContex } errCode = inTask.databaseHandle->DeleteRecordTotally(record.version, record.hashKey); if (errCode != E_OK) { - LOGE("[Vacuum][DoDeleteRecord] DeleteRecordTotally fail, Type=%d, Version=%llu, HashKey=%s, errCode=%d.", - record.type, ULL(record.version), VEC_TO_STR(record.hashKey), errCode); + LOGE("[Vacuum][DoDeleteRecord] DeleteRecordTotally fail, Type=%u, Version=%llu, HashKey=%s, errCode=%d.", + static_cast(record.type), ULL(record.version), VEC_TO_STR(record.hashKey), errCode); DoRollBackAndFinish(inTask); return errCode; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp index 55c749d27..4f4747555 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp @@ -302,7 +302,8 @@ int QueryObject::CheckEqualFormat(const std::list::iterator &iter) FieldType schemaFieldType = FieldType::LEAF_FIELD_BOOL; errCode = schema_.CheckQueryableAndGetFieldType(fieldPath, schemaFieldType); if (errCode != E_OK) { - LOGE("Get field type fail when check compare format! errCode = %d, fieldType = %d", errCode, schemaFieldType); + LOGE("Get field type fail when check compare format! errCode = %d, fieldType = %u", + errCode, static_cast(schemaFieldType)); return -E_INVALID_QUERY_FIELD; } @@ -343,7 +344,8 @@ int QueryObject::CheckLinkerFormat(const std::list::iterator &iter } SymbolType symbolType = SqliteQueryHelper::GetSymbolType(nextIter->operFlag); if (symbolType == INVALID_SYMBOL || symbolType == LINK_SYMBOL || symbolType == SPECIAL_SYMBOL) { - LOGE("Must be followed by comparison operation! operflag[%d], symbolType[%d]", nextIter->operFlag, symbolType); + LOGE("Must be followed by comparison operation! operflag[%u], symbolType[%u]", + static_cast(nextIter->operFlag), static_cast(symbolType)); return -E_INVALID_QUERY_FORMAT; } return CheckLinkerBefore(iter); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp index 53712b1e8..ffb0ccb2c 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp @@ -364,7 +364,7 @@ int SQLiteMultiVerTransaction::CheckToSaveRecord(const MultiVerKvEntry *entry, b (static_cast(entry))->GetOperFlag(operFlag); entry->GetTimestamp(timestamp); if ((operFlag & OPERATE_MASK) == CLEAR_FLAG && version_ != 0) { - LOGD("Erase one version:%llu ", version_); + LOGD("Erase one version:%" PRIu64 "", version_); errCode = GetPrePutValues(version_, timestamp, values); if (errCode != E_OK) { return errCode; @@ -792,7 +792,7 @@ int SQLiteMultiVerTransaction::UpdateTimestampByVersion(const Version &version, if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_DONE)) { errCode = E_OK; currentMaxTimestamp_ = (stamp > currentMaxTimestamp_) ? stamp : currentMaxTimestamp_; - LOGD("Update the timestamp of version:%llu - %llu", version, stamp); + LOGD("Update the timestamp of version:%" PRIu64 " - %" PRIu64 "", version, stamp); } else { LOGE("Failed to update the timestamp of the version:%d", errCode); } @@ -1079,7 +1079,7 @@ int SQLiteMultiVerTransaction::AddRecord(const Key &key, const Value &value, dataCopy.timestamp = currentMaxTimestamp_++; if ((dataCopy.operFlag & LOCAL_FLAG) != 0) { dataCopy.oriTimestamp = currentMaxTimestamp_; - LOGD("Origin timestamp:%llu", currentMaxTimestamp_); + LOGD("Origin timestamp:%" PRIu64 "", currentMaxTimestamp_); } } @@ -1404,8 +1404,8 @@ int SQLiteMultiVerTransaction::CheckIfNeedSaveRecord(sqlite3_stmt *statement, co static_cast(multiVerKvEntry)->GetOriTimestamp(oriTimestamp); // Only the latest origin time is same or the reading time is bigger than putting time. isNeedSave = ((readTime < timestamp) && (readOriTime != oriTimestamp || value != origVal)); - LOGD("Timestamp :%llu vs %llu, %llu vs %llu, readVersion:%llu, version:%llu, %d", - readOriTime, oriTimestamp, readTime, timestamp, readVersion, version_, isNeedSave); + LOGD("Timestamp :%" PRIu64 " vs %" PRIu64 ", %" PRIu64 " vs %" PRIu64 ", readVersion:%" PRIu64 ", version:" + "%" PRIu64 ", %d", readOriTime, oriTimestamp, readTime, timestamp, readVersion, version_, isNeedSave); // if the version of the data to be saved is same to the original, you should notify the caller. if (readVersion != version_) { origVal.resize(0); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp index 58f1811f8..3f4c0b9cb 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp @@ -770,8 +770,8 @@ int SQLiteSingleVerNaturalStore::GetSyncDataForQuerySync(std::vector & // Get query data. if (!continueStmtToken->IsGetQueryDataFinished()) { - LOGD("[SingleVerNStore] Get query data between %llu and %llu.", continueStmtToken->GetQueryBeginTime(), - continueStmtToken->GetQueryEndTime()); + LOGD("[SingleVerNStore] Get query data between %" PRIu64 " and %" PRIu64 ".", + continueStmtToken->GetQueryBeginTime(), continueStmtToken->GetQueryEndTime()); errCode = handle->GetSyncDataWithQuery(continueStmtToken->GetQuery(), GetAppendedLen(), dataSizeInfo, std::make_pair(continueStmtToken->GetQueryBeginTime(), continueStmtToken->GetQueryEndTime()), dataItems); } @@ -784,7 +784,7 @@ int SQLiteSingleVerNaturalStore::GetSyncDataForQuerySync(std::vector & errCode = -E_UNFINISHED; // Get delete time next. if (CanHoldDeletedData(dataItems, dataSizeInfo, GetAppendedLen())) { - LOGD("[SingleVerNStore] Get deleted data between %llu and %llu.", + LOGD("[SingleVerNStore] Get deleted data between %" PRIu64 " and %" PRIu64 ".", continueStmtToken->GetDeletedBeginTime(), continueStmtToken->GetDeletedEndTime()); errCode = handle->GetDeletedSyncDataByTimestamp(dataItems, GetAppendedLen(), continueStmtToken->GetDeletedBeginTime(), continueStmtToken->GetDeletedEndTime(), dataSizeInfo); @@ -956,7 +956,7 @@ int SQLiteSingleVerNaturalStore::RemoveDeviceData(const std::string &deviceName, uint64_t logFileSize = handle->GetLogFileSize(); ReleaseHandle(handle); if (logFileSize > GetMaxLogSize()) { - LOGW("[SingleVerNStore] RmDevData log size[%llu] over the limit", logFileSize); + LOGW("[SingleVerNStore] RmDevData log size[%" PRIu64 "] over the limit", logFileSize); return -E_LOG_OVER_LIMITS; } @@ -988,7 +988,7 @@ int SQLiteSingleVerNaturalStore::RemoveDeviceDataInCacheMode(const std::string & return errCode; } uint64_t recordVersion = GetAndIncreaseCacheRecordVersion(); - LOGI("Remove device data in cache mode isNeedNotify : %d, recordVersion : %d", isNeedNotify, recordVersion); + LOGI("Remove device data in cache mode isNeedNotify:%d, recordVersion:%" PRIu64 "", isNeedNotify, recordVersion); errCode = handle->RemoveDeviceDataInCacheMode(deviceName, isNeedNotify, recordVersion); if (errCode != E_OK) { LOGE("[SingleVerNStore] RemoveDeviceDataInCacheMode failed:%d", errCode); @@ -1159,7 +1159,7 @@ void SQLiteSingleVerNaturalStore::InitCurrentMaxStamp() } handle->InitCurrentMaxStamp(currentMaxTimeStamp_); - LOGD("Init max timestamp:%llu", currentMaxTimeStamp_); + LOGD("Init max timestamp:%" PRIu64 "", currentMaxTimeStamp_); ReleaseHandle(handle); } @@ -2251,7 +2251,7 @@ int SQLiteSingleVerNaturalStore::RemoveSubscribe(const std::string &subscribeId) int SQLiteSingleVerNaturalStore::SetMaxLogSize(uint64_t limit) { - LOGI("Set the max log size to %llu", limit); + LOGI("Set the max log size to %" PRIu64 "", limit); maxLogSize_.store(limit); return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp index 5d014b010..53b39705b 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp @@ -1015,7 +1015,7 @@ int SQLiteSingleVerNaturalStoreConnection::SaveLocalEntry(const Entry &entry, bo dataItem.flag = DataItem::DELETE_FLAG; } dataItem.timeStamp = naturalStore->GetCurrentTimeStamp(); - LOGD("TimeStamp is %llu", dataItem.timeStamp); + LOGD("TimeStamp is %" PRIu64 "", dataItem.timeStamp); if (IsCacheDBMode()) { return SaveLocalItemInCacheMode(dataItem); @@ -1750,7 +1750,7 @@ bool SQLiteSingleVerNaturalStoreConnection::CheckLogOverLimit(SQLiteSingleVerSto uint64_t logFileSize = executor->GetLogFileSize(); bool result = logFileSize > naturalStore->GetMaxLogSize(); if (result) { - LOGW("Log size[%llu] over the limit", logFileSize); + LOGW("Log size[%" PRIu64 "] over the limit", logFileSize); } return result; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp index 22a8f3f35..cf008c14b 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp @@ -280,7 +280,7 @@ int SQLiteSingleVerRelationalStorageExecutor::AlterAuxTableForUpgrade(const Tabl return errCode; } - LOGD("Begin to alter table: upgrade fields[%d], indexces[%d], deviceTable[%d]", upgradeFields.size(), + LOGD("Begin to alter table: upgrade fields[%zu], indexces[%zu], deviceTable[%zu]", upgradeFields.size(), upgradeIndexces.size(), deviceTables.size()); errCode = UpgradeFields(dbHandle_, deviceTables, upgradeFields); if (errCode != E_OK) { @@ -763,7 +763,7 @@ int SQLiteSingleVerRelationalStorageExecutor::SaveSyncDataItem(const DataItem &d const auto &fieldData = data.optionalData[cid]; errCode = BindDataValueByType(saveDataStmt, fieldData, cid + 1); if (errCode != E_OK) { - LOGE("Bind data failed, errCode:%d, cid:%d.", errCode, cid + 1); + LOGE("Bind data failed, errCode:%d, cid:%zu.", errCode, cid + 1); return errCode; } } @@ -1122,7 +1122,7 @@ int SQLiteSingleVerRelationalStorageExecutor::DeleteDistributedDeviceTable(const return errCode; } - LOGD("Begin to delete device table: deviceTable[%d]", deviceTables.size()); + LOGD("Begin to delete device table: deviceTable[%zu]", deviceTables.size()); for (const auto &table : deviceTables) { std::string deleteSql = "DROP TABLE IF EXISTS " + table + ";"; // drop the found table errCode = SQLiteUtils::ExecuteRawSQL(dbHandle_, deleteSql); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp index b24863a85..6f77bb141 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp @@ -95,7 +95,7 @@ int SQLiteSingleVerResultSet::OpenForCacheFullEntryMode(bool isMemDb) } count_ = window_->GetTotalCount(); isOpen_ = true; - LOGD("[SqlSinResSet][OpenForEntry] Type=%d, CacheMaxSize=%d(MB), Count=%d, IsMem=%d.", type_, + LOGD("[SqlSinResSet][OpenForEntry] Type=%d, CacheMaxSize=%d(MB), Count=%d, IsMem=%d.", static_cast(type_), option_.cacheMaxSize, count_, isMemDb); return E_OK; } @@ -126,7 +126,7 @@ int SQLiteSingleVerResultSet::OpenForCacheEntryIdMode() cacheStartPosition_ = 0; } isOpen_ = true; - LOGD("[SqlSinResSet][OpenForRowId] Type=%d, CacheMaxSize=%d(MB), Count=%d, Cached=%zu.", type_, + LOGD("[SqlSinResSet][OpenForRowId] Type=%d, CacheMaxSize=%d(MB), Count=%d, Cached=%zu.", static_cast(type_), option_.cacheMaxSize, count_, cachedRowIds_.size()); return E_OK; } @@ -279,7 +279,7 @@ void SQLiteSingleVerResultSet::Close() isOpen_ = false; count_ = 0; position_ = INIT_POSTION; - LOGD("[SqlSinResSet][Close] Done, Type=%d, Mode=%d.", type_, option_.cacheMode); + LOGD("[SqlSinResSet][Close] Done, Type=%d, Mode=%d.", static_cast(type_), static_cast(option_.cacheMode)); } void SQLiteSingleVerResultSet::CloseForCacheFullEntryMode() diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp index 85714b270..f999cdb5f 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp @@ -155,7 +155,8 @@ int SQLiteSingleVerStorageEngine::MigrateSyncDataByVersion(SQLiteSingleVerStorag } // next version need process - LOGD("MigrateVer[%llu], minVer[%llu] maxVer[%llu]", curMigrateVer, minVerIncurCacheDb, GetCacheRecordVersion()); + LOGD("MigrateVer[%" PRIu64 "], minVer[%" PRIu64 "] maxVer[%" PRIu64 "]", + curMigrateVer, minVerIncurCacheDb, GetCacheRecordVersion()); errCode = handle->MigrateSyncDataByVersion(curMigrateVer++, syncData, dataItems); if (errCode != E_OK) { LOGE("Migrate sync data fail and rollback, errCode = [%d]", errCode); @@ -238,7 +239,7 @@ int SQLiteSingleVerStorageEngine::MigrateSyncData(SQLiteSingleVerStorageExecutor } } - LOGD("Begin migrate sync data, need migrate version[%llu]", GetCacheRecordVersion() - 1); + LOGD("Begin migrate sync data, need migrate version[%" PRIu64 "]", GetCacheRecordVersion() - 1); uint64_t curMigrateVer = 0; // The migration process is asynchronous and continuous NotifyMigrateSyncData syncData; auto kvdbManager = KvDBManager::GetInstance(); @@ -258,7 +259,7 @@ int SQLiteSingleVerStorageEngine::MigrateSyncData(SQLiteSingleVerStorageExecutor while (curMigrateVer < GetCacheRecordVersion()) { errCode = MigrateSyncDataByVersion(handle, syncData, curMigrateVer); if (errCode != E_OK) { - LOGE("Migrate version[%llu] failed! errCode = [%d]", curMigrateVer, errCode); + LOGE("Migrate version[%" PRIu64 "] failed! errCode = [%d]", curMigrateVer, errCode); break; } if (!syncData.isRemote) { @@ -448,7 +449,7 @@ int SQLiteSingleVerStorageEngine::ExecuteMigrate() if (preState == EngineState::MIGRATING || preState == EngineState::INVALID || !OS::CheckPathExistence(GetDbDir(option_.subdir, DbType::CACHE) + "/" + DBConstant::SINGLE_VER_CACHE_STORE + DBConstant::SQLITE_DB_EXTENSION)) { - LOGD("[SqlSingleVerEngine] Being single ver migrating or never create db! engine state [%d]", preState); + LOGD("[SqlSingleVerEngine] Being single ver migrating or never create db! engine state [%u]", preState); return E_OK; } @@ -469,8 +470,8 @@ int SQLiteSingleVerStorageEngine::ExecuteMigrate() goto END; } - LOGD("[SqlSingleVerEngine] Current engineState [%d] executorState [%d], begin to executing singleVer db migrate!", - preState, executorState_); + LOGD("[SqlSingleVerEngine] Current engineState [%u] executorState [%u], begin to executing singleVer db migrate!", + static_cast(preState), static_cast(executorState_)); // has been attached, Mark start of migration and it can migrate data errCode = MigrateLocalData(handle); if (errCode != E_OK) { diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp index 07257fcf1..af988edbf 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp @@ -1228,7 +1228,8 @@ DataOperStatus SQLiteSingleVerStorageExecutor::JudgeSyncSaveType(DataItem &dataI if (itemGet.writeTimeStamp >= dataItem.writeTimeStamp) { // for multi user mode, no permit to forcewrite if ((!deviceName.empty()) && (itemGet.dev == deviceName) && isPermitForceWrite) { - LOGI("Force overwrite the data:%llu vs %llu", itemGet.writeTimeStamp, dataItem.writeTimeStamp); + LOGI("Force overwrite the data:%" PRIu64 " vs %" PRIu64 "", + itemGet.writeTimeStamp, dataItem.writeTimeStamp); status.isDefeated = false; dataItem.writeTimeStamp = itemGet.writeTimeStamp + 1; dataItem.timeStamp = itemGet.timeStamp; @@ -1506,7 +1507,8 @@ int SQLiteSingleVerStorageExecutor::BindSavedSyncData(sqlite3_stmt *statement, c const int writeTimeIndex = isUpdate ? BIND_SYNC_UPDATE_W_TIME_INDEX : BIND_SYNC_W_TIME_INDEX; errCode = SQLiteUtils::BindInt64ToStatement(statement, writeTimeIndex, dataItem.writeTimeStamp); - LOGD("Write timestamp:%llu timestamp:%llu, %llu", dataItem.writeTimeStamp, dataItem.timeStamp, dataItem.flag); + LOGD("Write timestamp:%" PRIu64 " timestamp:%" PRIu64 ", %" PRIu64 "", + dataItem.writeTimeStamp, dataItem.timeStamp, dataItem.flag); if (errCode != E_OK) { LOGE("Bind saved sync data write stamp failed:%d", errCode); return errCode; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp index 0c2d44754..d985e7430 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp @@ -219,8 +219,8 @@ int SQLiteSingleVerStorageExecutor::AttachMainDbAndCacheDb(CipherType type, cons } else { return -E_INVALID_ARGS; } - LOGD("[singleVerExecutor][attachDb] current engineState[%d], executorState[%d]", engineState, executorState_); - + LOGD("[singleVerExecutor][attachDb] current engineState[%u], executorState[%u]", static_cast(engineState), + static_cast(executorState_)); return errCode; } @@ -532,8 +532,8 @@ int SQLiteSingleVerStorageExecutor::BindSyncDataInCacheMode(sqlite3_stmt *statem return errCode; } - LOGD("Write timestamp:%llu timestamp%llu, %llu, version %llu", dataItem.writeTimeStamp, dataItem.timeStamp, - dataItem.flag, recordVersion); + LOGD("Write timestamp:%" PRIu64 " timestamp:%llu, %" PRIu64 ", flag:%" PRIu64 ", version:%" PRIu64 "", + dataItem.writeTimeStamp, dataItem.timeStamp, dataItem.flag, recordVersion); errCode = SQLiteUtils::BindInt64ToStatement(statement, BIND_CACHE_SYNC_FLAG_INDEX, static_cast(dataItem.flag)); if (errCode != E_OK) { @@ -800,7 +800,7 @@ int SQLiteSingleVerStorageExecutor::GetMinTimestampInCacheDB(TimeStamp &minStamp errCode = SQLiteUtils::StepWithRetry(statement, isMemDb_); if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)) { minStamp = static_cast(sqlite3_column_int64(statement, 0)); // get the first column - LOGD("Min time stamp in cacheDB is %llu", minStamp); + LOGD("Min time stamp in cacheDB is %" PRIu64 "", minStamp); errCode = E_OK; } else { LOGE("GetMinTimestampInCacheDB failed, errCode = %d.", errCode); @@ -840,8 +840,8 @@ int SQLiteSingleVerStorageExecutor::InitMigrateTimeStampOffset() // The purpose of -1 is to ensure that the first data record in the original cacheDB is 1 greater than // the last data record in the original mainDB after the migration. migrateTimeOffset_ = minTimeInCache - maxTimeInMain - 1; - LOGI("Min timestamp in cacheDB is %llu, max timestamp in mainDB is %llu. Time offset during migrating is %lld.", - minTimeInCache, maxTimeInMain, migrateTimeOffset_); + LOGI("Min timestamp in cacheDB is %" PRIu64 ", max timestamp in mainDB is %" PRIu64 ". Time offset during migrating" + " is %" PRId64 ".", minTimeInCache, maxTimeInMain, migrateTimeOffset_); return E_OK; } @@ -907,7 +907,7 @@ int SQLiteSingleVerStorageExecutor::InitMigrateData() insertSQL = MIGRATE_INSERT_DATA_TO_MAINDB_FROM_CACHEHANDLE; updateSQL = MIGRATE_UPDATE_DATA_TO_MAINDB_FROM_CACHEHANDLE; } else { - LOGE("[InitMigrateData] executor in an error state[%d]!", executorState_); + LOGE("[InitMigrateData] executor in an error state[%u]!", static_cast(executorState_)); return -E_INVALID_DB; } int errCode = PrepareForSavingData(querySQL, insertSQL, updateSQL, migrateSyncStatements_); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp index 5f79dbecd..e7217e167 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp @@ -172,13 +172,14 @@ int SQLiteSingleVerStorageExecutor::AddSubscribeTrigger(QueryObject &query, cons std::string subscribeCondition; errCode = helper.GetSubscribeSql(subscribeId, mode, subscribeCondition); if (errCode != E_OK) { - LOGE("Get subscribe trigger create sql failed. mode: %d, errCode: %d", mode, errCode); + LOGE("Get subscribe trigger create sql failed. mode: %u, errCode: %d", static_cast(mode), + errCode); return errCode; } std::string sql = FormatSubscribeTriggerSql(subscribeId, subscribeCondition, mode); errCode = SQLiteUtils::ExecuteRawSQL(dbHandle_, sql); if (errCode != E_OK) { - LOGE("Add subscribe trigger failed. mode: %d, errCode: %d", mode, errCode); + LOGE("Add subscribe trigger failed. mode: %u, errCode: %d", static_cast(mode), errCode); return errCode; } } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp index 007a87bf3..73727a8d9 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp @@ -114,7 +114,7 @@ StorageExecutor *StorageEngine::FindWriteExecutor(OperatePerm perm, int &errCode std::unique_lock lock(writeMutex_); errCode = -E_BUSY; if (perm_ == OperatePerm::DISABLE_PERM || perm_ != perm) { - LOGI("Not permitted to get the executor[%d]", perm_); + LOGI("Not permitted to get the executor[%u]", static_cast(perm_)); return nullptr; } if (waitTime <= 0) { // non-blocking. @@ -137,8 +137,9 @@ StorageExecutor *StorageEngine::FindWriteExecutor(OperatePerm perm, int &errCode return nullptr; } if (!result) { - LOGI("Get write handle result[%d], permissType[%d], operType[%d], write[%d-%d-%d]", - result, perm_, perm, writeIdleList_.size(), writeUsingList_.size(), engineAttr_.maxWriteNum); + LOGI("Get write handle result[%d], permissType[%u], operType[%u], write[%zu-%zu-%" PRIu32 "]", result, + static_cast(perm_), static_cast(perm), writeIdleList_.size(), writeUsingList_.size(), + engineAttr_.maxWriteNum); return nullptr; } return FetchStorageExecutor(true, writeIdleList_, writeUsingList_, errCode); @@ -149,7 +150,7 @@ StorageExecutor *StorageEngine::FindReadExecutor(OperatePerm perm, int &errCode, std::unique_lock lock(readMutex_); errCode = -E_BUSY; if (perm_ == OperatePerm::DISABLE_PERM || perm_ != perm) { - LOGI("Not permitted to get the executor[%d]", perm_); + LOGI("Not permitted to get the executor[%u]", static_cast(perm_)); return nullptr; } @@ -173,8 +174,9 @@ StorageExecutor *StorageEngine::FindReadExecutor(OperatePerm perm, int &errCode, return nullptr; } if (!result) { - LOGI("Get read handle result[%d], permissType[%d], operType[%d], read[%d-%d-%d]", - result, perm_, perm, readIdleList_.size(), readUsingList_.size(), engineAttr_.maxReadNum); + LOGI("Get read handle result[%d], permissType[%u], operType[%u], read[%zu-%zu-%" PRIu32 "]", result, + static_cast(perm_), static_cast(perm), readIdleList_.size(), readUsingList_.size(), + engineAttr_.maxReadNum); return nullptr; } return FetchStorageExecutor(false, readIdleList_, readUsingList_, errCode); @@ -411,7 +413,7 @@ StorageExecutor *StorageEngine::FetchStorageExecutor(bool isWrite, std::list g_adapter = std::make_shared(); - EXPECT_TRUE(g_adapter != nullptr); RuntimeContext::GetInstance()->SetProcessSystemApiAdapter(g_adapter); KvStoreNbDelegate::Option option = {true, false, false}; int abnormalNum = -100; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_upgrade_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_upgrade_test.cpp index 55a31af7e..5d4e4c874 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_upgrade_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_upgrade_test.cpp @@ -287,7 +287,6 @@ void DistributedDBStorageSingleVerUpgradeTest::SetUpTestCase(void) int errCode = g_passwd.SetValue(passwdBuffer1.data(), passwdBuffer1.size()); ASSERT_EQ(errCode, CipherPassword::ErrorCode::OK); g_adapter = std::make_shared(); - EXPECT_TRUE(g_adapter != nullptr); RuntimeContext::GetInstance()->SetProcessSystemApiAdapter(g_adapter); g_maindbPath = g_testDir + "/" + identifier + "/" + DBConstant::SINGLE_SUB_DIR + "/" + DBConstant::MAINDB_DIR + "/" + DBConstant::SINGLE_VER_DATA_STORE + DBConstant::SQLITE_DB_EXTENSION; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp index c44b497b6..cb70d93b6 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp @@ -144,7 +144,7 @@ std::string FbfFileToSchemaString(const std::string &fileName) } auto size = is.tellg(); - LOGE("file size %d", size); + LOGE("file size %u", static_cast(size)); std::string schema(size, '\0'); is.seekg(0); if (is.read(&schema[0], size)) { diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp index f595b4d2f..a062dd05a 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp @@ -1336,7 +1336,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp001, TestSize.L // Tobe compare the timestamp. CommitID commitId; TimeStamp commitTimestamp = GetCommitTimestamp(commitId); - LOGD("TimeRecord:%llu, TimeCommit:%llu", *(timeSet.begin()), commitTimestamp); + LOGD("TimeRecord:%" PRIu64 ", TimeCommit:%" PRIu64 "", *(timeSet.begin()), commitTimestamp); ASSERT_EQ(*(timeSet.begin()), commitTimestamp); ASSERT_NE(commitTimestamp, 0UL); @@ -1449,7 +1449,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp002, TestSize.L */ TimeStamp stampSecond = GetCommitTimestamp(commitId); ASSERT_NE(stampSecond, 0UL); // non-zero - LOGD("TimeFirst:%llu, TimeSecond:%llu", stampFirst, stampSecond); + LOGD("TimeFirst:%" PRIu64 ", TimeSecond:%" PRIu64 "", stampFirst, stampSecond); ASSERT_GT(stampSecond, stampFirst); } static void ReleaseKvEntries(std::vector &entries) @@ -1502,7 +1502,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp003, TestSize.L * @tc.steps: expected. the timestamp of the sync commit is equal to the timestamp of the data record. */ TimeStamp commitTimestamp = GetCommitTimestamp(commit.commitId); - LOGD("TimeRecord:%llu, TimeCommit:%llu", timestamp, commitTimestamp); + LOGD("TimeRecord:%" PRIu64 ", TimeCommit:%" PRIu64 "", timestamp, commitTimestamp); ASSERT_EQ(timestamp, commitTimestamp); ASSERT_NE(commitTimestamp, 0UL); } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp index 8e050440f..199e27585 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp @@ -92,7 +92,6 @@ void DistributedDBSingleVerP2PSyncCheckTest::SetUpTestCase(void) RuntimeContext::GetInstance()->SetCommunicatorAggregator(g_communicatorAggregator); std::shared_ptr g_adapter = std::make_shared(); - EXPECT_TRUE(g_adapter != nullptr); RuntimeContext::GetInstance()->SetProcessSystemApiAdapter(g_adapter); } -- Gitee From 0f8b9076657b709a77bc5337314448bc336e645d Mon Sep 17 00:00:00 2001 From: lidwchn Date: Wed, 23 Mar 2022 15:06:49 +0800 Subject: [PATCH 05/20] Fix issue. Signed-off-by: lidwchn --- .../src/multiver/multi_ver_storage_executor.cpp | 10 +++++----- .../storage/src/multiver/multi_ver_vacuum.cpp | 4 ++-- .../src/sqlite/sqlite_multi_ver_transaction.cpp | 6 +++--- .../src/sqlite/sqlite_single_ver_natural_store.cpp | 6 +++--- .../sqlite_single_ver_natural_store_connection.cpp | 2 +- .../src/sqlite/sqlite_single_ver_storage_executor.cpp | 4 ++-- .../sqlite_single_ver_storage_executor_cache.cpp | 4 ++-- .../distributeddb_storage_transaction_data_test.cpp | 6 +++--- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp index 65d7ed518..d34e8eabb 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp @@ -409,7 +409,7 @@ int MultiVerStorageExecutor::ReInitTransactionVersion(const MultiVerCommitNode & errCode = E_OK; } } else { - LOGD("Reput the version:%" PRIu64 "", readCommit->GetCommitVersion()); + LOGD("Reput the version:%" PRIu64, readCommit->GetCommitVersion()); transaction_->SetVersion(readCommit->GetCommitVersion()); commitStorage_->ReleaseCommit(readCommit); } @@ -559,7 +559,7 @@ int MultiVerStorageExecutor::MergeCommits(const std::vector } if (item.deviceInfo.size() == MULTI_VER_TAG_SIZE || item.deviceInfo.compare(0, SHA256_DIGEST_LENGTH, rootNodeDeviceInfo, 0, SHA256_DIGEST_LENGTH) != 0) { - LOGD("Skip the version:%" PRIu64 "", item.version); + LOGD("Skip the version:%" PRIu64, item.version); continue; } errCode = MergeOneCommit(item); @@ -871,7 +871,7 @@ int MultiVerStorageExecutor::CommitTransaction(MultiTransactionType type) dataStorage_->RollbackWritePhaseOne(transaction_, commitVersion); goto END; } - LOGD("local commit version:%" PRIu64 "", commitVersion); + LOGD("local commit version:%" PRIu64, commitVersion); static_cast(kvDB_)->SetMaxTimeStamp(multiVerTimeStamp.timestamp); dataStorage_->CommitWritePhaseTwo(transaction_); static_cast(kvDB_)->SetMaxCommitVersion(commitVersion); @@ -1107,7 +1107,7 @@ int MultiVerStorageExecutor::GetResolvedConflictEntries(const MultiVerCommitNode entries.clear(); entries.shrink_to_fit(); Version version = commit->GetCommitVersion(); - LOGD("Version is %" PRIu64 "", version); + LOGD("Version is %" PRIu64, version); if (transaction_ != nullptr) { errCode = transaction_->GetEntriesByVersion(version, entries); if (errCode != E_OK) { @@ -1318,7 +1318,7 @@ int MultiVerStorageExecutor::CommitTransaction(const MultiVerCommitNode &multiVe dataStorage_->CommitWritePhaseTwo(transaction_); static_cast(kvDB_)->SetMaxTimeStamp(multiVerTimeStamp.timestamp); static_cast(kvDB_)->SetMaxCommitVersion(commitVersion); - LOGD("sync commit version:%" PRIu64 "", commitVersion); + LOGD("sync commit version:%" PRIu64, commitVersion); END: dataStorage_->ReleaseTransaction(transaction_); transaction_ = nullptr; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp index 791bc7e16..9014b4707 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp @@ -356,8 +356,8 @@ int MultiVerVacuum::DealWithLeftBranchVacuumNeedRecord(VacuumTaskContext &inTask // No other thread will access handle, node and record field of a RUN_NING, PAUSE_WAIT, ABORT_WAIT status task // So it is concurrency safe to access or change these field without protection of lockguard const MultiVerRecordInfo &record = inTask.vacuumNeedRecords.front(); - LOGD("[Vacuum][DealLeftRecord] Type=%u, Version=%llu, HashKey=%s.", static_cast(record.type), - ULL(record.version), VEC_TO_STR(record.hashKey)); + LOGD("[Vacuum][DealLeftRecord] Type=%" PRIu32 ", Version=%" PRIu64 ", HashKey=%s.", + static_cast(record.type), record.version, VEC_TO_STR(record.hashKey)); if (inTask.shadowRecords.empty()) { if (record.type == RecordType::CLEAR) { errCode = inTask.databaseHandle->GetShadowRecordsOfClearTypeRecord(record.version, record.hashKey, diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp index ffb0ccb2c..a6f2940fd 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp @@ -364,7 +364,7 @@ int SQLiteMultiVerTransaction::CheckToSaveRecord(const MultiVerKvEntry *entry, b (static_cast(entry))->GetOperFlag(operFlag); entry->GetTimestamp(timestamp); if ((operFlag & OPERATE_MASK) == CLEAR_FLAG && version_ != 0) { - LOGD("Erase one version:%" PRIu64 "", version_); + LOGD("Erase one version:%" PRIu64, version_); errCode = GetPrePutValues(version_, timestamp, values); if (errCode != E_OK) { return errCode; @@ -792,7 +792,7 @@ int SQLiteMultiVerTransaction::UpdateTimestampByVersion(const Version &version, if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_DONE)) { errCode = E_OK; currentMaxTimestamp_ = (stamp > currentMaxTimestamp_) ? stamp : currentMaxTimestamp_; - LOGD("Update the timestamp of version:%" PRIu64 " - %" PRIu64 "", version, stamp); + LOGD("Update the timestamp of version:%" PRIu64 " - %" PRIu64, version, stamp); } else { LOGE("Failed to update the timestamp of the version:%d", errCode); } @@ -1079,7 +1079,7 @@ int SQLiteMultiVerTransaction::AddRecord(const Key &key, const Value &value, dataCopy.timestamp = currentMaxTimestamp_++; if ((dataCopy.operFlag & LOCAL_FLAG) != 0) { dataCopy.oriTimestamp = currentMaxTimestamp_; - LOGD("Origin timestamp:%" PRIu64 "", currentMaxTimestamp_); + LOGD("Origin timestamp:%" PRIu64, currentMaxTimestamp_); } } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp index 3f4c0b9cb..efd8b59f7 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp @@ -988,7 +988,7 @@ int SQLiteSingleVerNaturalStore::RemoveDeviceDataInCacheMode(const std::string & return errCode; } uint64_t recordVersion = GetAndIncreaseCacheRecordVersion(); - LOGI("Remove device data in cache mode isNeedNotify:%d, recordVersion:%" PRIu64 "", isNeedNotify, recordVersion); + LOGI("Remove device data in cache mode isNeedNotify:%d, recordVersion:%" PRIu64, isNeedNotify, recordVersion); errCode = handle->RemoveDeviceDataInCacheMode(deviceName, isNeedNotify, recordVersion); if (errCode != E_OK) { LOGE("[SingleVerNStore] RemoveDeviceDataInCacheMode failed:%d", errCode); @@ -1159,7 +1159,7 @@ void SQLiteSingleVerNaturalStore::InitCurrentMaxStamp() } handle->InitCurrentMaxStamp(currentMaxTimeStamp_); - LOGD("Init max timestamp:%" PRIu64 "", currentMaxTimeStamp_); + LOGD("Init max timestamp:%" PRIu64, currentMaxTimeStamp_); ReleaseHandle(handle); } @@ -2251,7 +2251,7 @@ int SQLiteSingleVerNaturalStore::RemoveSubscribe(const std::string &subscribeId) int SQLiteSingleVerNaturalStore::SetMaxLogSize(uint64_t limit) { - LOGI("Set the max log size to %" PRIu64 "", limit); + LOGI("Set the max log size to %" PRIu64, limit); maxLogSize_.store(limit); return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp index 53b39705b..958b5aceb 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp @@ -1015,7 +1015,7 @@ int SQLiteSingleVerNaturalStoreConnection::SaveLocalEntry(const Entry &entry, bo dataItem.flag = DataItem::DELETE_FLAG; } dataItem.timeStamp = naturalStore->GetCurrentTimeStamp(); - LOGD("TimeStamp is %" PRIu64 "", dataItem.timeStamp); + LOGD("TimeStamp is %" PRIu64, dataItem.timeStamp); if (IsCacheDBMode()) { return SaveLocalItemInCacheMode(dataItem); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp index af988edbf..5744bc88c 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp @@ -1228,7 +1228,7 @@ DataOperStatus SQLiteSingleVerStorageExecutor::JudgeSyncSaveType(DataItem &dataI if (itemGet.writeTimeStamp >= dataItem.writeTimeStamp) { // for multi user mode, no permit to forcewrite if ((!deviceName.empty()) && (itemGet.dev == deviceName) && isPermitForceWrite) { - LOGI("Force overwrite the data:%" PRIu64 " vs %" PRIu64 "", + LOGI("Force overwrite the data:%" PRIu64 " vs %" PRIu64, itemGet.writeTimeStamp, dataItem.writeTimeStamp); status.isDefeated = false; dataItem.writeTimeStamp = itemGet.writeTimeStamp + 1; @@ -1507,7 +1507,7 @@ int SQLiteSingleVerStorageExecutor::BindSavedSyncData(sqlite3_stmt *statement, c const int writeTimeIndex = isUpdate ? BIND_SYNC_UPDATE_W_TIME_INDEX : BIND_SYNC_W_TIME_INDEX; errCode = SQLiteUtils::BindInt64ToStatement(statement, writeTimeIndex, dataItem.writeTimeStamp); - LOGD("Write timestamp:%" PRIu64 " timestamp:%" PRIu64 ", %" PRIu64 "", + LOGD("Write timestamp:%" PRIu64 " timestamp:%" PRIu64 ", %" PRIu64, dataItem.writeTimeStamp, dataItem.timeStamp, dataItem.flag); if (errCode != E_OK) { LOGE("Bind saved sync data write stamp failed:%d", errCode); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp index d985e7430..41dce8384 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp @@ -532,7 +532,7 @@ int SQLiteSingleVerStorageExecutor::BindSyncDataInCacheMode(sqlite3_stmt *statem return errCode; } - LOGD("Write timestamp:%" PRIu64 " timestamp:%llu, %" PRIu64 ", flag:%" PRIu64 ", version:%" PRIu64 "", + LOGD("Write timestamp:%" PRIu64 " timestamp:%" PRIu64 ", flag:%" PRIu64 ", version:%" PRIu64, dataItem.writeTimeStamp, dataItem.timeStamp, dataItem.flag, recordVersion); errCode = SQLiteUtils::BindInt64ToStatement(statement, BIND_CACHE_SYNC_FLAG_INDEX, static_cast(dataItem.flag)); @@ -800,7 +800,7 @@ int SQLiteSingleVerStorageExecutor::GetMinTimestampInCacheDB(TimeStamp &minStamp errCode = SQLiteUtils::StepWithRetry(statement, isMemDb_); if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)) { minStamp = static_cast(sqlite3_column_int64(statement, 0)); // get the first column - LOGD("Min time stamp in cacheDB is %" PRIu64 "", minStamp); + LOGD("Min time stamp in cacheDB is %" PRIu64, minStamp); errCode = E_OK; } else { LOGE("GetMinTimestampInCacheDB failed, errCode = %d.", errCode); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp index a062dd05a..4c19de1d0 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp @@ -1336,7 +1336,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp001, TestSize.L // Tobe compare the timestamp. CommitID commitId; TimeStamp commitTimestamp = GetCommitTimestamp(commitId); - LOGD("TimeRecord:%" PRIu64 ", TimeCommit:%" PRIu64 "", *(timeSet.begin()), commitTimestamp); + LOGD("TimeRecord:%" PRIu64 ", TimeCommit:%" PRIu64, *(timeSet.begin()), commitTimestamp); ASSERT_EQ(*(timeSet.begin()), commitTimestamp); ASSERT_NE(commitTimestamp, 0UL); @@ -1449,7 +1449,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp002, TestSize.L */ TimeStamp stampSecond = GetCommitTimestamp(commitId); ASSERT_NE(stampSecond, 0UL); // non-zero - LOGD("TimeFirst:%" PRIu64 ", TimeSecond:%" PRIu64 "", stampFirst, stampSecond); + LOGD("TimeFirst:%" PRIu64 ", TimeSecond:%" PRIu64, stampFirst, stampSecond); ASSERT_GT(stampSecond, stampFirst); } static void ReleaseKvEntries(std::vector &entries) @@ -1502,7 +1502,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp003, TestSize.L * @tc.steps: expected. the timestamp of the sync commit is equal to the timestamp of the data record. */ TimeStamp commitTimestamp = GetCommitTimestamp(commit.commitId); - LOGD("TimeRecord:%" PRIu64 ", TimeCommit:%" PRIu64 "", timestamp, commitTimestamp); + LOGD("TimeRecord:%" PRIu64 ", TimeCommit:%" PRIu64, timestamp, commitTimestamp); ASSERT_EQ(timestamp, commitTimestamp); ASSERT_NE(commitTimestamp, 0UL); } -- Gitee From 79a885953895e7090488054752e2716a0ab49f7f Mon Sep 17 00:00:00 2001 From: zqq Date: Mon, 21 Mar 2022 20:46:35 +0800 Subject: [PATCH 06/20] format log print Signed-off-by: zqq --- .../distributeddb/syncer/src/ability_sync.cpp | 6 +- .../syncer/src/commit_history_sync.cpp | 8 +-- .../distributeddb/syncer/src/meta_data.cpp | 15 +++-- .../syncer/src/multi_ver_data_sync.cpp | 4 +- .../src/multi_ver_sync_state_machine.cpp | 4 +- .../src/single_ver_data_message_schedule.cpp | 16 +++-- .../syncer/src/single_ver_data_sync.cpp | 66 ++++++++++--------- .../syncer/src/single_ver_data_sync_utils.cpp | 2 +- .../syncer/src/single_ver_kv_syncer.cpp | 6 +- .../src/single_ver_serialize_manager.cpp | 3 +- .../syncer/src/single_ver_sync_engine.cpp | 4 +- .../src/single_ver_sync_state_machine.cpp | 4 +- .../src/single_ver_sync_task_context.cpp | 6 +- .../syncer/src/subscribe_manager.cpp | 2 +- .../distributeddb/syncer/src/sync_engine.cpp | 4 +- .../distributeddb/syncer/src/time_sync.cpp | 17 ++--- .../syncer/src/value_slice_sync.cpp | 3 +- .../common/syncer/kv_virtual_device.cpp | 2 +- ...rtual_relational_ver_sync_db_interface.cpp | 10 +-- .../virtual_single_ver_sync_db_Interface.cpp | 13 ++-- 20 files changed, 105 insertions(+), 90 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp index 59d1f9728..fe0473973 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp @@ -145,7 +145,7 @@ uint32_t AbilitySyncRequestPacket::CalculateLen() const // the reason why not 8-byte align is that old version is not 8-byte align // so it is not possible to set 8-byte align for high version. if (len > INT32_MAX) { - LOGE("[AbilitySyncRequestPacket][CalculateLen] err len:%llu", len); + LOGE("[AbilitySyncRequestPacket][CalculateLen] err len:%" PRIu64, len); return 0; } return len; @@ -299,7 +299,7 @@ uint32_t AbilitySyncAckPacket::CalculateLen() const len += DbAbility::CalculateLen(dbAbility_); // dbAbility_ len += SchemaNegotiate::CalculateParcelLen(relationalSyncOpinion_); if (len > INT32_MAX) { - LOGE("[AbilitySyncAckPacket][CalculateLen] err len:%llu", len); + LOGE("[AbilitySyncAckPacket][CalculateLen] err len:%" PRIu64, len); return 0; } return len; @@ -930,7 +930,7 @@ int AbilitySync::SetAbilityRequestBodyInfo(AbilitySyncRequestPacket &packet, uin packet.SetSecFlag(option.securityFlag); packet.SetDbCreateTime(dbCreateTime); packet.SetDbAbility(dbAbility); - LOGI("[AbilitySync][FillRequest] ver=%u,Lab=%d,Flag=%d,dbCreateTime=%llu", SOFTWARE_VERSION_CURRENT, + LOGI("[AbilitySync][FillRequest] ver=%u,Lab=%d,Flag=%d,dbCreateTime=%" PRId64, SOFTWARE_VERSION_CURRENT, option.securityLabel, option.securityFlag, dbCreateTime); return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp index 350dc4596..cb5f3a16c 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp @@ -312,7 +312,7 @@ int CommitHistorySync::AckRecvCallback(MultiVerSyncTaskContext *context, const M context->SetCommits(commits); context->SetCommitIndex(0); context->SetCommitsSize(static_cast(commits.size())); - LOGD("CommitHistorySync::AckRecvCallback end, CommitsSize = %llu, dst = %s{private}, ver = %d, myversion = %u", + LOGD("CommitHistorySync::AckRecvCallback end, CommitsSize = %zu, dst = %s{private}, ver = %d, myversion = %u", commits.size(), context->GetDeviceId().c_str(), ver, SOFTWARE_VERSION_CURRENT); return E_OK; } @@ -386,7 +386,7 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 Parcel parcel(const_cast(buffer), length); packLen += parcel.ReadUInt64(len); if (len > DBConstant::MAX_DEVICES_SIZE) { - LOGE("CommitHistorySync::RequestPacketDeSerialization : commitMap size too large = %llu", len); + LOGE("CommitHistorySync::RequestPacketDeSerialization : commitMap size too large = %" PRIu64, len); return -E_INVALID_ARGS; } // commitMap DeSerialization @@ -408,8 +408,8 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 packLen += parcel.ReadVector(reserved); packLen = Parcel::GetEightByteAlign(packLen); if (packLen != length || parcel.IsError()) { - LOGE("CommitHistorySync::RequestPacketDeSerialization : length error, input len = %lu, cac len = %llu", - length, packLen); + LOGE("CommitHistorySync::RequestPacketDeSerialization : length error, input len = %" PRIu32 + ", cac len = %" PRIu64, length, packLen); return -E_INVALID_ARGS; } CommitHistorySyncRequestPacket *packet = new (std::nothrow) CommitHistorySyncRequestPacket(); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp index 6eb4ee538..485f8d8f1 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp @@ -80,7 +80,7 @@ int Metadata::SaveTimeOffset(const DeviceID &deviceId, TimeOffset inValue) GetMetaDataValue(deviceId, metadata, true); metadata.timeOffset = inValue; metadata.lastUpdateTime = TimeHelper::GetSysCurrentTime(); - LOGD("Metadata::SaveTimeOffset = %lld dev %s", inValue, STR_MASK(deviceId)); + LOGD("Metadata::SaveTimeOffset = %" PRId64 " dev %s", inValue, STR_MASK(deviceId)); return SaveMetaDataValue(deviceId, metadata); } @@ -106,7 +106,7 @@ int Metadata::SaveLocalWaterMark(const DeviceID &deviceId, uint64_t inValue) std::lock_guard lockGuard(metadataLock_); GetMetaDataValue(deviceId, metadata, true); metadata.localWaterMark = inValue; - LOGD("Metadata::SaveLocalWaterMark = %llu", inValue); + LOGD("Metadata::SaveLocalWaterMark = %" PRIu64, inValue); return SaveMetaDataValue(deviceId, metadata); } @@ -137,7 +137,7 @@ int Metadata::SaveLocalTimeOffset(TimeOffset timeOffset) std::lock_guard lockGuard(localTimeOffsetLock_); localTimeOffset_ = timeOffset; - LOGD("Metadata::SaveLocalTimeOffset offset = %lld", timeOffset); + LOGD("Metadata::SaveLocalTimeOffset offset = %" PRId64, timeOffset); int errCode = SetMetadataToDb(localTimeOffsetValue, timeOffsetValue); if (errCode != E_OK) { LOGE("Metadata::SaveLocalTimeOffset SetMetadataToDb failed errCode:%d", errCode); @@ -284,7 +284,7 @@ int64_t Metadata::StringToLong(const std::vector &value) const { std::string valueString(value.begin(), value.end()); int64_t longData = std::strtoll(valueString.c_str(), nullptr, STR_TO_LL_BY_DEVALUE); - LOGD("Metadata::StringToLong longData = %lld", longData); + LOGD("Metadata::StringToLong longData = %" PRId64, longData); return longData; } @@ -365,7 +365,7 @@ uint64_t Metadata::GetRandTimeOffset() const // use a 16 bit rand data to make a rand timeoffset uint64_t randTimeOffset = (static_cast(randBytes[1]) << 8) | randBytes[0]; // 16 bit data, 8 is offset randTimeOffset = randTimeOffset * 1000 * 1000 * 10; // second, 1000 is scale - LOGD("[Metadata] GetRandTimeOffset %llu", randTimeOffset); + LOGD("[Metadata] GetRandTimeOffset %" PRIu64, randTimeOffset); return randTimeOffset; } @@ -514,10 +514,11 @@ int Metadata::SetDbCreateTime(const DeviceID &deviceId, uint64_t inValue, bool i metadata = metadataMap_[hashDeviceId]; if (metadata.dbCreateTime != 0 && metadata.dbCreateTime != inValue) { metadata.clearDeviceDataMark = REMOVE_DEVICE_DATA_MARK; - LOGI("Metadata::SetDbCreateTime,set cleardata mark,dev=%s,dbCreateTime=%llu", STR_MASK(deviceId), inValue); + LOGI("Metadata::SetDbCreateTime,set cleardata mark,dev=%s,dbCreateTime=%" PRIu64, + STR_MASK(deviceId), inValue); } if (metadata.dbCreateTime == 0) { - LOGI("Metadata::SetDbCreateTime,update dev=%s,dbCreateTime=%llu", STR_MASK(deviceId), inValue); + LOGI("Metadata::SetDbCreateTime,update dev=%s,dbCreateTime=%" PRIu64, STR_MASK(deviceId), inValue); } } metadata.dbCreateTime = inValue; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp index 662c6bb3f..9bc8c84f7 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp @@ -279,7 +279,7 @@ int MultiVerDataSync::AckRecvCallback(MultiVerSyncTaskContext *context, const Me context->SetEntries(entries); context->SetEntriesIndex(0); context->SetEntriesSize(static_cast(entries.size())); - LOGD("MultiVerDataSync::AckRecvCallback src=%s{private}, entries num = %llu", + LOGD("MultiVerDataSync::AckRecvCallback src=%s{private}, entries num = %zu", context->GetDeviceId().c_str(), entries.size()); if (entries.size() > 0) { @@ -292,7 +292,7 @@ int MultiVerDataSync::AckRecvCallback(MultiVerSyncTaskContext *context, const Me context->SetValueSliceHashNodes(valueHashes); context->SetValueSlicesIndex(0); context->SetValueSlicesSize(valueHashes.size()); - LOGD("MultiVerDataSync::AckRecvCallback src=%s{private}, ValueSlicesSize num = %llu", + LOGD("MultiVerDataSync::AckRecvCallback src=%s{private}, ValueSlicesSize num = %zu", context->GetDeviceId().c_str(), valueHashes.size()); return errCode; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp index 2235a8fc6..7d9175f64 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp @@ -473,7 +473,7 @@ int MultiVerSyncStateMachine::OneCommitSyncFinish() // Due to time sync error, commit timestamp may bigger than currentLocalTime, we need to fix the timestamp TimeOffset timefixOffset = (commit.timestamp < currentLocalTime) ? 0 : (commit.timestamp - static_cast(currentLocalTime)); - LOGD("MultiVerSyncStateMachine::OneCommitSyncFinish src=%s, timefixOffset = %lld", + LOGD("MultiVerSyncStateMachine::OneCommitSyncFinish src=%s, timefixOffset = %" PRId64, STR_MASK(context_->GetDeviceId()), timefixOffset); commit.timestamp -= static_cast(timefixOffset); ChangeEntriesTimeStamp(entries, outOffset, timefixOffset); @@ -595,7 +595,7 @@ int MultiVerSyncStateMachine::SyncResponseTimeout(TimerId timerId) return info.timerId == timerId; }); if (iter == responseInfos_.end()) { - LOGW("[MultiVerSyncStateMachine][SyncResponseTimeout] Can't find sync response timerId %d", timerId); + LOGW("[MultiVerSyncStateMachine][SyncResponseTimeout] Can't find sync response timerId %" PRIu64, timerId); return E_OK; } sessionId = iter->sessionId; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp index f9ccc4ffa..b958ee8f3 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp @@ -94,8 +94,8 @@ void SingleVerDataMessageSchedule::ScheduleInfoHandle(bool isNeedHandleStatus, b ClearMsgMapWithNoLock(); expectedSequenceId_ = 1; } else { - LOGI("[DataMsgSchedule] DealMsg seqId=%u finishedPacketId=%llu ok,label=%s,dev=%s", expectedSequenceId_, - finishedPacketId_, label_.c_str(), STR_MASK(deviceId_)); + LOGI("[DataMsgSchedule] DealMsg seqId=%" PRIu32 " finishedPacketId=%" PRIu64 " ok,label=%s,dev=%s", + expectedSequenceId_, finishedPacketId_, label_.c_str(), STR_MASK(deviceId_)); expectedSequenceId_++; } } @@ -246,7 +246,7 @@ void SingleVerDataMessageSchedule::StartTimer(SingleVerSyncTaskContext *context) return; } timerId_ = timerId; - LOGD("[DataMsgSchedule] StartTimer,TimerId=%llu", timerId_); + LOGD("[DataMsgSchedule] StartTimer,TimerId=%" PRIu64, timerId_); } void SingleVerDataMessageSchedule::StopTimer() @@ -254,7 +254,7 @@ void SingleVerDataMessageSchedule::StopTimer() TimerId timerId; { std::lock_guard lock(lock_); - LOGD("[DataMsgSchedule] StopTimer,remove TimerId=%llu", timerId_); + LOGD("[DataMsgSchedule] StopTimer,remove TimerId=%" PRIu64, timerId_); if (timerId_ == 0) { return; } @@ -285,7 +285,7 @@ int SingleVerDataMessageSchedule::TimeOut(TimerId timerId) } { std::lock_guard lock(lock_); - LOGI("[DataMsgSchedule] timeout handling, stop timerId_[%llu]", timerId, timerId_); + LOGI("[DataMsgSchedule] timeout handling, stop timerId_[%" PRIu64 "]", timerId); if (timerId == timerId_) { ClearMsgMapWithNoLock(); timerId_ = 0; @@ -308,6 +308,8 @@ int SingleVerDataMessageSchedule::UpdateMsgMapIfNeed(Message *msg) uint32_t sequenceId = msg->GetSequenceId(); uint64_t packetId = packet->GetPacketId(); if (prevSessionId_ != 0 && sessionId == prevSessionId_) { + LOGD("[DataMsgSchedule] recv prev sessionId msg, drop msg, label=%s, dev=%s", label_.c_str(), + STR_MASK(deviceId_)); return -E_INVALID_ARGS; } if (sessionId != currentSessionId_) { @@ -322,6 +324,8 @@ int SingleVerDataMessageSchedule::UpdateMsgMapIfNeed(Message *msg) const auto *cachePacket = messageMap_[sequenceId]->GetObject(); if (cachePacket != nullptr) { if (packetId != 0 && packetId < cachePacket->GetPacketId()) { + LOGD("[DataMsgSchedule] drop msg packetId=%" PRIu64 ", cachePacketId=%" PRIu64 ", label=%s, dev=%s", + packetId, cachePacket->GetPacketId(), label_.c_str(), STR_MASK(deviceId_)); return -E_INVALID_ARGS; } } @@ -329,6 +333,8 @@ int SingleVerDataMessageSchedule::UpdateMsgMapIfNeed(Message *msg) messageMap_[sequenceId] = nullptr; } messageMap_[sequenceId] = msg; + LOGD("[DataMsgSchedule] put into msgMap seqId=%" PRIu32 ", packetId=%" PRIu64 ", label=%s, dev=%s", sequenceId, + packetId, label_.c_str(), STR_MASK(deviceId_)); return E_OK; } } \ No newline at end of file diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp index 69263d565..de566bf06 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp @@ -160,8 +160,8 @@ int SingleVerDataSync::TryContinueSync(SingleVerSyncTaskContext *context, const uint32_t sequenceId = message->GetSequenceId(); std::lock_guard lock(lock_); - LOGI("[DataSync] recv ack seqId=%d,packetId=%llu,winSize=%d,label=%s,dev=%s", sequenceId, packetId, windowSize_, - label_.c_str(), STR_MASK(deviceId_)); + LOGI("[DataSync] recv ack seqId=%" PRIu32 ",packetId=%" PRIu64 ",winSize=%d,label=%s,dev=%s", sequenceId, packetId, + windowSize_, label_.c_str(), STR_MASK(deviceId_)); if (sessionId != sessionId_) { LOGI("[DataSync] ignore ack,sessionId is different"); return E_OK; @@ -209,9 +209,10 @@ int SingleVerDataSync::ReSendData(SingleVerSyncTaskContext *context) } uint32_t sequenceId = reSendMap_.begin()->first; ReSendInfo reSendInfo = reSendMap_.begin()->second; - LOGI("[DataSync] ReSend mode=%d,start=%llu,end=%llu,delStart=%llu,delEnd=%llu,seqId=%d,packetId=%llu,windowsize=%d," - "label=%s,deviceId=%s", mode_, reSendInfo.start, reSendInfo.end, reSendInfo.deleteBeginTime, - reSendInfo.deleteEndTime, sequenceId, reSendInfo.packetId, windowSize_, label_.c_str(), STR_MASK(deviceId_)); + LOGI("[DataSync] ReSend mode=%d,start=%" PRIu64 ",end=%" PRIu64 ",delStart=%" PRIu64 ",delEnd=%" PRIu64 "," + "seqId=%" PRIu32 ",packetId=%" PRIu64 ",windowsize=%d,label=%s,deviceId=%s", mode_, reSendInfo.start, + reSendInfo.end, reSendInfo.deleteBeginTime, reSendInfo.deleteEndTime, sequenceId, reSendInfo.packetId, + windowSize_, label_.c_str(), STR_MASK(deviceId_)); DataSyncReSendInfo dataReSendInfo = {sessionId_, sequenceId, reSendInfo.start, reSendInfo.end, reSendInfo.deleteBeginTime, reSendInfo.deleteEndTime, reSendInfo.packetId}; return ReSend(context, dataReSendInfo); @@ -452,7 +453,7 @@ int SingleVerDataSync::SaveLocalWaterMark(SyncType syncType, const SingleVerSync } } if (isNeedUpdateMark) { - LOGD("label=%s,dev=%s,endTime=%llu", label_.c_str(), STR_MASK(GetDeviceId()), dataTimeRange.endTime); + LOGD("label=%s,dev=%s,endTime=%" PRIu64, label_.c_str(), STR_MASK(GetDeviceId()), dataTimeRange.endTime); errCode = metadata_->SetSendQueryWaterMark(queryId, deviceId, dataTimeRange.endTime); if (errCode != E_OK) { LOGE("[DataSync][SaveLocalWaterMark] save query metadata watermark failed,errCode=%d", errCode); @@ -460,7 +461,7 @@ int SingleVerDataSync::SaveLocalWaterMark(SyncType syncType, const SingleVerSync } } if (isNeedUpdateDeleteMark) { - LOGD("label=%s,dev=%s,deleteEndTime=%llu", label_.c_str(), STR_MASK(GetDeviceId()), + LOGD("label=%s,dev=%s,deleteEndTime=%" PRIu64, label_.c_str(), STR_MASK(GetDeviceId()), dataTimeRange.deleteEndTime); errCode = metadata_->SetSendDeleteSyncWaterMark(context->GetDeleteSyncId(), dataTimeRange.deleteEndTime); } @@ -610,10 +611,10 @@ void SingleVerDataSync::UpdateSendInfo(SyncTimeRange dataTimeRange, SingleVerSyn if (token == nullptr) { isAllDataHasSent_ = true; } - LOGI("[DataSync] mode=%d,start=%llu,end=%llu,deleteStart=%llu,deleteEnd=%llu,seqId=%d,packetId=%llu,window_size=%d," - "isAllSend=%d,label=%s,device=%s", mode_, reSendInfo.start, reSendInfo.end, reSendInfo.deleteBeginTime, - reSendInfo.deleteEndTime, maxSequenceIdHasSent_, reSendInfo.packetId, windowSize_, isAllDataHasSent_, - label_.c_str(), STR_MASK(deviceId_)); + LOGI("[DataSync] mode=%d,start=%" PRIu64 ",end=%" PRIu64 ",deleteStart=%" PRIu64 ",deleteEnd=%" PRIu64 "," + "seqId=%" PRIu32 ",packetId=%" PRIu64 ",window_size=%d,isAllSend=%d,label=%s,device=%s", mode_, + reSendInfo.start, reSendInfo.end, reSendInfo.deleteBeginTime, reSendInfo.deleteEndTime, maxSequenceIdHasSent_, + reSendInfo.packetId, windowSize_, isAllDataHasSent_, label_.c_str(), STR_MASK(deviceId_)); } void SingleVerDataSync::FillDataRequestPacket(DataRequestPacket *packet, SingleVerSyncTaskContext *context, @@ -659,9 +660,9 @@ void SingleVerDataSync::FillDataRequestPacket(DataRequestPacket *packet, SingleV context->GetQuery().HasOrderBy())) { packet->SetUpdateWaterMark(); } - LOGD("[DataSync] curType=%d,local=%llu,del=%llu,end=%llu,label=%s,dev=%s,queryId=%s,isCompress=%d", curType, - localMark, deleteMark, context->GetEndMark(), label_.c_str(), STR_MASK(GetDeviceId()), - STR_MASK(context->GetQuery().GetIdentify()), packet->IsCompressData()); + LOGD("[DataSync] curType=%d,local=%" PRIu64 ",del=%" PRIu64 ",end=%" PRIu64 ",label=%s,dev=%s,queryId=%s," + "isCompress=%d", curType, localMark, deleteMark, context->GetEndMark(), label_.c_str(), + STR_MASK(GetDeviceId()), STR_MASK(context->GetQuery().GetIdentify()), packet->IsCompressData()); } int SingleVerDataSync::RequestStart(SingleVerSyncTaskContext *context, int mode) @@ -775,8 +776,8 @@ int SingleVerDataSync::PullRequestStart(SingleVerSyncTaskContext *context) packet->SetLastSequence(); SingleVerDataSyncUtils::SetPacketId(packet, context, version); - LOGD("[DataSync][Pull] curType=%d,local=%llu,del=%llu,end=%llu,peer=%llu,label=%s,dev=%s", syncType, localMark, - deleteMark, peerMark, endMark, label_.c_str(), STR_MASK(GetDeviceId())); + LOGD("[DataSync][Pull] curType=%d,local=%" PRIu64 ",del=%" PRIu64 ",end=%" PRIu64 ",peer=%" PRIu64 ",label=%s," + "dev=%s", syncType, localMark, deleteMark, endMark, peerMark, label_.c_str(), STR_MASK(GetDeviceId())); UpdateSendInfo(dataTime, context); return SendDataPacket(syncType, packet, context); } @@ -850,14 +851,14 @@ void SingleVerDataSync::UpdatePeerWaterMark(SyncType syncType, const std::string errCode = metadata_->SavePeerWaterMark(context->GetDeviceId(), peerWatermark, true); } else { if (peerWatermark != 0) { - LOGD("label=%s,dev=%s,endTime=%llu", label_.c_str(), STR_MASK(GetDeviceId()), peerWatermark); + LOGD("label=%s,dev=%s,endTime=%" PRIu64, label_.c_str(), STR_MASK(GetDeviceId()), peerWatermark); errCode = metadata_->SetRecvQueryWaterMark(queryId, context->GetDeviceId(), peerWatermark); if (errCode != E_OK) { LOGE("[DataSync][UpdatePeerWaterMark] save query peer water mark failed,errCode=%d", errCode); } } if (peerDeletedWatermark != 0) { - LOGD("label=%s,dev=%s,peerDeletedTime=%llu", + LOGD("label=%s,dev=%s,peerDeletedTime=%" PRIu64, label_.c_str(), STR_MASK(GetDeviceId()), peerDeletedWatermark); errCode = metadata_->SetRecvDeleteSyncWaterMark(context->GetDeleteSyncId(), peerDeletedWatermark); } @@ -941,9 +942,9 @@ int SingleVerDataSync::DataRequestRecv(SingleVerSyncTaskContext *context, const const DataRequestPacket *packet = message->GetObject(); const std::vector &data = packet->GetData(); SyncType curType = SyncOperation::GetSyncType(packet->GetMode()); - LOGI("[DataSync][DataRequestRecv] curType=%d,remote ver=%u,size=%d,errCode=%d,queryId=%s,Label=%s,dev=%s", curType, - packet->GetVersion(), data.size(), packet->GetSendCode(), STR_MASK(packet->GetQueryId()), label_.c_str(), - STR_MASK(GetDeviceId())); + LOGI("[DataSync][DataRequestRecv] curType=%d,remote ver=%zu,size=%d,errCode=%d,queryId=%s,Label=%s,dev=%s", + curType, packet->GetVersion(), data.size(), packet->GetSendCode(), STR_MASK(packet->GetQueryId()), + label_.c_str(), STR_MASK(GetDeviceId())); context->SetReceiveWaterMarkErr(false); UpdateWaterMark isUpdateWaterMark; SyncTimeRange dataTime = SingleVerDataSyncUtils::GetRecvDataTimeRange(curType, data, isUpdateWaterMark); @@ -1115,7 +1116,8 @@ bool SingleVerDataSync::AckPacketIdCheck(const Message *message) if (reSendMap_.count(sequenceId) != 0) { uint64_t originalPacketId = reSendMap_[sequenceId].packetId; if (DataAckPacket::IsPacketIdValid(packetId) && packetId != originalPacketId) { - LOGE("[DataSync] packetId[%llu] is not match with original[%llu]", packetId, originalPacketId); + LOGE("[DataSync] packetId[%" PRIu64 "] is not match with original[%" PRIu64 "]", packetId, + originalPacketId); return false; } } @@ -1155,7 +1157,7 @@ int SingleVerDataSync::AckRecv(SingleVerSyncTaskContext *context, const Message if (recvCode == -E_SAVE_DATA_NOTIFY && data != 0) { // data only use low 32bit context->StartFeedDogForSync(static_cast(data), SyncDirectionFlag::RECEIVE); - LOGI("[DataSync][AckRecv] notify ResetWatchDog=%llu,label=%s,dev=%s", data, label_.c_str(), + LOGI("[DataSync][AckRecv] notify ResetWatchDog=%" PRIu64 ",label=%s,dev=%s", data, label_.c_str(), STR_MASK(GetDeviceId())); } @@ -1223,8 +1225,8 @@ void SingleVerDataSync::GetPullEndWatermark(const SingleVerSyncTaskContext *cont TimeOffset offset; metadata_->GetTimeOffset(context->GetDeviceId(), offset); pullEndWatermark = endMark - static_cast(offset); - LOGD("[DataSync][PullEndWatermark] packetEndMark=%llu,offset=%llu,endWaterMark=%llu,label=%s,dev=%s", - endMark, offset, pullEndWatermark, label_.c_str(), STR_MASK(GetDeviceId())); + LOGD("[DataSync][PullEndWatermark] packetEndMark=%" PRIu64 ",offset=%" PRId64 ",endWaterMark=%" PRIu64 "," + "label=%s,dev=%s", endMark, offset, pullEndWatermark, label_.c_str(), STR_MASK(GetDeviceId())); } } @@ -1240,8 +1242,8 @@ int SingleVerDataSync::DealWaterMarkException(SingleVerSyncTaskContext *context, } deletedWaterMark = reserved[ACK_PACKET_RESERVED_INDEX_DELETE_WATER_MARK]; } - LOGI("[DataSync][WaterMarkException] AckRecv water error, mark=%llu,deleteMark=%llu,label=%s,dev=%s", ackWaterMark, - deletedWaterMark, label_.c_str(), STR_MASK(GetDeviceId())); + LOGI("[DataSync][WaterMarkException] AckRecv water error, mark=%" PRIu64 ",deleteMark=%" PRIu64 "," + "label=%s,dev=%s", ackWaterMark, deletedWaterMark, label_.c_str(), STR_MASK(GetDeviceId())); int errCode = SaveLocalWaterMark(curType, context, {0, 0, ackWaterMark, deletedWaterMark}); if (errCode != E_OK) { @@ -1324,7 +1326,8 @@ void SingleVerDataSync::SendResetWatchDogPacket(SingleVerSyncTaskContext *contex LOGE("[DataSync][ResetWatchDog] Send packet failed,errcode=%d,label=%s,dev=%s", errCode, label_.c_str(), STR_MASK(GetDeviceId())); } else { - LOGI("[DataSync][ResetWatchDog] data = %llu,label=%s,dev=%s", data, label_.c_str(), STR_MASK(GetDeviceId())); + LOGI("[DataSync][ResetWatchDog] data = %" PRIu64 ",label=%s,dev=%s", data, label_.c_str(), + STR_MASK(GetDeviceId())); } } @@ -1456,14 +1459,15 @@ bool SingleVerDataSync::WaterMarkErrHandle(SyncType syncType, SingleVerSyncTaskC GetPeerDeleteSyncWaterMark(context->GetDeleteSyncId(), deletedMark); } if (syncType != SyncType::QUERY_SYNC_TYPE && packetLocalMark > peerMark) { - LOGI("[DataSync][DataRequestRecv] packetLocalMark=%llu,current=%llu", packetLocalMark, peerMark); + LOGI("[DataSync][DataRequestRecv] packetLocalMark=%" PRIu64 ",current=%" PRIu64, packetLocalMark, peerMark); context->SetReceiveWaterMarkErr(true); SendDataAck(context, message, LOCAL_WATER_MARK_NOT_INIT, 0); return true; } if (syncType == SyncType::QUERY_SYNC_TYPE && (packetLocalMark > peerMark || packetDeletedMark > deletedMark)) { - LOGI("[DataSync][DataRequestRecv] packetDeletedMark=%llu,deletedMark=%llu,packetLocalMark=%llu,peerMark=%llu", - packetDeletedMark, deletedMark, packetLocalMark, peerMark); + LOGI("[DataSync][DataRequestRecv] packetDeletedMark=%" PRIu64 ",deletedMark=%" PRIu64 "," + "packetLocalMark=%" PRIu64 ",peerMark=%" PRIu64, packetDeletedMark, deletedMark, packetLocalMark, + peerMark); context->SetReceiveWaterMarkErr(true); SendDataAck(context, message, LOCAL_WATER_MARK_NOT_INIT, 0); return true; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp index 7e72e4aaa..5647815de 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp @@ -106,7 +106,7 @@ void SingleVerDataSyncUtils::TransDbDataItemToSendDataItem(const std::string &lo } outData[i]->SetOrigDevice(outData[i]->GetOrigDevice().empty() ? localHashName : outData[i]->GetOrigDevice()); if (i == 0 || i == (outData.size() - 1)) { - LOGD("[DataSync][TransToSendItem] printData packet=%d,timeStamp=%llu,flag=%llu", i, + LOGD("[DataSync][TransToSendItem] printData packet=%zu,timeStamp=%" PRIu64 ",flag=%" PRIu64, i, outData[i]->GetTimestamp(), outData[i]->GetFlag()); } } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp index de0c05467..d0e52aa8b 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp @@ -149,7 +149,7 @@ void SingleVerKVSyncer::RemoteDataChanged(const std::string &device) LOGI("no need to trigger auto subscribe"); return; } - LOGI("[SingleVerKVSyncer] trigger local subscribe sync, queryNums=%d", syncQueries.size()); + LOGI("[SingleVerKVSyncer] trigger local subscribe sync, queryNums=%zu", syncQueries.size()); for (const auto &query : syncQueries) { TriggerSubscribe(device, query); } @@ -272,8 +272,8 @@ void SingleVerKVSyncer::TriggerSubQuerySync(const std::vector &devi if (lastTimestamp < queryWaterMark || lastTimestamp == 0) { continue; } - LOGD("[Syncer] lastTime=%llu vs WaterMark=%llu,trigger queryId=%s,dev=%s", lastTimestamp, queryWaterMark, - STR_MASK(queryId), STR_MASK(device)); + LOGD("[Syncer] lastTime=%" PRIu64 " vs WaterMark=%" PRIu64 ",trigger queryId=%s,dev=%s", lastTimestamp, + queryWaterMark, STR_MASK(queryId), STR_MASK(device)); InternalSyncParma param; std::vector targetDevices; targetDevices.push_back(device); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp index c5c6bf993..a6fc97b09 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp @@ -453,7 +453,8 @@ int SingleVerSerializeManager::DataPacketSyncerPartDeSerialization(Parcel &parce } packLen = Parcel::GetEightByteAlign(packLen); if (parcel.IsError()) { - LOGE("[DataSync][DataPacketDeSerialization] deserialize failed! input len=%lu,packLen=%lu", length, packLen); + LOGE("[DataSync][DataPacketDeSerialization] deserialize failed! input len=%" PRIu32 ",packLen=%" PRIu32, + length, packLen); return -E_LENGTH_ERROR; } parcel.EightByteAlign(); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp index b961ddbaa..3f85cb9ed 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp @@ -75,7 +75,7 @@ int SingleVerSyncEngine::StartAutoSubscribeTimer() return errCode; } subscribeTimerId_ = timerId; - LOGI("[SingleSyncEngine] start auto subscribe timerId=%d finished", timerId); + LOGI("[SingleSyncEngine] start auto subscribe timerId=%" PRIu64 " finished", timerId); return errCode; } @@ -85,7 +85,7 @@ void SingleVerSyncEngine::StopAutoSubscribeTimer() if (subscribeTimerId_ == 0) { return; } - LOGI("[SingleSyncEngine] stop auto subscribe timerId=%d finished", subscribeTimerId_); + LOGI("[SingleSyncEngine] stop auto subscribe timerId=%" PRIu64 " finished", subscribeTimerId_); RuntimeContext::GetInstance()->RemoveTimer(subscribeTimerId_); subscribeTimerId_ = 0; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp index 0e72373b7..c0bb1aa6d 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp @@ -322,7 +322,7 @@ void SingleVerSyncStateMachine::InitStateSwitchTable(uint32_t version, table.version = version; for (const auto &stateSwitch : switchTable) { if (stateSwitch.size() <= OUTPUT_STATE_INDEX) { - LOGE("[StateMachine][InitSwitchTable] stateSwitch size err,size=%llu", stateSwitch.size()); + LOGE("[StateMachine][InitSwitchTable] stateSwitch size err,size=%zu", stateSwitch.size()); return; } if (table.switchTable.count(stateSwitch[CURRENT_STATE_INDEX]) == 0) { @@ -689,7 +689,7 @@ void SingleVerSyncStateMachine::NeedAbilitySyncHandle() // mean the version num has been reset when syncing data, // there should not clear the new version cache again. if (currentRemoteVersionId_ == context_->GetRemoteSoftwareVersionId()) { - LOGI("[StateMachine] set remote version 0, currentRemoteVersionId_ = %llu", currentRemoteVersionId_); + LOGI("[StateMachine] set remote version 0, currentRemoteVersionId_ = %" PRIu64, currentRemoteVersionId_); context_->SetRemoteSoftwareVersion(0); } else { currentRemoteVersionId_ = context_->GetRemoteSoftwareVersionId(); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp index 456a03d70..2f6a66862 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp @@ -158,7 +158,7 @@ void SingleVerSyncTaskContext::ReleaseContinueToken() int SingleVerSyncTaskContext::PopResponseTarget(SingleVerSyncTarget &target) { std::lock_guard lock(targetQueueLock_); - LOGD("[SingleVerSyncTaskContext] GetFrontExtWaterMarak size = %d", responseTargetQueue_.size()); + LOGD("[SingleVerSyncTaskContext] GetFrontExtWaterMarak size = %zu", responseTargetQueue_.size()); if (!responseTargetQueue_.empty()) { ISyncTarget *tmpTarget = responseTargetQueue_.front(); responseTargetQueue_.pop_front(); @@ -240,7 +240,7 @@ void SingleVerSyncTaskContext::ClearAllSyncTask() std::list targetQueue; { std::lock_guard lock(targetQueueLock_); - LOGI("[SingleVerSyncTaskContext] request taskcount=%d,responsecount=%d", requestTargetQueue_.size(), + LOGI("[SingleVerSyncTaskContext] request taskcount=%zu, responsecount=%zu", requestTargetQueue_.size(), responseTargetQueue_.size()); while (!requestTargetQueue_.empty()) { ISyncTarget *tmpTarget = nullptr; @@ -513,7 +513,7 @@ bool SingleVerSyncTaskContext::IsCurrentSyncTaskCanBeSkipped() const return false; } if (localWaterMark > maxTimeStampInDb) { - LOGI("skip current push task, deviceId_ = %s, localWaterMark = %llu, maxTimeStampInDb = %llu", + LOGI("skip current push task, deviceId_ = %s, localWaterMark = %" PRIu64 ", maxTimeStampInDb = %" PRIu64, STR_MASK(deviceId_), localWaterMark, maxTimeStampInDb); return true; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/subscribe_manager.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/subscribe_manager.cpp index ccff66498..572cd9154 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/subscribe_manager.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/subscribe_manager.cpp @@ -97,7 +97,7 @@ void SubscribeManager::DeleteRemoteSubscribeQuery(const std::string &device, con void SubscribeManager::PutLocalUnFiniedSubQueries(const std::string &device, std::vector &subscribeQueries) { - LOGI("[SubscribeManager] put local unfinished subscribe queries, nums=%d", subscribeQueries.size()); + LOGI("[SubscribeManager] put local unfinished subscribe queries, nums=%zu", subscribeQueries.size()); std::unique_lock lockGuard(localSubscribeMapLock_); if (subscribeQueries.size() == 0) { unFinishedLocalAutoSubMap_.erase(device); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp index 4b4821e9d..5a932f3b7 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp @@ -250,7 +250,7 @@ int SyncEngine::InitComunicator(const ISyncInterface *syncInterface) false); if (isSyncDualTupleMode) { std::vector dualTuplelabel = syncInterface->GetDualTupleIdentifier(); - LOGI("[SyncEngine] dual tuple mode, original identifier=%0.6s, target identifier=%0.6s", VEC_TO_STR(label), + LOGI("[SyncEngine] dual tuple mode, original identifier=%.6s, target identifier=%.6s", VEC_TO_STR(label), VEC_TO_STR(dualTuplelabel)); communicator_ = communicatorAggregator->AllocCommunicator(dualTuplelabel, errCode); } else { @@ -521,7 +521,7 @@ void SyncEngine::PutMsgIntoQueue(const std::string &targetDev, Message *inMsg, i inMsg->SetTarget(targetDev); msgQueue_.push_back(inMsg); queueCacheSize_ += msgSize; - LOGE("[SyncEngine] The quantity of executing threads is beyond maximum. msgQueueSize = %d", msgQueue_.size()); + LOGE("[SyncEngine] The quantity of executing threads is beyond maximum. msgQueueSize = %zu", msgQueue_.size()); } int SyncEngine::GetMsgSize(const Message *inMsg) const diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp index 92b7d1625..27931ba43 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp @@ -197,7 +197,7 @@ int TimeSync::SyncStart(const CommErrHandler &handler, uint32_t sessionId) TimeStamp startTime = timeHelper_->GetTime(); packet.SetSourceTimeBegin(startTime); // send timeSync request - LOGD("[TimeSync] startTime = %llu, dev = %s{private}", startTime, deviceId_.c_str()); + LOGD("[TimeSync] startTime = %" PRIu64 ", dev = %s{private}", startTime, deviceId_.c_str()); Message *message = new (std::nothrow) Message(TIME_SYNC_MESSAGE); if (message == nullptr) { @@ -341,7 +341,8 @@ int TimeSync::AckRecv(const Message *message, uint32_t targetSessionId) } // calculate timeoffset of two devices TimeOffset offset = CalculateTimeOffset(packetData); - LOGD("TimeSync::AckRecv, dev = %s{private}, sEnd = %llu, tEnd = %llu, sBegin = %llu, tBegin = %llu, offset = %lld", + LOGD("TimeSync::AckRecv, dev = %s{private}, sEnd = %" PRIu64 ", tEnd = %" PRIu64 ", sBegin = %" PRIu64 + ", tBegin = %" PRIu64 ", offset = %lld", deviceId_.c_str(), packetData.GetSourceTimeEnd(), packetData.GetTargetTimeEnd(), @@ -378,9 +379,9 @@ int TimeSync::RequestRecv(const Message *message) ackPacket.SetTargetTimeBegin(targetTimeBegin); TimeStamp targetTimeEnd = timeHelper_->GetTime(); ackPacket.SetTargetTimeEnd(targetTimeEnd); - LOGD("TimeSync::RequestRecv, dev = %s{private}, sTimeEnd = %llu, tTimeEnd = %llu, sbegin = %llu, tbegin = %llu", - deviceId_.c_str(), ackPacket.GetSourceTimeEnd(), ackPacket.GetTargetTimeEnd(), ackPacket.GetSourceTimeBegin(), - ackPacket.GetTargetTimeBegin()); + LOGD("TimeSync::RequestRecv, dev = %s{private}, sTimeEnd = %" PRIu64 ", tTimeEnd = %" PRIu64 ", sbegin = %" PRIu64 + ", tbegin = %" PRIu64, deviceId_.c_str(), ackPacket.GetSourceTimeEnd(), ackPacket.GetTargetTimeEnd(), + ackPacket.GetSourceTimeBegin(), ackPacket.GetTargetTimeBegin()); if (ackPacket.GetSourceTimeBegin() > TimeHelper::MAX_VALID_TIME) { LOGD("[TimeSync][RequestRecv] Time valid check failed."); return -E_INVALID_TIME; @@ -434,8 +435,8 @@ TimeOffset TimeSync::CalculateTimeOffset(const TimeSyncPacket &timeSyncInfo) TimeOffset offset2 = static_cast(timeSyncInfo.GetTargetTimeEnd() + (roundTrip / TRIP_DIV_HALF) - timeSyncInfo.GetSourceTimeEnd()); TimeOffset offset = (offset1 / TRIP_DIV_HALF) + (offset2 / TRIP_DIV_HALF); - LOGD("TimeSync::CalculateTimeOffset roundTrip= %lld, offset1 = %lld, offset2 = %lld, offset = %lld", - roundTrip, offset1, offset2, offset); + LOGD("TimeSync::CalculateTimeOffset roundTrip= %" PRId64 ", offset1 = %" PRId64 ", offset2 = %" PRId64 + ", offset = %" PRId64, roundTrip, offset1, offset2, offset); return offset; } @@ -499,7 +500,7 @@ int TimeSync::GetTimeOffset(TimeOffset &outOffset, uint32_t timeout, uint32_t se } CommErrHandler handler = std::bind(&TimeSync::CommErrHandlerFunc, std::placeholders::_1, this); int errCode = SyncStart(handler, sessionId); - LOGD("TimeSync::GetTimeOffset start, current time = %llu, errCode = %d,timeout = %u ms", + LOGD("TimeSync::GetTimeOffset start, current time = %" PRIu64 ", errCode = %d, timeout = %" PRIu32 " ms", TimeHelper::GetSysCurrentTime(), errCode, timeout); std::unique_lock lock(cvLock_); if (errCode != E_OK || !conditionVar_.wait_for(lock, std::chrono::milliseconds(timeout), diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp index 8946b09c7..6b19fa333 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp @@ -462,7 +462,8 @@ int ValueSliceSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t len // valueSlice DeSerialization packLen += parcel.ReadVectorChar(valueSlice); if (packLen != length || parcel.IsError()) { - LOGE("ValueSliceSync::AckPacketSerialization data error, packLen = %lu, length = %lu", packLen, length); + LOGE("ValueSliceSync::AckPacketSerialization data error, packLen = %" PRIu32 ", length = %" PRIu32, + packLen, length); return -E_INVALID_ARGS; } ValueSlicePacket *packet = new (std::nothrow) ValueSlicePacket(); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp index 1c3251594..eef31ab39 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp @@ -41,7 +41,7 @@ int KvVirtualDevice::GetData(const Key &key, Value &value) int KvVirtualDevice::PutData(const Key &key, const Value &value, const TimeStamp &time, int flag) { VirtualSingleVerSyncDBInterface *syncAble = static_cast(storage_); - LOGI("dev %s put data time %llu", deviceId_.c_str(), time); + LOGI("dev %s put data time %" PRIu64, deviceId_.c_str(), time); return syncAble->PutData(key, value, time, flag); } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.cpp index cd9a0fa63..db0cf78ed 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.cpp @@ -48,7 +48,7 @@ namespace { } entries.clear(); } - LOGD("[GetEntriesFromItems] size:%d", dataItems.size()); + LOGD("[GetEntriesFromItems] size:%zu", dataItems.size()); return errCode; } @@ -63,7 +63,7 @@ namespace { int VirtualRelationalVerSyncDBInterface::PutSyncDataWithQuery(const QueryObject &object, const std::vector &entries, const std::string &deviceName) { - LOGD("[PutSyncData] size %d", entries.size()); + LOGD("[PutSyncData] size %zu", entries.size()); std::vector dataItems; for (auto itemEntry : entries) { auto *entry = static_cast(itemEntry); @@ -95,7 +95,7 @@ int VirtualRelationalVerSyncDBInterface::PutSyncDataWithQuery(const QueryObject break; } DataValue dataValue = std::move(optItem); - LOGD("type:%d", optItem.GetType()); + LOGD("type:%d", static_cast(optItem.GetType())); virtualRowData.objectData.PutDataValue(localFieldInfo_[index].GetFieldName(), dataValue); index++; } @@ -223,7 +223,7 @@ void VirtualRelationalVerSyncDBInterface::GetMaxTimeStamp(TimeStamp &stamp) cons } } } - LOGD("VirtualSingleVerSyncDBInterface::GetMaxTimeStamp time = %llu", stamp); + LOGD("VirtualSingleVerSyncDBInterface::GetMaxTimeStamp time = %" PRIu64, stamp); } int VirtualRelationalVerSyncDBInterface::GetMetaData(const Key &key, Value &value) const @@ -269,7 +269,7 @@ int VirtualRelationalVerSyncDBInterface::GetAllMetaKeys(std::vector &keys) for (auto &iter : metadata_) { keys.push_back(iter.first); } - LOGD("GetAllMetaKeys size %d", keys.size()); + LOGD("GetAllMetaKeys size %zu", keys.size()); return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.cpp index b3aded370..9c7139d9d 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.cpp @@ -108,7 +108,7 @@ int VirtualSingleVerSyncDBInterface::GetAllMetaKeys(std::vector &keys) cons for (auto iter = metadata_.begin(); iter != metadata_.end(); ++iter) { keys.push_back(iter->first); } - LOGD("GetAllMetaKeys size %d", keys.size()); + LOGD("GetAllMetaKeys size %zu", keys.size()); return E_OK; } @@ -162,7 +162,7 @@ void VirtualSingleVerSyncDBInterface::GetMaxTimeStamp(TimeStamp& stamp) const stamp = iter->writeTimeStamp; } } - LOGD("VirtualSingleVerSyncDBInterface::GetMaxTimeStamp time = %llu", stamp); + LOGD("VirtualSingleVerSyncDBInterface::GetMaxTimeStamp time = %" PRIu64, stamp); } int VirtualSingleVerSyncDBInterface::RemoveDeviceData(const std::string &deviceName, bool isNeedNotify) @@ -219,7 +219,7 @@ int VirtualSingleVerSyncDBInterface::GetSyncData(TimeStamp begin, TimeStamp end, } } continueStmtToken = nullptr; - LOGD("dataItems size %d", dataItems.size()); + LOGD("dataItems size %zu", dataItems.size()); return E_OK; } @@ -246,7 +246,8 @@ int VirtualSingleVerSyncDBInterface::PutSyncData(std::vector& d [iter](VirtualDataItem item) { return item.key == iter->key; }); if ((dbDataIter != dbData_.end()) && (dbDataIter->writeTimeStamp < iter->writeTimeStamp)) { // if has conflict, compare writeTimeStamp - LOGI("conflict data time local %llu, remote %llu", dbDataIter->writeTimeStamp, iter->writeTimeStamp); + LOGI("conflict data time local %" PRIu64 ", remote %" PRIu64, dbDataIter->writeTimeStamp, + iter->writeTimeStamp); dbDataIter->key = iter->key; dbDataIter->value = iter->value; dbDataIter->timeStamp = iter->timeStamp; @@ -254,7 +255,7 @@ int VirtualSingleVerSyncDBInterface::PutSyncData(std::vector& d dbDataIter->flag = iter->flag; dbDataIter->isLocal = false; } else { - LOGI("PutSyncData, use remote data %llu", iter->timeStamp); + LOGI("PutSyncData, use remote data %" PRIu64, iter->timeStamp); VirtualDataItem dataItem; dataItem.key = iter->key; dataItem.value = iter->value; @@ -333,7 +334,7 @@ int VirtualSingleVerSyncDBInterface::GetSyncData(QueryObject &query, const SyncT } } - LOGD("dataItems size %d", dataItems.size()); + LOGD("dataItems size %zu", dataItems.size()); return GetEntriesFromItems(entries, dataItems); } -- Gitee From 2cf39d74f992065b73114d108d8582f0af8d233c Mon Sep 17 00:00:00 2001 From: zqq Date: Wed, 23 Mar 2022 09:19:32 +0800 Subject: [PATCH 07/20] check define macro Signed-off-by: zqq --- .../libs/distributeddb/common/include/log_print.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/distributeddataservice/libs/distributeddb/common/include/log_print.h b/services/distributeddataservice/libs/distributeddb/common/include/log_print.h index 697a2986c..df545b16c 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/log_print.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/log_print.h @@ -16,7 +16,9 @@ #ifndef DISTRIBUTEDDB_LOG_PRINT_H #define DISTRIBUTEDDB_LOG_PRINT_H +#ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS +#endif #include #include #include -- Gitee From e578af4fefe5fbdcc4c2848815cc522f93a71ecd Mon Sep 17 00:00:00 2001 From: zqq Date: Wed, 23 Mar 2022 10:31:23 +0800 Subject: [PATCH 08/20] format log print Signed-off-by: zqq --- .../libs/distributeddb/syncer/src/meta_data.cpp | 2 +- .../distributeddb/syncer/src/single_ver_data_sync.cpp | 11 ++++++----- .../libs/distributeddb/syncer/src/time_sync.cpp | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp index 485f8d8f1..ed1060c76 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp @@ -124,7 +124,7 @@ int Metadata::SavePeerWaterMark(const DeviceID &deviceId, uint64_t inValue, bool std::lock_guard lockGuard(metadataLock_); GetMetaDataValue(deviceId, metadata, isNeedHash); metadata.peerWaterMark = inValue; - LOGD("Metadata::SavePeerWaterMark = %llu", inValue); + LOGD("Metadata::SavePeerWaterMark = %" PRIu64, inValue); return SaveMetaDataValue(deviceId, metadata); } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp index de566bf06..0fbc3153f 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp @@ -661,7 +661,7 @@ void SingleVerDataSync::FillDataRequestPacket(DataRequestPacket *packet, SingleV packet->SetUpdateWaterMark(); } LOGD("[DataSync] curType=%d,local=%" PRIu64 ",del=%" PRIu64 ",end=%" PRIu64 ",label=%s,dev=%s,queryId=%s," - "isCompress=%d", curType, localMark, deleteMark, context->GetEndMark(), label_.c_str(), + "isCompress=%d", static_cast(curType), localMark, deleteMark, context->GetEndMark(), label_.c_str(), STR_MASK(GetDeviceId()), STR_MASK(context->GetQuery().GetIdentify()), packet->IsCompressData()); } @@ -777,7 +777,8 @@ int SingleVerDataSync::PullRequestStart(SingleVerSyncTaskContext *context) SingleVerDataSyncUtils::SetPacketId(packet, context, version); LOGD("[DataSync][Pull] curType=%d,local=%" PRIu64 ",del=%" PRIu64 ",end=%" PRIu64 ",peer=%" PRIu64 ",label=%s," - "dev=%s", syncType, localMark, deleteMark, endMark, peerMark, label_.c_str(), STR_MASK(GetDeviceId())); + "dev=%s", static_cast(syncType), localMark, deleteMark, endMark, peerMark, label_.c_str(), + STR_MASK(GetDeviceId())); UpdateSendInfo(dataTime, context); return SendDataPacket(syncType, packet, context); } @@ -942,9 +943,9 @@ int SingleVerDataSync::DataRequestRecv(SingleVerSyncTaskContext *context, const const DataRequestPacket *packet = message->GetObject(); const std::vector &data = packet->GetData(); SyncType curType = SyncOperation::GetSyncType(packet->GetMode()); - LOGI("[DataSync][DataRequestRecv] curType=%d,remote ver=%zu,size=%d,errCode=%d,queryId=%s,Label=%s,dev=%s", - curType, packet->GetVersion(), data.size(), packet->GetSendCode(), STR_MASK(packet->GetQueryId()), - label_.c_str(), STR_MASK(GetDeviceId())); + LOGI("[DataSync][DataRequestRecv] curType=%d, remote ver=%" PRIu32 ", size=%zu, errCode=%d, queryId=%s," + " Label=%s, dev=%s", static_cast(curType), packet->GetVersion(), data.size(), packet->GetSendCode(), + STR_MASK(packet->GetQueryId()), label_.c_str(), STR_MASK(GetDeviceId())); context->SetReceiveWaterMarkErr(false); UpdateWaterMark isUpdateWaterMark; SyncTimeRange dataTime = SingleVerDataSyncUtils::GetRecvDataTimeRange(curType, data, isUpdateWaterMark); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp index 27931ba43..af93c5574 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp @@ -342,7 +342,7 @@ int TimeSync::AckRecv(const Message *message, uint32_t targetSessionId) // calculate timeoffset of two devices TimeOffset offset = CalculateTimeOffset(packetData); LOGD("TimeSync::AckRecv, dev = %s{private}, sEnd = %" PRIu64 ", tEnd = %" PRIu64 ", sBegin = %" PRIu64 - ", tBegin = %" PRIu64 ", offset = %lld", + ", tBegin = %" PRIu64 ", offset = %" PRId64, deviceId_.c_str(), packetData.GetSourceTimeEnd(), packetData.GetTargetTimeEnd(), -- Gitee From 15c8c57374e69e56cc50c178faaed1e2751373e7 Mon Sep 17 00:00:00 2001 From: lidwchn Date: Thu, 24 Mar 2022 10:52:21 +0800 Subject: [PATCH 09/20] Fix issue. Signed-off-by: lidwchn --- .../communicator/src/protocol_proto.cpp | 7 +++--- .../storage/src/generic_kvdb.cpp | 5 ++++ .../storage/src/generic_kvdb_connection.cpp | 25 ++++++++++++++++--- .../kvdb_commit_notify_filterable_data.cpp | 2 +- .../sqlite_relational_store_connection.cpp | 2 ++ .../src/sqlite/sqlite_storage_engine.cpp | 1 + .../distributeddb_communicator_common.h | 5 +++- 7 files changed, 39 insertions(+), 8 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp index a31c2689b..eb599db26 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp @@ -811,7 +811,7 @@ int ProtocolProto::ParseCommDivergeHeader(const uint8_t *bytes, uint32_t length, } uint16_t version = NetToHost(*(reinterpret_cast(bytes + sizeof(CommPhyHeader)))); if (version != PROTOCOL_VERSION) { - LOGE("[Proto][ParseDiverge] Version=%u not support.", version); + LOGE("[Proto][ParseDiverge] Version=%" PRIu16 " not support.", version); return -E_VERSION_NOT_SUPPORT; } @@ -930,7 +930,7 @@ int ProtocolProto::FrameFragmentation(const uint8_t *splitStartBytes, const Fram const CommPhyHeader &framePhyHeader, std::vector, uint32_t>> &outPieces) { // It can be guaranteed that fragCount >= 2 and also won't be too large - if (fragmentInfo.fragCount < 2) { + if (fragmentInfo.fragCount < MIN_FRAGMENT_COUNT) { return -E_INVALID_ARGS; } outPieces.resize(fragmentInfo.fragCount); // Note: should use resize other than reserve @@ -979,7 +979,8 @@ int ProtocolProto::FrameFragmentation(const uint8_t *splitStartBytes, const Fram pieceFragLen, packet); entry.second = fragmentInfo.extendHeadSize; if (err != E_OK) { - LOGE("[Proto][FrameFrag] Fill packet fail, fragCount=%u, fragNo=%u", fragmentInfo.fragCount, fragNo); + LOGE("[Proto][FrameFrag] Fill packet fail, fragCount=%" PRIu16 ", fragNo=%" PRIu16, + fragmentInfo.fragCount, fragNo); return err; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp index e19fbaf4a..4184ad268 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp @@ -342,11 +342,15 @@ uint32_t GenericKvDB::GetRegisterFunctionCount(RegisterFuncType type) const int GenericKvDB::TransObserverTypeToRegisterFunctionType(int observerType, RegisterFuncType &type) const { + (void)observerType; + (void)type; return -E_NOT_SUPPORT; } int GenericKvDB::TransConflictTypeToRegisterFunctionType(int conflictType, RegisterFuncType &type) const { + (void)conflictType; + (void)type; return -E_NOT_SUPPORT; } @@ -371,6 +375,7 @@ bool GenericKvDB::IsDataMigrating() const void GenericKvDB::SetConnectionFlag(bool isExisted) const { + (void)isExisted; return; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb_connection.cpp index d3602d5ce..464d9850a 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb_connection.cpp @@ -168,6 +168,8 @@ int GenericKvDBConnection::UnRegisterObserver(const KvDBObserverHandle *observer int GenericKvDBConnection::SetConflictNotifier(int conflictType, const KvDBConflictAction &action) { + (void)conflictType; + (void)action; return -E_NOT_SUPPORT; } @@ -203,6 +205,8 @@ std::string GenericKvDBConnection::GetIdentifier() const int GenericKvDBConnection::Pragma(int cmd, void *parameter) { + (void)cmd; + (void)parameter; return -E_NOT_SUPPORT; } @@ -218,38 +222,53 @@ void GenericKvDBConnection::SetSafeDeleted() int GenericKvDBConnection::GetEntries(const IOption &option, const Key &keyPrefix, std::vector &entries) const { + (void)option; + (void)keyPrefix; + (void)entries; return -E_NOT_SUPPORT; } int GenericKvDBConnection::GetEntries(const IOption &option, const Query &query, std::vector &entries) const { + (void)option; + (void)query; + (void)entries; return -E_NOT_SUPPORT; } -int GenericKvDBConnection::GetResultSet(const IOption &option, const Key &keyPrefix, - IKvDBResultSet *&resultSet) const +int GenericKvDBConnection::GetResultSet(const IOption &option, const Key &keyPrefix, IKvDBResultSet *&resultSet) const { + (void)option; + (void)keyPrefix; + (void)resultSet; return -E_NOT_SUPPORT; } int GenericKvDBConnection::GetResultSet(const IOption &option, const Query &query, IKvDBResultSet *&resultSet) const { + (void)option; + (void)query; + (void)resultSet; return -E_NOT_SUPPORT; } int GenericKvDBConnection::GetCount(const IOption &option, const Query &query, int &count) const { + (void)option; + (void)query; + (void)count; return -E_NOT_SUPPORT; } void GenericKvDBConnection::ReleaseResultSet(IKvDBResultSet *&resultSet) { + (void)resultSet; return; } int GenericKvDBConnection::RegisterLifeCycleCallback(const DatabaseLifeCycleNotifier ¬ifier) { - (void) notifier; + (void)notifier; return -E_NOT_SUPPORT; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp index ee3dd9233..3007d8566 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp @@ -75,7 +75,7 @@ bool KvDBCommitNotifyFilterAbleData::IsConflictedDataEmpty() const void KvDBCommitNotifyFilterAbleData::SetFilterKey(const Key &key) { - (void) key; + (void)key; return; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp index c43ef227d..41a30fabc 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp @@ -164,6 +164,8 @@ int SQLiteRelationalStoreConnection::RemoveDeviceData(const std::string &device, int SQLiteRelationalStoreConnection::Pragma(int cmd, void *parameter) // reserve for interface function fix { + (void)cmd; + (void)parameter; return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp index 0d6084c9a..b7ed3b1fc 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp @@ -63,6 +63,7 @@ int SQLiteStorageEngine::Upgrade(sqlite3 *db) // SQLiteLocalStorageEngine do not override this function so content upgrade can only be done by the Storage // who use the SQLiteLocalKvDB. // MultiVerStorageEngine do not inherit SQLiteStorageEngine. + (void)db; return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/distributeddb_communicator_common.h b/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/distributeddb_communicator_common.h index 59e08f15e..04f9c5d2d 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/distributeddb_communicator_common.h +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/distributeddb_communicator_common.h @@ -101,7 +101,10 @@ public: for (uint8_t i = 0; i < BUFF_LEN; i++) { info.userId[i] = localDbProperty_.userId[i]; } - memcpy_s(data, totalLen, &info, sizeof(ExtendHeadInfo)); + auto errCode = memcpy_s(data, totalLen, &info, sizeof(ExtendHeadInfo)); + if (errCode != EOK) { + return DistributedDB::DB_ERROR; + } return DistributedDB::OK; }; static constexpr int MAGIC_NUM = 0xF2; -- Gitee From 722f3c48c7c6ddb5b730258cf1dfcee7c6afb416 Mon Sep 17 00:00:00 2001 From: lianhuix Date: Wed, 23 Mar 2022 17:17:36 +0800 Subject: [PATCH 10/20] Fix code check Signed-off-by: lianhuix --- .../libs/distributeddb/common/src/parcel.cpp | 4 ++-- .../libs/distributeddb/syncer/src/time_sync.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp b/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp index d7eb4d9ee..372a9bfc6 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp @@ -164,14 +164,14 @@ int Parcel::WriteString(const std::string &inVal) uint64_t stepLen = sizeof(uint32_t) + static_cast(inVal.size()); len = HostToNet(len); if (stepLen > INT32_MAX || parcelLen_ + BYTE_8_ALIGN(stepLen) > totalLen_) { - LOGE("[WriteString] stepLen:%" PRIu64 ", totalLen:%" PRIu64 ", parcelLen:%" PRIu64 , stepLen, totalLen_, + LOGE("[WriteString] stepLen:%" PRIu64 ", totalLen:%" PRIu64 ", parcelLen:%" PRIu64, stepLen, totalLen_, parcelLen_); isError_ = true; return -E_PARSE_FAIL; } errno_t errCode = memcpy_s(bufPtr_, totalLen_ - parcelLen_, &len, sizeof(uint32_t)); if (errCode != EOK) { - LOGE("[WriteString] bufPtr:%d, totalLen:%" PRIu64 ", parcelLen:%" PRIu64 , bufPtr_ != nullptr, totalLen_, + LOGE("[WriteString] bufPtr:%d, totalLen:%" PRIu64 ", parcelLen:%" PRIu64, bufPtr_ != nullptr, totalLen_, parcelLen_); isError_ = true; return -E_SECUREC_ERROR; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp index af93c5574..f0d865527 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp @@ -341,7 +341,7 @@ int TimeSync::AckRecv(const Message *message, uint32_t targetSessionId) } // calculate timeoffset of two devices TimeOffset offset = CalculateTimeOffset(packetData); - LOGD("TimeSync::AckRecv, dev = %s{private}, sEnd = %" PRIu64 ", tEnd = %" PRIu64 ", sBegin = %" PRIu64 + LOGD("TimeSync::AckRecv, dev = %s{private}, sEnd = %" PRIu64 ", tEnd = %" PRIu64 ", sBegin = %" PRIu64 ", tBegin = %" PRIu64 ", offset = %" PRId64, deviceId_.c_str(), packetData.GetSourceTimeEnd(), -- Gitee From ec03d6a36783596a73b27304115dd4aad9e0694e Mon Sep 17 00:00:00 2001 From: lianhuix Date: Thu, 24 Mar 2022 16:17:12 +0800 Subject: [PATCH 11/20] Fix code reviews Signed-off-by: lianhuix --- .../distributeddb/common/src/data_compression.cpp | 1 - .../common/src/evloop/src/event_impl.cpp | 13 +++---------- .../common/src/evloop/src/event_loop_impl.cpp | 6 +----- .../common/src/evloop/src/event_loop_select.cpp | 4 ++-- .../common/src/evloop/src/event_loop_select.h | 2 +- .../distributeddb/common/src/evloop/src/ievent.cpp | 2 +- .../distributeddb/common/src/flatbuffer_schema.cpp | 2 +- .../libs/distributeddb/common/src/schema_utils.cpp | 4 ++-- .../distributeddb_interfaces_index_unit_test.cpp | 2 +- ...distributeddb_nb_predicate_query_expand_test.cpp | 2 +- 10 files changed, 13 insertions(+), 25 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/common/src/data_compression.cpp b/services/distributeddataservice/libs/distributeddb/common/src/data_compression.cpp index 8465e9df4..c0b221f06 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/data_compression.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/data_compression.cpp @@ -24,7 +24,6 @@ void DataCompression::GetCompressionAlgo(std::set &algorithmS for (const auto &item : GetCompressionAlgos()) { algorithmSet.insert(item.first); } - return; } int DataCompression::TransferCompressionAlgo(uint32_t compressAlgoType, CompressAlgorithm &algoType) diff --git a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_impl.cpp b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_impl.cpp index c33970d9b..d4e44d7a1 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_impl.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_impl.cpp @@ -368,20 +368,13 @@ int EventImpl::Dispatch() bool EventImpl::IsValidArg(EventsMask events) const { EventsMask allEvents = ET_READ | ET_WRITE | ET_ERROR | ET_TIMEOUT; - if (!events || (events & (~allEvents))) { - return false; - } - return true; + return events && !(events & (~allEvents)); } bool EventImpl::IsValidArg(EventTime timeout) const { - if ((timeout < 0) || (timeout > MAX_TIME_VALUE)) { - return false; - } - return true; + return (timeout >= 0) && (timeout <= MAX_TIME_VALUE); } DEFINE_OBJECT_TAG_FACILITIES(EventImpl) -} - +} // namespace DistributedDB diff --git a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp index 826a65322..bc920a864 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp @@ -308,11 +308,7 @@ bool EventLoopImpl::IsInLoopThread(bool &started) const bool EventLoopImpl::EventObjectExists(EventImpl *event) const { - auto it = polling_.find(event); - if (it != polling_.end()) { - return true; - } - return false; + return polling_.find(event) != polling_.end(); } bool EventLoopImpl::EventFdExists(const EventImpl *event) const diff --git a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp index a9ba7c311..b26b382ff 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp @@ -82,6 +82,6 @@ int EventLoopSelect::ModifyEvent(EventImpl *event, bool isAdd, EventsMask events } DEFINE_OBJECT_TAG_FACILITIES(EventLoopSelect) -} +} // namespace DistributedDB -#endif +#endif // EVENT_LOOP_USE_SELECT diff --git a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.h b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.h index 79a6fbdd6..a4d77d15f 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.h +++ b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.h @@ -44,6 +44,6 @@ private: std::mutex wakeUpMutex_; std::condition_variable wakeUpCondition_; }; -} +} // namespace DistributedDB #endif // EVENT_LOOP_USE_SELECT #endif // EVENT_LOOP_SELECT_H diff --git a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/ievent.cpp b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/ievent.cpp index a033d06b9..361edfe06 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/ievent.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/ievent.cpp @@ -56,4 +56,4 @@ IEvent *IEvent::CreateEvent(EventFd fd, EventsMask events, errCode = E_OK; return event; } -} +} // namespace DistributedDB diff --git a/services/distributeddataservice/libs/distributeddb/common/src/flatbuffer_schema.cpp b/services/distributeddataservice/libs/distributeddb/common/src/flatbuffer_schema.cpp index e1524f4f9..3ba5419be 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/flatbuffer_schema.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/flatbuffer_schema.cpp @@ -503,7 +503,7 @@ int SchemaObject::FlatBufferSchema::ParseCheckRootTableAttribute(const reflectio return E_OK; } std::string skipsizeStr = SchemaUtils::Strip(skipsizeAttr->value()->str()); - int skipsizeInt = std::atoi(skipsizeStr.c_str()); // std::stoi will throw exception + int skipsizeInt = strtol(skipsizeStr.c_str(), nullptr, 10); // 10: decimal if (std::to_string(skipsizeInt) != skipsizeStr || skipsizeInt < 0 || static_cast(skipsizeInt) > SchemaConstant::SCHEMA_SKIPSIZE_MAX) { LOGE("[FBSchema][ParseRootAttr] Unexpect SCHEMA_SKIPSIZE value=%s.", skipsizeAttr->value()->c_str()); diff --git a/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp b/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp index cb6fbb42d..fe8cdd610 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp @@ -157,7 +157,7 @@ int SchemaUtils::TransToInteger(const std::string &defaultContent, SchemaAttribu if (defaultContent.empty()) { return -E_SCHEMA_PARSE_FAIL; } - int transRes = std::atoi(defaultContent.c_str()); + int transRes = strtol(defaultContent.c_str(), nullptr, 10); // 10: decimal std::string resReview = std::to_string(transRes); if (defaultContent.compare(defaultContent.find_first_not_of("+- "), defaultContent.size(), resReview, resReview.find_first_not_of("+- "), resReview.size()) == 0) { @@ -179,7 +179,7 @@ int SchemaUtils::TransToLong(const std::string &defaultContent, SchemaAttribute if (defaultContent.empty()) { return -E_SCHEMA_PARSE_FAIL; } - int64_t transRes = std::atoll(defaultContent.c_str()); + int64_t transRes = strtoll(defaultContent.c_str(), nullptr, 10); // 10: decimal std::string resReview = std::to_string(transRes); if (defaultContent.compare(defaultContent.find_first_not_of("+- "), defaultContent.size(), resReview, resReview.find_first_not_of("+- "), resReview.size()) == 0) { diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_index_unit_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_index_unit_test.cpp index 88935b39e..895eb2f27 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_index_unit_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_index_unit_test.cpp @@ -73,7 +73,7 @@ namespace { int CallbackReturnCount(void *data, int argc, char **argv, char **azColName) { if (argc == 1) { - int count = atoi(*(argv)); + int count = strtol(*(argv), nullptr, 10); // 10: decimal if (data != nullptr) { int *mid = static_cast(data); *mid = count; diff --git a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp index d5301b6e9..cf58ef226 100644 --- a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp +++ b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp @@ -1100,7 +1100,7 @@ void MoveCursor(KvStoreResultSet &resultSet, const vector &entriesBatch) { int currentPosition = CURSOR_POSITION_NEGATIVE1; Entry entry; - bool result; + bool result = false; for (int position = CURSOR_POSITION_NEGATIVE1; position < TEN_RECORDS; ++position) { result = resultSet.MoveToNext(); if (position < (TEN_RECORDS - CURSOR_POSITION_1)) { -- Gitee From 164771eb9aa0842d82db926439c703d5db98e01b Mon Sep 17 00:00:00 2001 From: lianhuix Date: Thu, 24 Mar 2022 19:30:56 +0800 Subject: [PATCH 12/20] Fix code reviews Signed-off-by: lianhuix --- .../libs/distributeddb/communicator/src/protocol_proto.cpp | 4 ++-- .../libs/distributeddb/syncer/src/ability_sync.cpp | 2 +- .../distributeddb/syncer/src/multi_ver_sync_state_machine.cpp | 4 +++- .../libs/distributeddb/syncer/src/time_helper.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp index eb599db26..84d3cca61 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp @@ -979,8 +979,8 @@ int ProtocolProto::FrameFragmentation(const uint8_t *splitStartBytes, const Fram pieceFragLen, packet); entry.second = fragmentInfo.extendHeadSize; if (err != E_OK) { - LOGE("[Proto][FrameFrag] Fill packet fail, fragCount=%" PRIu16 ", fragNo=%" PRIu16, - fragmentInfo.fragCount, fragNo); + LOGE("[Proto][FrameFrag] Fill packet fail, fragCount=%" PRIu16 ", fragNo=%" PRIu16, fragmentInfo.fragCount, + fragNo); return err; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp index fe0473973..f50b713f0 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp @@ -459,7 +459,7 @@ int AbilitySync::AckNotifyRecv(const Message *message, ISyncTaskContext *context } int errCode = packet->GetAckCode(); if (errCode != E_OK) { - LOGE("[AbilitySync][AckNotifyRecv] received a errCode %d", errCode); + LOGE("[AbilitySync][AckNotifyRecv] received an errCode %d", errCode); return errCode; } std::string schema = packet->GetSchema(); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp index 7d9175f64..1a9c5a9a5 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp @@ -305,7 +305,9 @@ int MultiVerSyncStateMachine::PrepareNextSyncTask() void MultiVerSyncStateMachine::SendSaveDataNotifyPacket(uint32_t sessionId, uint32_t sequenceId, uint32_t inMsgId) { - (void) sequenceId; + (void)sessionId; + (void)sequenceId; + (void)inMsgId; } void MultiVerSyncStateMachine::CommErrAbort() diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.cpp index a0374f7be..2e7727853 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.cpp @@ -75,7 +75,7 @@ int TimeHelper::Initialize(const ISyncInterface *inStorage, std::shared_ptr(maxItemTime - currentSysTime + MS_TO_100_NS); // 1ms int errCode = SaveLocalTimeOffset(localTimeOffset); if (errCode != E_OK) { - LOGE("[TimeHelper] save local time offset faield,err=%d", errCode); + LOGE("[TimeHelper] save local time offset failed,err=%d", errCode); return errCode; } } -- Gitee From 3dce8f978c84c0ee2f6db28e2354b9450a18d4ac Mon Sep 17 00:00:00 2001 From: zqq Date: Sat, 5 Mar 2022 18:17:51 +0800 Subject: [PATCH 13/20] move file location Signed-off-by: zqq --- services/distributeddataservice/libs/distributeddb/BUILD.gn | 2 +- .../libs/distributeddb/{common => syncer}/src/db_ability.cpp | 0 .../distributeddb/{common/include => syncer/src}/db_ability.h | 0 .../libs/distributeddb/syncer/{include => src}/sync_config.h | 0 .../distributeddataservice/libs/distributeddb/test/BUILD.gn | 2 +- 5 files changed, 2 insertions(+), 2 deletions(-) rename services/distributeddataservice/libs/distributeddb/{common => syncer}/src/db_ability.cpp (100%) rename services/distributeddataservice/libs/distributeddb/{common/include => syncer/src}/db_ability.h (100%) rename services/distributeddataservice/libs/distributeddb/syncer/{include => src}/sync_config.h (100%) diff --git a/services/distributeddataservice/libs/distributeddb/BUILD.gn b/services/distributeddataservice/libs/distributeddb/BUILD.gn index af085b71b..66f52258a 100644 --- a/services/distributeddataservice/libs/distributeddb/BUILD.gn +++ b/services/distributeddataservice/libs/distributeddb/BUILD.gn @@ -67,7 +67,6 @@ ohos_shared_library("distributeddb") { "common/src/auto_launch.cpp", "common/src/data_compression.cpp", "common/src/data_value.cpp", - "common/src/db_ability.cpp", "common/src/db_common.cpp", "common/src/db_constant.cpp", "common/src/evloop/src/event_impl.cpp", @@ -209,6 +208,7 @@ ohos_shared_library("distributeddb") { "syncer/src/ability_sync.cpp", "syncer/src/commit_history_sync.cpp", "syncer/src/communicator_proxy.cpp", + "syncer/src/db_ability.cpp", "syncer/src/device_manager.cpp", "syncer/src/generic_syncer.cpp", "syncer/src/meta_data.cpp", diff --git a/services/distributeddataservice/libs/distributeddb/common/src/db_ability.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/db_ability.cpp similarity index 100% rename from services/distributeddataservice/libs/distributeddb/common/src/db_ability.cpp rename to services/distributeddataservice/libs/distributeddb/syncer/src/db_ability.cpp diff --git a/services/distributeddataservice/libs/distributeddb/common/include/db_ability.h b/services/distributeddataservice/libs/distributeddb/syncer/src/db_ability.h similarity index 100% rename from services/distributeddataservice/libs/distributeddb/common/include/db_ability.h rename to services/distributeddataservice/libs/distributeddb/syncer/src/db_ability.h diff --git a/services/distributeddataservice/libs/distributeddb/syncer/include/sync_config.h b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_config.h similarity index 100% rename from services/distributeddataservice/libs/distributeddb/syncer/include/sync_config.h rename to services/distributeddataservice/libs/distributeddb/syncer/src/sync_config.h diff --git a/services/distributeddataservice/libs/distributeddb/test/BUILD.gn b/services/distributeddataservice/libs/distributeddb/test/BUILD.gn index e5c07e313..c0be53fcf 100644 --- a/services/distributeddataservice/libs/distributeddb/test/BUILD.gn +++ b/services/distributeddataservice/libs/distributeddb/test/BUILD.gn @@ -70,7 +70,6 @@ ohos_source_set("src_file") { "../common/src/auto_launch.cpp", "../common/src/data_compression.cpp", "../common/src/data_value.cpp", - "../common/src/db_ability.cpp", "../common/src/db_common.cpp", "../common/src/db_constant.cpp", "../common/src/evloop/src/event_impl.cpp", @@ -212,6 +211,7 @@ ohos_source_set("src_file") { "../syncer/src/ability_sync.cpp", "../syncer/src/commit_history_sync.cpp", "../syncer/src/communicator_proxy.cpp", + "../syncer/src/db_ability.cpp", "../syncer/src/device_manager.cpp", "../syncer/src/generic_syncer.cpp", "../syncer/src/meta_data.cpp", -- Gitee From 556239c162a1110a93ea4c6c589c256ef4f365ee Mon Sep 17 00:00:00 2001 From: lianhuix Date: Thu, 24 Mar 2022 11:03:19 +0800 Subject: [PATCH 14/20] Case timestamp Signed-off-by: lianhuix --- .../kvstore_flowctrl_manager.cpp | 10 +- .../kvstore_flowctrl_manager.h | 4 +- .../distributeddb/common/include/db_types.h | 16 +- .../common/include/performance_analysis.h | 8 +- .../common/include/runtime_context.h | 2 +- .../common/src/performance_analysis.cpp | 2 +- .../common/src/runtime_context_impl.cpp | 4 +- .../common/src/runtime_context_impl.h | 2 +- .../common/src/time_tick_monitor.cpp | 4 +- .../common/src/time_tick_monitor.h | 8 +- .../relational_store_sqlite_ext.cpp | 48 ++--- .../relational/relational_sync_able_storage.h | 10 +- .../storage/include/isync_interface.h | 2 +- .../storage/include/single_ver_kv_entry.h | 8 +- .../include/single_ver_kvdb_sync_interface.h | 2 +- .../storage/include/sync_generic_interface.h | 6 +- .../storage/src/data_transformer.cpp | 8 +- .../storage/src/data_transformer.h | 4 +- .../src/generic_single_ver_kv_entry.cpp | 32 +-- .../storage/src/generic_single_ver_kv_entry.h | 8 +- .../distributeddb/storage/src/ikvdb_commit.h | 4 +- .../multiver/ikvdb_multi_ver_data_storage.h | 4 +- .../multiver/ikvdb_multi_ver_transaction.h | 6 +- .../storage/src/multiver/multi_ver_commit.cpp | 4 +- .../storage/src/multiver/multi_ver_commit.h | 6 +- .../src/multiver/multi_ver_natural_store.cpp | 8 +- .../src/multiver/multi_ver_natural_store.h | 6 +- ...multi_ver_natural_store_commit_storage.cpp | 2 +- .../multiver/multi_ver_storage_executor.cpp | 22 +- .../src/multiver/multi_ver_storage_executor.h | 2 +- .../src/relational_sync_able_storage.cpp | 24 +-- ...e_ver_natural_store_commit_notify_data.cpp | 2 +- .../sqlite/sqlite_multi_ver_data_storage.cpp | 6 +- .../sqlite/sqlite_multi_ver_data_storage.h | 2 +- .../sqlite/sqlite_multi_ver_transaction.cpp | 24 +-- .../src/sqlite/sqlite_multi_ver_transaction.h | 10 +- .../src/sqlite/sqlite_query_helper.cpp | 4 +- .../storage/src/sqlite/sqlite_query_helper.h | 2 +- .../sqlite_single_ver_continue_token.cpp | 30 +-- .../sqlite/sqlite_single_ver_continue_token.h | 20 +- .../sqlite_single_ver_natural_store.cpp | 72 +++---- .../sqlite/sqlite_single_ver_natural_store.h | 22 +- ...te_single_ver_natural_store_connection.cpp | 74 +++---- ...lite_single_ver_natural_store_connection.h | 4 +- ...e_single_ver_relational_continue_token.cpp | 2 +- ...single_ver_relational_storage_executor.cpp | 36 ++-- ...e_single_ver_relational_storage_executor.h | 14 +- .../sqlite_single_ver_storage_engine.cpp | 14 +- .../sqlite/sqlite_single_ver_storage_engine.h | 2 +- .../sqlite_single_ver_storage_executor.cpp | 78 +++---- .../sqlite_single_ver_storage_executor.h | 52 ++--- ...lite_single_ver_storage_executor_cache.cpp | 48 ++--- ..._single_ver_storage_executor_subscribe.cpp | 6 +- .../storage/src/sync_able_engine.cpp | 4 +- .../storage/src/sync_able_engine.h | 2 +- .../storage/src/sync_able_kvdb.cpp | 4 +- .../storage/src/sync_able_kvdb.h | 2 +- .../distributeddb/syncer/include/isyncer.h | 2 +- .../syncer/include/syncer_proxy.h | 2 +- .../distributeddb/syncer/src/ability_sync.cpp | 8 +- .../syncer/src/generic_syncer.cpp | 4 +- .../distributeddb/syncer/src/generic_syncer.h | 2 +- .../syncer/src/isync_task_context.h | 2 +- .../distributeddb/syncer/src/meta_data.cpp | 12 +- .../libs/distributeddb/syncer/src/meta_data.h | 12 +- .../src/multi_ver_sync_state_machine.cpp | 20 +- .../src/query_sync_water_mark_helper.cpp | 8 +- .../syncer/src/query_sync_water_mark_helper.h | 6 +- .../syncer/src/single_ver_data_sync.cpp | 26 +-- .../syncer/src/single_ver_data_sync.h | 24 +-- .../syncer/src/single_ver_data_sync_utils.cpp | 36 ++-- .../syncer/src/single_ver_data_sync_utils.h | 2 +- .../src/single_ver_sync_task_context.cpp | 12 +- .../distributeddb/syncer/src/sync_engine.cpp | 8 +- .../syncer/src/sync_task_context.cpp | 2 +- .../syncer/src/sync_task_context.h | 2 +- .../distributeddb/syncer/src/syncer_proxy.cpp | 6 +- .../distributeddb/syncer/src/time_helper.cpp | 28 +-- .../distributeddb/syncer/src/time_helper.h | 14 +- .../distributeddb/syncer/src/time_sync.cpp | 40 ++-- .../libs/distributeddb/syncer/src/time_sync.h | 24 +-- .../common/distributeddb_auto_launch_test.cpp | 6 +- .../common/distributeddb_tools_unit_test.cpp | 2 +- ...tributeddb_interfaces_auto_launch_test.cpp | 4 +- .../distributeddb_data_transformer_test.cpp | 2 +- ...distributeddb_relational_get_data_test.cpp | 8 +- ...tributeddb_storage_commit_storage_test.cpp | 28 +-- ..._memory_single_ver_naturall_store_test.cpp | 36 ++-- .../distributeddb_storage_query_sync_test.cpp | 14 +- ...buteddb_storage_register_conflict_test.cpp | 20 +- ...buteddb_storage_register_observer_test.cpp | 26 +-- ...rage_single_ver_natural_store_testcase.cpp | 196 +++++++++--------- ...torage_single_ver_natural_store_testcase.h | 6 +- ...uteddb_storage_single_ver_upgrade_test.cpp | 2 +- ...e_sqlite_single_ver_natural_store_test.cpp | 36 ++-- ...ributeddb_storage_subscribe_query_test.cpp | 8 +- ...ibuteddb_storage_transaction_data_test.cpp | 24 +-- .../distributeddb_mock_sync_module_test.cpp | 4 +- .../distributeddb_multi_ver_p2p_sync_test.cpp | 4 +- ...stributeddb_single_ver_multi_user_test.cpp | 4 +- ...buteddb_single_ver_p2p_sync_check_test.cpp | 2 +- .../common/syncer/kv_virtual_device.cpp | 2 +- .../common/syncer/kv_virtual_device.h | 2 +- .../unittest/common/syncer/mock_meta_data.h | 4 +- .../virtual_multi_ver_sync_db_interface.cpp | 4 +- .../virtual_multi_ver_sync_db_interface.h | 2 +- ...rtual_relational_ver_sync_db_interface.cpp | 14 +- ...virtual_relational_ver_sync_db_interface.h | 4 +- .../virtual_single_ver_sync_db_Interface.cpp | 58 +++--- .../virtual_single_ver_sync_db_Interface.h | 16 +- 110 files changed, 826 insertions(+), 826 deletions(-) diff --git a/services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.cpp b/services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.cpp index 8065027e1..f023df18b 100644 --- a/services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.cpp +++ b/services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.cpp @@ -37,10 +37,10 @@ KvStoreFlowCtrlManager::KvStoreFlowCtrlManager(const int burstCapacity, const in sustainedTokenBucket_.refreshTimeGap = SUSTAINED_REFRESH_TIME; } -void KvStoreFlowCtrlManager::RefreshTokenBucket(TokenBucket &tokenBucket, uint64_t timeStamp) +void KvStoreFlowCtrlManager::RefreshTokenBucket(TokenBucket &tokenBucket, uint64_t timestamp) { tokenBucket.leftNumInTokenBucket = tokenBucket.maxCapacity; - tokenBucket.tokenBucketRefreshTime = timeStamp; + tokenBucket.tokenBucketRefreshTime = timestamp; } bool KvStoreFlowCtrlManager::IsTokenEnough() @@ -57,14 +57,14 @@ bool KvStoreFlowCtrlManager::IsTokenEnough() return false; } -bool KvStoreFlowCtrlManager::IsTokenEnoughSlice(TokenBucket &tokenBucket, uint64_t timeStamp) +bool KvStoreFlowCtrlManager::IsTokenEnoughSlice(TokenBucket &tokenBucket, uint64_t timestamp) { // the first time to get token will be allowed; // if the gap between this time to get token and the least time to fill the bucket // to the full is larger than 10ms, this operation will be allowed; if (tokenBucket.tokenBucketRefreshTime == 0 || - timeStamp - tokenBucket.tokenBucketRefreshTime > tokenBucket.refreshTimeGap) { - RefreshTokenBucket(tokenBucket, timeStamp); + timestamp - tokenBucket.tokenBucketRefreshTime > tokenBucket.refreshTimeGap) { + RefreshTokenBucket(tokenBucket, timestamp); return true; } else { return tokenBucket.leftNumInTokenBucket >= 1; diff --git a/services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.h b/services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.h index d83fdd7c6..838cb3bdd 100644 --- a/services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.h +++ b/services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.h @@ -47,9 +47,9 @@ public: static const int SUSTAINED_REFRESH_TIME = 60000; private: - void RefreshTokenBucket(TokenBucket &tokenBucket, uint64_t timeStamp); + void RefreshTokenBucket(TokenBucket &tokenBucket, uint64_t timestamp); - bool IsTokenEnoughSlice(TokenBucket &tokenBucket, uint64_t timeStamp); + bool IsTokenEnoughSlice(TokenBucket &tokenBucket, uint64_t timestamp); TokenBucket burstTokenBucket_; // token bucket to deal with events in a burst diff --git a/services/distributeddataservice/libs/distributeddb/common/include/db_types.h b/services/distributeddataservice/libs/distributeddb/common/include/db_types.h index 131c95180..b8dabd596 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/db_types.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/db_types.h @@ -25,7 +25,7 @@ #include "db_constant.h" namespace DistributedDB { -using TimeStamp = uint64_t; +using Timestamp = uint64_t; using ContinueToken = void *; using DeviceID = std::string; using TimeOffset = int64_t; @@ -39,10 +39,10 @@ const uint32_t MTU_SIZE = 5 * 1024 * 1024; // 5 M, 1024 is scale struct DataItem { Key key; Value value; - TimeStamp timeStamp = 0; + Timestamp timestamp = 0; uint64_t flag = 0; std::string origDev; - TimeStamp writeTimeStamp = 0; + Timestamp writeTimestamp = 0; std::string dev; bool neglect = false; Key hashKey{}; @@ -126,11 +126,11 @@ enum SingleVerConflictResolvePolicy { }; struct SyncTimeRange { - TimeStamp beginTime = 0; - TimeStamp deleteBeginTime = 0; - TimeStamp endTime = static_cast(INT64_MAX); - TimeStamp deleteEndTime = static_cast(INT64_MAX); - TimeStamp lastQueryTime = 0; + Timestamp beginTime = 0; + Timestamp deleteBeginTime = 0; + Timestamp endTime = static_cast(INT64_MAX); + Timestamp deleteEndTime = static_cast(INT64_MAX); + Timestamp lastQueryTime = 0; bool IsValid() const { return (beginTime <= endTime && deleteBeginTime <= deleteEndTime); diff --git a/services/distributeddataservice/libs/distributeddb/common/include/performance_analysis.h b/services/distributeddataservice/libs/distributeddb/common/include/performance_analysis.h index 6d9ef7586..4a89f22f0 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/performance_analysis.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/performance_analysis.h @@ -53,13 +53,13 @@ enum MV_TEST_RECORDS : uint32_t { }; struct TimePair { - TimeStamp startTime = 0; - TimeStamp endTime = 0; + Timestamp startTime = 0; + Timestamp endTime = 0; }; struct StatisticsInfo { - TimeStamp max = 0; - TimeStamp min = 0; + Timestamp max = 0; + Timestamp min = 0; float average = 0.0; }; diff --git a/services/distributeddataservice/libs/distributeddb/common/include/runtime_context.h b/services/distributeddataservice/libs/distributeddb/common/include/runtime_context.h index 9ac95d753..9b68f63f6 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/runtime_context.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/runtime_context.h @@ -108,7 +108,7 @@ public: virtual bool IsCommunicatorAggregatorValid() const = 0; // Notify TIME_CHANGE_EVENT. - virtual void NotifyTimeStampChanged(TimeOffset offset) const = 0; + virtual void NotifyTimestampChanged(TimeOffset offset) const = 0; virtual void SetStoreStatusNotifier(const StoreStatusNotifier ¬ifier) = 0; diff --git a/services/distributeddataservice/libs/distributeddb/common/src/performance_analysis.cpp b/services/distributeddataservice/libs/distributeddb/common/src/performance_analysis.cpp index 779644068..508f20d47 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/performance_analysis.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/performance_analysis.cpp @@ -161,7 +161,7 @@ void PerformanceAnalysis::StepTimeRecordEnd(uint32_t step) if ((timePair.endTime < timePair.startTime) || (timePair.startTime == 0) || (timePair.endTime == 0)) { return; } - TimeStamp offset = timePair.endTime - timePair.startTime; + Timestamp offset = timePair.endTime - timePair.startTime; if (stepTimeRecordInfo_[step].max < offset) { stepTimeRecordInfo_[step].max = offset; } diff --git a/services/distributeddataservice/libs/distributeddb/common/src/runtime_context_impl.cpp b/services/distributeddataservice/libs/distributeddb/common/src/runtime_context_impl.cpp index b774b1675..b88be91e8 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/runtime_context_impl.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/runtime_context_impl.cpp @@ -568,11 +568,11 @@ bool RuntimeContextImpl::IsProcessSystemApiAdapterValid() const return true; } -void RuntimeContextImpl::NotifyTimeStampChanged(TimeOffset offset) const +void RuntimeContextImpl::NotifyTimestampChanged(TimeOffset offset) const { std::lock_guard autoLock(timeTickMonitorLock_); if (timeTickMonitor_ == nullptr) { - LOGD("NotifyTimeStampChanged fail, timeTickMonitor_ is null."); + LOGD("NotifyTimestampChanged fail, timeTickMonitor_ is null."); return; } timeTickMonitor_->NotifyTimeChange(offset); diff --git a/services/distributeddataservice/libs/distributeddb/common/src/runtime_context_impl.h b/services/distributeddataservice/libs/distributeddb/common/src/runtime_context_impl.h index 4bc90b2da..5dd607e84 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/runtime_context_impl.h +++ b/services/distributeddataservice/libs/distributeddb/common/src/runtime_context_impl.h @@ -97,7 +97,7 @@ public: bool IsCommunicatorAggregatorValid() const override; // Notify TIME_CHANGE_EVENT. - void NotifyTimeStampChanged(TimeOffset offset) const override; + void NotifyTimestampChanged(TimeOffset offset) const override; void SetStoreStatusNotifier(const StoreStatusNotifier ¬ifier) override; diff --git a/services/distributeddataservice/libs/distributeddb/common/src/time_tick_monitor.cpp b/services/distributeddataservice/libs/distributeddb/common/src/time_tick_monitor.cpp index 82a8a606a..d43fadc18 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/time_tick_monitor.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/time_tick_monitor.cpp @@ -128,7 +128,7 @@ int TimeTickMonitor::TimeTick(TimerId timerId) return E_OK; } -TimeStamp TimeTickMonitor::GetSysCurrentTime() +Timestamp TimeTickMonitor::GetSysCurrentTime() { uint64_t curTime = 0; int errCode = OS::GetCurrentSysTimeInMicrosecond(curTime); @@ -139,7 +139,7 @@ TimeStamp TimeTickMonitor::GetSysCurrentTime() return curTime; } -TimeStamp TimeTickMonitor::GetMonotonicTime() +Timestamp TimeTickMonitor::GetMonotonicTime() { uint64_t time; int errCode = OS::GetMonotonicRelativeTimeInMicrosecond(time); diff --git a/services/distributeddataservice/libs/distributeddb/common/src/time_tick_monitor.h b/services/distributeddataservice/libs/distributeddb/common/src/time_tick_monitor.h index 35b409208..0bb42c5d0 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/time_tick_monitor.h +++ b/services/distributeddataservice/libs/distributeddb/common/src/time_tick_monitor.h @@ -47,10 +47,10 @@ private: static const uint64_t INVALID_TIMESTAMP = 0; // Get the current system time - static TimeStamp GetSysCurrentTime(); + static Timestamp GetSysCurrentTime(); // Get the Monotonic time - static TimeStamp GetMonotonicTime(); + static Timestamp GetMonotonicTime(); // prepare notifier chain int PrepareNotifierChain(); @@ -63,8 +63,8 @@ private: RuntimeContext *runtimeCxt_; TimerId monitorTimerId_ = 0; TimerAction monitorCallback_; - TimeStamp lastMonotonicTime_ = 0; - TimeStamp lastSystemTime_ = 0; + Timestamp lastMonotonicTime_ = 0; + Timestamp lastSystemTime_ = 0; bool isStarted_ = false; }; } // namespace DistributedDB diff --git a/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_store_sqlite_ext.cpp b/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_store_sqlite_ext.cpp index d66f4b93d..2f309c3dd 100644 --- a/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_store_sqlite_ext.cpp +++ b/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_store_sqlite_ext.cpp @@ -87,7 +87,7 @@ private: const uint64_t MULTIPLES_BETWEEN_SECONDS_AND_MICROSECONDS = 1000000; -using TimeStamp = uint64_t; +using Timestamp = uint64_t; using TimeOffset = int64_t; class TimeHelper { @@ -98,10 +98,10 @@ public: constexpr static uint64_t TO_100_NS = 10; // 1us to 100ns - constexpr static TimeStamp INVALID_TIMESTAMP = 0; + constexpr static Timestamp INVALID_TIMESTAMP = 0; // Get current system time - static TimeStamp GetSysCurrentTime() + static Timestamp GetSysCurrentTime() { uint64_t curTime = 0; int errCode = GetCurrentSysTimeInMicrosecond(curTime); @@ -120,22 +120,22 @@ public: lastSystemTimeUs_ = curTime; currentIncCount_ = 0; } - return (curTime * TO_100_NS) + currentIncCount_; // Currently TimeStamp is uint64_t + return (curTime * TO_100_NS) + currentIncCount_; // Currently Timestamp is uint64_t } // Init the TimeHelper - static void Initialize(TimeStamp maxTimeStamp) + static void Initialize(Timestamp maxTimestamp) { std::lock_guard lock(lastLocalTimeLock_); - if (lastSystemTimeUs_ < maxTimeStamp) { - lastSystemTimeUs_ = maxTimeStamp; + if (lastSystemTimeUs_ < maxTimestamp) { + lastSystemTimeUs_ = maxTimestamp; } } - static TimeStamp GetTime(TimeOffset timeOffset) + static Timestamp GetTime(TimeOffset timeOffset) { - TimeStamp currentSysTime = GetSysCurrentTime(); - TimeStamp currentLocalTime = currentSysTime + timeOffset; + Timestamp currentSysTime = GetSysCurrentTime(); + Timestamp currentLocalTime = currentSysTime + timeOffset; std::lock_guard lock(lastLocalTimeLock_); if (currentLocalTime <= lastLocalTime_ || currentLocalTime > MAX_VALID_TIME) { lastLocalTime_++; @@ -160,18 +160,18 @@ private: } static std::mutex systemTimeLock_; - static TimeStamp lastSystemTimeUs_; - static TimeStamp currentIncCount_; + static Timestamp lastSystemTimeUs_; + static Timestamp currentIncCount_; static const uint64_t MAX_INC_COUNT = 9; // last bit from 0-9 - static TimeStamp lastLocalTime_; + static Timestamp lastLocalTime_; static std::mutex lastLocalTimeLock_; }; std::mutex TimeHelper::systemTimeLock_; -TimeStamp TimeHelper::lastSystemTimeUs_ = 0; -TimeStamp TimeHelper::currentIncCount_ = 0; -TimeStamp TimeHelper::lastLocalTime_ = 0; +Timestamp TimeHelper::lastSystemTimeUs_ = 0; +Timestamp TimeHelper::currentIncCount_ = 0; +Timestamp TimeHelper::lastLocalTime_ = 0; std::mutex TimeHelper::lastLocalTimeLock_; struct TransactFunc { @@ -298,7 +298,7 @@ int GetColumnTestValue(sqlite3_stmt *stmt, int index, std::string &value) return E_OK; } -int GetCurrentMaxTimeStamp(sqlite3 *db, TimeStamp &maxTimestamp) +int GetCurrentMaxTimestamp(sqlite3 *db, Timestamp &maxTimestamp) { if (db == nullptr) { return -E_ERROR; @@ -328,7 +328,7 @@ int GetCurrentMaxTimeStamp(sqlite3 *db, TimeStamp &maxTimestamp) ResetStatement(getTimeStmt); continue; } - auto tableMaxTimestamp = static_cast(sqlite3_column_int64(getTimeStmt, 0)); + auto tableMaxTimestamp = static_cast(sqlite3_column_int64(getTimeStmt, 0)); maxTimestamp = (maxTimestamp > tableMaxTimestamp) ? maxTimestamp : tableMaxTimestamp; ResetStatement(getTimeStmt); } @@ -343,8 +343,8 @@ SQLITE_API int sqlite3_open_relational(const char *filename, sqlite3 **ppDb) if (err != SQLITE_OK) { return err; } - TimeStamp currentMaxTimestamp = 0; - (void)GetCurrentMaxTimeStamp(*ppDb, currentMaxTimestamp); + Timestamp currentMaxTimestamp = 0; + (void)GetCurrentMaxTimestamp(*ppDb, currentMaxTimestamp); TimeHelper::Initialize(currentMaxTimestamp); RegisterCalcHash(*ppDb); RegisterGetSysTime(*ppDb); @@ -357,8 +357,8 @@ SQLITE_API int sqlite3_open16_relational(const void *filename, sqlite3 **ppDb) if (err != SQLITE_OK) { return err; } - TimeStamp currentMaxTimestamp = 0; - (void)GetCurrentMaxTimeStamp(*ppDb, currentMaxTimestamp); + Timestamp currentMaxTimestamp = 0; + (void)GetCurrentMaxTimestamp(*ppDb, currentMaxTimestamp); TimeHelper::Initialize(currentMaxTimestamp); RegisterCalcHash(*ppDb); RegisterGetSysTime(*ppDb); @@ -371,8 +371,8 @@ SQLITE_API int sqlite3_open_v2_relational(const char *filename, sqlite3 **ppDb, if (err != SQLITE_OK) { return err; } - TimeStamp currentMaxTimestamp = 0; - (void)GetCurrentMaxTimeStamp(*ppDb, currentMaxTimestamp); + Timestamp currentMaxTimestamp = 0; + (void)GetCurrentMaxTimestamp(*ppDb, currentMaxTimestamp); TimeHelper::Initialize(currentMaxTimestamp); RegisterCalcHash(*ppDb); RegisterGetSysTime(*ppDb); diff --git a/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_sync_able_storage.h b/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_sync_able_storage.h index 35432bbef..e7e616df4 100644 --- a/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_sync_able_storage.h +++ b/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_sync_able_storage.h @@ -43,7 +43,7 @@ public: std::vector GetIdentifier() const override; // Get the max timestamp of all entries in database. - void GetMaxTimeStamp(TimeStamp &stamp) const override; + void GetMaxTimestamp(Timestamp &stamp) const override; // Get meta data associated with the given key. int GetMetaData(const Key &key, Value &value) const override; @@ -82,7 +82,7 @@ public: void NotifyRemotePushFinished(const std::string &deviceId) const override; // Get the timestamp when database created or imported - int GetDatabaseCreateTimeStamp(TimeStamp &outTime) const override; + int GetDatabaseCreateTimestamp(Timestamp &outTime) const override; // Get batch meta data associated with the given key. int GetBatchMetaData(const std::vector &keys, std::vector &entries) const override; @@ -119,7 +119,7 @@ private: SQLiteSingleVerRelationalStorageExecutor *GetHandle(bool isWrite, int &errCode, OperatePerm perm = OperatePerm::NORMAL_PERM) const; void ReleaseHandle(SQLiteSingleVerRelationalStorageExecutor *&handle) const; - int SetMaxTimeStamp(TimeStamp timestamp); + int SetMaxTimestamp(Timestamp timestamp); // get int GetSyncDataForQuerySync(std::vector &dataItems, SQLiteSingleVerRelationalContinueToken *&token, @@ -131,9 +131,9 @@ private: // data SQLiteSingleRelationalStorageEngine *storageEngine_ = nullptr; - TimeStamp currentMaxTimeStamp_ = 0; + Timestamp currentMaxTimestamp_ = 0; KvDBProperties properties_; - mutable std::mutex maxTimeStampMutex_; + mutable std::mutex maxTimestampMutex_; std::function onSchemaChanged_; mutable std::mutex onSchemaChangedMutex_; diff --git a/services/distributeddataservice/libs/distributeddb/storage/include/isync_interface.h b/services/distributeddataservice/libs/distributeddb/storage/include/isync_interface.h index 4b45ec919..0a4e0e704 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/include/isync_interface.h +++ b/services/distributeddataservice/libs/distributeddb/storage/include/isync_interface.h @@ -49,7 +49,7 @@ public: virtual std::vector GetDualTupleIdentifier() const = 0; // Get the max timestamp of all entries in database. - virtual void GetMaxTimeStamp(TimeStamp &stamp) const = 0; + virtual void GetMaxTimestamp(Timestamp &stamp) const = 0; // Get meta data associated with the given key. virtual int GetMetaData(const Key &key, Value &value) const = 0; diff --git a/services/distributeddataservice/libs/distributeddb/storage/include/single_ver_kv_entry.h b/services/distributeddataservice/libs/distributeddb/storage/include/single_ver_kv_entry.h index f9a870017..626ad2375 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/include/single_ver_kv_entry.h +++ b/services/distributeddataservice/libs/distributeddb/storage/include/single_ver_kv_entry.h @@ -25,10 +25,10 @@ public: virtual ~SingleVerKvEntry() {}; virtual std::string GetOrigDevice() const = 0; virtual void SetOrigDevice(const std::string &device) = 0; - virtual TimeStamp GetTimestamp() const = 0; - virtual void SetTimestamp(TimeStamp timestamp) = 0; - virtual TimeStamp GetWriteTimestamp() const = 0; - virtual void SetWriteTimestamp(TimeStamp timestamp) = 0; + virtual Timestamp GetTimestamp() const = 0; + virtual void SetTimestamp(Timestamp timestamp) = 0; + virtual Timestamp GetWriteTimestamp() const = 0; + virtual void SetWriteTimestamp(Timestamp timestamp) = 0; virtual uint64_t GetFlag() const = 0; virtual int SerializeData(Parcel &parcel, uint32_t softWareVersion) = 0; virtual int DeSerializeData(Parcel &parcel) = 0; diff --git a/services/distributeddataservice/libs/distributeddb/storage/include/single_ver_kvdb_sync_interface.h b/services/distributeddataservice/libs/distributeddb/storage/include/single_ver_kvdb_sync_interface.h index fe56452bb..dc9cdf298 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/include/single_ver_kvdb_sync_interface.h +++ b/services/distributeddataservice/libs/distributeddb/storage/include/single_ver_kvdb_sync_interface.h @@ -23,7 +23,7 @@ #include "intercepted_data.h" namespace DistributedDB { -using MulDevTimeRanges = std::map>; +using MulDevTimeRanges = std::map>; using MulDevSinVerKvEntry = std::map>; using MulDevDataItems = std::map>; diff --git a/services/distributeddataservice/libs/distributeddb/storage/include/sync_generic_interface.h b/services/distributeddataservice/libs/distributeddb/storage/include/sync_generic_interface.h index c8a11e689..1fc895c43 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/include/sync_generic_interface.h +++ b/services/distributeddataservice/libs/distributeddb/storage/include/sync_generic_interface.h @@ -26,7 +26,7 @@ public: SyncGenericInterface() = default; ~SyncGenericInterface() override = default; - virtual int GetSyncData(TimeStamp begin, TimeStamp end, std::vector &dataItems, + virtual int GetSyncData(Timestamp begin, Timestamp end, std::vector &dataItems, ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const { LOGE("GetSyncData not support!"); @@ -36,7 +36,7 @@ public: // Get the data which would be synced to other devices according the timestamp. // if the data size is over than the blockSize, It would alloc one token and assign to continueStmtToken, // it should be released when the read operation terminate. - virtual int GetSyncData(TimeStamp begin, TimeStamp end, std::vector &entries, + virtual int GetSyncData(Timestamp begin, Timestamp end, std::vector &entries, ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const { LOGE("GetSyncData not support!"); @@ -93,7 +93,7 @@ public: } // Get the timestamp when database created or imported - virtual int GetDatabaseCreateTimeStamp(TimeStamp &outTime) const + virtual int GetDatabaseCreateTimestamp(Timestamp &outTime) const { return -E_NOT_SUPPORT; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.cpp index 70f8d33c2..5d1ff9908 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.cpp @@ -67,10 +67,10 @@ int DataTransformer::SerializeDataItem(const RowDataWithLog &data, return errCode; } const LogInfo &logInfo = data.logInfo; - dataItem.timeStamp = logInfo.timestamp; + dataItem.timestamp = logInfo.timestamp; dataItem.dev = logInfo.device; dataItem.origDev = logInfo.originDev; - dataItem.writeTimeStamp = logInfo.wTimeStamp; + dataItem.writeTimestamp = logInfo.wTimestamp; dataItem.flag = logInfo.flag; dataItem.hashKey = logInfo.hashKey; return E_OK; @@ -88,10 +88,10 @@ int DataTransformer::DeSerializeDataItem(const DataItem &dataItem, OptRowDataWit } LogInfo &logInfo = data.logInfo; - logInfo.timestamp = dataItem.timeStamp; + logInfo.timestamp = dataItem.timestamp; logInfo.device = dataItem.dev; logInfo.originDev = dataItem.origDev; - logInfo.wTimeStamp = dataItem.writeTimeStamp; + logInfo.wTimestamp = dataItem.writeTimestamp; logInfo.flag = dataItem.flag; logInfo.hashKey = dataItem.hashKey; return E_OK; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.h b/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.h index 92774ce5b..05022ff75 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.h @@ -30,8 +30,8 @@ struct LogInfo { int64_t dataKey = -1; std::string device; std::string originDev; - TimeStamp timestamp = 0; - TimeStamp wTimeStamp = 0; + Timestamp timestamp = 0; + Timestamp wTimestamp = 0; uint64_t flag = 0; Key hashKey; // primary key hash value }; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp index 7b0a11155..54f5003e6 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp @@ -40,24 +40,24 @@ void GenericSingleVerKvEntry::SetOrigDevice(const std::string &dev) dataItem_.origDev = dev; } -TimeStamp GenericSingleVerKvEntry::GetTimestamp() const +Timestamp GenericSingleVerKvEntry::GetTimestamp() const { - return dataItem_.timeStamp; + return dataItem_.timestamp; } -void GenericSingleVerKvEntry::SetTimestamp(TimeStamp time) +void GenericSingleVerKvEntry::SetTimestamp(Timestamp time) { - dataItem_.timeStamp = time; + dataItem_.timestamp = time; } -TimeStamp GenericSingleVerKvEntry::GetWriteTimestamp() const +Timestamp GenericSingleVerKvEntry::GetWriteTimestamp() const { - return dataItem_.writeTimeStamp; + return dataItem_.writeTimestamp; } -void GenericSingleVerKvEntry::SetWriteTimestamp(TimeStamp time) +void GenericSingleVerKvEntry::SetWriteTimestamp(Timestamp time) { - dataItem_.writeTimeStamp = time; + dataItem_.writeTimestamp = time; } void GenericSingleVerKvEntry::SetEntryData(DataItem &&dataItem) @@ -268,7 +268,7 @@ int GenericSingleVerKvEntry::SerializeDataByFirstVersion(Parcel &parcel) const if (errCode != E_OK) { return errCode; } - errCode = parcel.WriteUInt64(dataItem_.timeStamp); + errCode = parcel.WriteUInt64(dataItem_.timestamp); if (errCode != E_OK) { return errCode; } @@ -282,11 +282,11 @@ int GenericSingleVerKvEntry::SerializeDataByFirstVersion(Parcel &parcel) const int GenericSingleVerKvEntry::SerializeDataByLaterVersion(Parcel &parcel, uint32_t targetVersion) const { - TimeStamp writeTimeStamp = dataItem_.writeTimeStamp; - if (writeTimeStamp == 0) { - writeTimeStamp = dataItem_.timeStamp; + Timestamp writeTimestamp = dataItem_.writeTimestamp; + if (writeTimestamp == 0) { + writeTimestamp = dataItem_.timestamp; } - int errCode = parcel.WriteUInt64(writeTimeStamp); + int errCode = parcel.WriteUInt64(writeTimestamp); if (errCode != E_OK) { return errCode; } @@ -337,15 +337,15 @@ void GenericSingleVerKvEntry::DeSerializeByFirstVersion(uint64_t &len, Parcel &p { len += parcel.ReadVectorChar(dataItem_.key); len += parcel.ReadVectorChar(dataItem_.value); - len += parcel.ReadUInt64(dataItem_.timeStamp); + len += parcel.ReadUInt64(dataItem_.timestamp); len += parcel.ReadUInt64(dataItem_.flag); len += parcel.ReadString(dataItem_.origDev); - dataItem_.writeTimeStamp = dataItem_.timeStamp; + dataItem_.writeTimestamp = dataItem_.timestamp; } void GenericSingleVerKvEntry::DeSerializeByLaterVersion(uint64_t &len, Parcel &parcel, uint32_t targetVersion) { - len += parcel.ReadUInt64(dataItem_.writeTimeStamp); + len += parcel.ReadUInt64(dataItem_.writeTimestamp); if (targetVersion >= SOFTWARE_VERSION_RELEASE_6_0) { len += parcel.ReadVector(dataItem_.hashKey); } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.h b/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.h index 1bf10395b..32a59696b 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.h @@ -39,13 +39,13 @@ public: void SetOrigDevice(const std::string &dev) override; - TimeStamp GetTimestamp() const override; + Timestamp GetTimestamp() const override; - void SetTimestamp(TimeStamp time) override; + void SetTimestamp(Timestamp time) override; - TimeStamp GetWriteTimestamp() const override; + Timestamp GetWriteTimestamp() const override; - void SetWriteTimestamp(TimeStamp time) override; + void SetWriteTimestamp(Timestamp time) override; void GetKey(Key &key) const; const Key &GetKey() const override; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/ikvdb_commit.h b/services/distributeddataservice/libs/distributeddb/storage/src/ikvdb_commit.h index eb254dc8c..75dfe2a46 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/ikvdb_commit.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/ikvdb_commit.h @@ -31,8 +31,8 @@ public: virtual void SetLeftParentId(const CommitID &id) = 0; virtual CommitID GetRightParentId() const = 0; virtual void SetRightParentId(const CommitID &id) = 0; - virtual TimeStamp GetTimestamp() const = 0; - virtual void SetTimestamp(TimeStamp timestamp) = 0; + virtual Timestamp GetTimestamp() const = 0; + virtual void SetTimestamp(Timestamp timestamp) = 0; virtual bool GetLocalFlag() const = 0; virtual void SetLocalFlag(bool localFlag) = 0; virtual DeviceID GetDeviceInfo() const = 0; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/ikvdb_multi_ver_data_storage.h b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/ikvdb_multi_ver_data_storage.h index f56d53b38..49e5f598a 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/ikvdb_multi_ver_data_storage.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/ikvdb_multi_ver_data_storage.h @@ -31,7 +31,7 @@ enum class KvDataType { KV_DATA_SYNC_P2P, }; -struct UpdateVerTimeStamp { +struct UpdateVerTimestamp { uint64_t timestamp = 0ull; bool isNeedUpdate = false; }; @@ -50,7 +50,7 @@ public: virtual int Open(const Property &property) = 0; virtual int StartWrite(KvDataType dataType, IKvDBMultiVerTransaction *&transaction) = 0; virtual int CommitWritePhaseOne(IKvDBMultiVerTransaction *transaction, - const UpdateVerTimeStamp &multiVerTimeStamp) = 0; + const UpdateVerTimestamp &multiVerTimestamp) = 0; virtual int RollbackWritePhaseOne(IKvDBMultiVerTransaction *transaction, const Version &versionInfo) = 0; virtual int RollbackWrite(IKvDBMultiVerTransaction *transaction) = 0; virtual void CommitWritePhaseTwo(IKvDBMultiVerTransaction *transaction) = 0; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/ikvdb_multi_ver_transaction.h b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/ikvdb_multi_ver_transaction.h index 81490fc68..3cb433d57 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/ikvdb_multi_ver_transaction.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/ikvdb_multi_ver_transaction.h @@ -39,10 +39,10 @@ public: virtual int StartTransaction() = 0; virtual int RollBackTransaction() = 0; virtual int CommitTransaction() = 0; - virtual int UpdateTimestampByVersion(const Version &version, TimeStamp stamp) const = 0; + virtual int UpdateTimestampByVersion(const Version &version, Timestamp stamp) const = 0; virtual bool IsDataChanged() const = 0; // only for write transaction. - virtual bool IsRecordCleared(const TimeStamp timestamp) const = 0; - virtual TimeStamp GetCurrentMaxTimestamp() const = 0; + virtual bool IsRecordCleared(const Timestamp timestamp) const = 0; + virtual Timestamp GetCurrentMaxTimestamp() const = 0; virtual void SetVersion(const Version &versionInfo) = 0; virtual Version GetVersion() const = 0; virtual int GetEntriesByVersion(Version version, std::list &data) const = 0; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp index fbde2ffd5..56e4c35e3 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp @@ -71,12 +71,12 @@ void MultiVerCommit::SetRightParentId(const CommitID &id) return; } -TimeStamp MultiVerCommit::GetTimestamp() const +Timestamp MultiVerCommit::GetTimestamp() const { return timestamp_; } -void MultiVerCommit::SetTimestamp(TimeStamp timestamp) +void MultiVerCommit::SetTimestamp(Timestamp timestamp) { timestamp_ = timestamp; return; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_commit.h b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_commit.h index eecf9860d..7ba7c292e 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_commit.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_commit.h @@ -42,8 +42,8 @@ public: CommitID GetRightParentId() const override; void SetRightParentId(const CommitID &id) override; - TimeStamp GetTimestamp() const override; - void SetTimestamp(TimeStamp timestamp) override; + Timestamp GetTimestamp() const override; + void SetTimestamp(Timestamp timestamp) override; bool GetLocalFlag() const override; void SetLocalFlag(bool localFlag) override; @@ -61,7 +61,7 @@ private: CommitID commitID_; CommitID leftParentID_; CommitID rightParentID_; - TimeStamp timestamp_; + Timestamp timestamp_; bool localFlag_; DeviceID deviceInfo_; }; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp index 709724567..8f0ca69a8 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp @@ -501,13 +501,13 @@ std::string MultiVerNaturalStore::GetStringIdentifier() const } // Get the max timestamp of all entries in database. -void MultiVerNaturalStore::GetMaxTimeStamp(TimeStamp &stamp) const +void MultiVerNaturalStore::GetMaxTimestamp(Timestamp &stamp) const { std::lock_guard lock(maxTimeMutex_); stamp = maxRecordTimestamp_; } -void MultiVerNaturalStore::SetMaxTimeStamp(TimeStamp stamp) +void MultiVerNaturalStore::SetMaxTimestamp(Timestamp stamp) { std::lock_guard lock(maxTimeMutex_); maxRecordTimestamp_ = (stamp > maxRecordTimestamp_) ? stamp : maxRecordTimestamp_; @@ -821,9 +821,9 @@ END: return errCode; } -uint64_t MultiVerNaturalStore::GetCurrentTimeStamp() +uint64_t MultiVerNaturalStore::GetCurrentTimestamp() { - return GetTimeStamp(); + return GetTimestamp(); } int MultiVerNaturalStore::GetDiffEntries(const CommitID &begin, const CommitID &end, MultiVerDiffData &data) const diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.h b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.h index 961c159b2..28145b1d8 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.h @@ -66,7 +66,7 @@ public: std::vector GetIdentifier() const override; // Get the max timestamp of all entries in database. - void GetMaxTimeStamp(TimeStamp &stamp) const override; + void GetMaxTimestamp(Timestamp &stamp) const override; // Get meta data associated with the given key. int GetMetaData(const Key &key, Value &value) const override; @@ -120,10 +120,10 @@ public: int GetDiffEntries(const CommitID &begin, const CommitID &end, MultiVerDiffData &data) const; - uint64_t GetCurrentTimeStamp(); + uint64_t GetCurrentTimestamp(); // Set the max timestamp - void SetMaxTimeStamp(TimeStamp stamp); + void SetMaxTimestamp(Timestamp stamp); Version GetMaxCommitVersion() const; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp index abc5cd470..02133d508 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp @@ -710,7 +710,7 @@ int MultiVerNaturalStoreCommitStorage::TransferValueToCommit(const Value &value, return -E_UNEXPECTED_DATA; } - TimeStamp timestamp = 0; + Timestamp timestamp = 0; uint64_t localFlag = 1; Version versionInfo; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp index d34e8eabb..14b82f68e 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp @@ -848,7 +848,7 @@ int MultiVerStorageExecutor::CommitTransaction(MultiTransactionType type) if ((dataStorage_ == nullptr) || (transaction_ == nullptr)) { return -E_INVALID_DB; } - UpdateVerTimeStamp multiVerTimeStamp = {static_cast(kvDB_)->GetCurrentTimeStamp(), true}; + UpdateVerTimestamp multiVerTimestamp = {static_cast(kvDB_)->GetCurrentTimestamp(), true}; Version commitVersion; CommitID commitId; int errCode = E_OK; @@ -858,21 +858,21 @@ int MultiVerStorageExecutor::CommitTransaction(MultiTransactionType type) goto END; } - errCode = dataStorage_->CommitWritePhaseOne(transaction_, multiVerTimeStamp); + errCode = dataStorage_->CommitWritePhaseOne(transaction_, multiVerTimestamp); if (errCode != E_OK) { LOGE("commit phase one failed:%d", errCode); goto END; } commitVersion = transaction_->GetVersion(); - errCode = FillAndCommitLogEntry(commitVersion, commitId, multiVerTimeStamp.timestamp); + errCode = FillAndCommitLogEntry(commitVersion, commitId, multiVerTimestamp.timestamp); if (errCode != E_OK) { LOGE("rollback commit phase one failed:%d", errCode); dataStorage_->RollbackWritePhaseOne(transaction_, commitVersion); goto END; } LOGD("local commit version:%" PRIu64, commitVersion); - static_cast(kvDB_)->SetMaxTimeStamp(multiVerTimeStamp.timestamp); + static_cast(kvDB_)->SetMaxTimestamp(multiVerTimestamp.timestamp); dataStorage_->CommitWritePhaseTwo(transaction_); static_cast(kvDB_)->SetMaxCommitVersion(commitVersion); END: @@ -1234,7 +1234,7 @@ int MultiVerStorageExecutor::FillCommitByForeign(IKvDBCommit *commit, commit->SetLeftParentId(header); commit->SetRightParentId(multiVerCommit.commitId); commit->SetLocalFlag(true); - TimeStamp timestamp = static_cast(kvDB_)->GetCurrentTimeStamp(); + Timestamp timestamp = static_cast(kvDB_)->GetCurrentTimestamp(); commit->SetTimestamp(timestamp); commit->SetDeviceInfo(strTag); } else { @@ -1251,7 +1251,7 @@ int MultiVerStorageExecutor::FillCommitByForeign(IKvDBCommit *commit, } int MultiVerStorageExecutor::FillAndCommitLogEntry(const Version &versionInfo, - const MultiVerCommitNode &multiVerCommit, CommitID &commitId, bool isMerge, TimeStamp ×tamp) const + const MultiVerCommitNode &multiVerCommit, CommitID &commitId, bool isMerge, Timestamp ×tamp) const { if (commitStorage_ == nullptr) { return -E_INVALID_DB; @@ -1272,7 +1272,7 @@ int MultiVerStorageExecutor::FillAndCommitLogEntry(const Version &versionInfo, goto END; } - timestamp = isMerge ? static_cast(kvDB_)->GetCurrentTimeStamp() : multiVerCommit.timestamp; + timestamp = isMerge ? static_cast(kvDB_)->GetCurrentTimestamp() : multiVerCommit.timestamp; commit->SetTimestamp(timestamp); // write the commit history. @@ -1298,17 +1298,17 @@ int MultiVerStorageExecutor::CommitTransaction(const MultiVerCommitNode &multiVe Version commitVersion; CommitID commitId; - UpdateVerTimeStamp multiVerTimeStamp = {0ull, false}; + UpdateVerTimestamp multiVerTimestamp = {0ull, false}; bool isDataChanged = transaction_->IsDataChanged(); - int errCode = dataStorage_->CommitWritePhaseOne(transaction_, multiVerTimeStamp); + int errCode = dataStorage_->CommitWritePhaseOne(transaction_, multiVerTimestamp); if (errCode != E_OK) { LOGE("commit phase one failed:%d", errCode); goto END; } commitVersion = transaction_->GetVersion(); - errCode = FillAndCommitLogEntry(commitVersion, multiVerCommit, commitId, isMerge, multiVerTimeStamp.timestamp); + errCode = FillAndCommitLogEntry(commitVersion, multiVerCommit, commitId, isMerge, multiVerTimestamp.timestamp); if (errCode != E_OK) { LOGE("rollback commit phase one failed:%d", errCode); dataStorage_->RollbackWritePhaseOne(transaction_, commitVersion); @@ -1316,7 +1316,7 @@ int MultiVerStorageExecutor::CommitTransaction(const MultiVerCommitNode &multiVe } dataStorage_->CommitWritePhaseTwo(transaction_); - static_cast(kvDB_)->SetMaxTimeStamp(multiVerTimeStamp.timestamp); + static_cast(kvDB_)->SetMaxTimestamp(multiVerTimestamp.timestamp); static_cast(kvDB_)->SetMaxCommitVersion(commitVersion); LOGD("sync commit version:%" PRIu64, commitVersion); END: diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.h b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.h index e1f4d22cc..4b3f99c65 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.h @@ -140,7 +140,7 @@ private: const Version &versionInfo, const CommitID &commitId, bool isMerge) const; int FillAndCommitLogEntry(const Version &versionInfo, const MultiVerCommitNode &multiVerCommit, - CommitID &commitId, bool isMerge, TimeStamp ×tamp) const; + CommitID &commitId, bool isMerge, Timestamp ×tamp) const; int MergeOneCommit(const MultiVerCommitNode &commit); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/relational_sync_able_storage.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/relational_sync_able_storage.cpp index 2a5cb216a..58e805797 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/relational_sync_able_storage.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/relational_sync_able_storage.cpp @@ -63,17 +63,17 @@ std::vector RelationalSyncAbleStorage::GetIdentifier() const } // Get the max timestamp of all entries in database. -void RelationalSyncAbleStorage::GetMaxTimeStamp(TimeStamp &stamp) const +void RelationalSyncAbleStorage::GetMaxTimestamp(Timestamp &stamp) const { - std::lock_guard lock(maxTimeStampMutex_); - stamp = currentMaxTimeStamp_; + std::lock_guard lock(maxTimestampMutex_); + stamp = currentMaxTimestamp_; } -int RelationalSyncAbleStorage::SetMaxTimeStamp(TimeStamp timestamp) +int RelationalSyncAbleStorage::SetMaxTimestamp(Timestamp timestamp) { - std::lock_guard lock(maxTimeStampMutex_); - if (timestamp > currentMaxTimeStamp_) { - currentMaxTimeStamp_ = timestamp; + std::lock_guard lock(maxTimestampMutex_); + if (timestamp > currentMaxTimestamp_) { + currentMaxTimestamp_ = timestamp; } return E_OK; } @@ -368,8 +368,8 @@ int RelationalSyncAbleStorage::PutSyncDataWithQuery(const QueryObject &object, DataItem item; item.origDev = entry->GetOrigDevice(); item.flag = entry->GetFlag(); - item.timeStamp = entry->GetTimestamp(); - item.writeTimeStamp = entry->GetWriteTimestamp(); + item.timestamp = entry->GetTimestamp(); + item.writeTimestamp = entry->GetWriteTimestamp(); entry->GetKey(item.key); entry->GetValue(item.value); entry->GetHashKey(item.hashKey); @@ -392,11 +392,11 @@ int RelationalSyncAbleStorage::SaveSyncDataItems(const QueryObject &object, std: QueryObject query = object; query.SetSchema(storageEngine_->GetSchemaRef()); - TimeStamp maxTimestamp = 0; + Timestamp maxTimestamp = 0; errCode = handle->SaveSyncItems(query, dataItems, deviceName, storageEngine_->GetSchemaRef().GetTable(object.GetTableName()), maxTimestamp); if (errCode == E_OK) { - (void)SetMaxTimeStamp(maxTimestamp); + (void)SetMaxTimestamp(maxTimestamp); // dataItems size > 0 now because already check before // all dataItems will write into db now, so need to observer notify here // if some dataItems will not write into db in the future, observer notify here need change @@ -445,7 +445,7 @@ void RelationalSyncAbleStorage::NotifyRemotePushFinished(const std::string &devi } // Get the timestamp when database created or imported -int RelationalSyncAbleStorage::GetDatabaseCreateTimeStamp(TimeStamp &outTime) const +int RelationalSyncAbleStorage::GetDatabaseCreateTimestamp(Timestamp &outTime) const { return OS::GetCurrentSysTimeInMicrosecond(outTime); } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp index fd3db2a6c..56d61937a 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp @@ -248,7 +248,7 @@ void SingleVerNaturalStoreCommitNotifyData::PutIntoConflictData(const DataItemIn // If the new item is deleted, just using the key of the old data item. // If the items are all deleted, this function should not be executed. conflictData.key = isDeleted ? orgItemInfo.dataItem.key : newItemInfo.dataItem.key; - if (newItemInfo.dataItem.writeTimeStamp <= orgItemInfo.dataItem.writeTimeStamp) { + if (newItemInfo.dataItem.writeTimestamp <= orgItemInfo.dataItem.writeTimestamp) { std::swap(conflictData.newData, conflictData.oldData); } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp index 568ea7a6d..6255829e3 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp @@ -167,7 +167,7 @@ int SQLiteMultiVerDataStorage::StartWrite(KvDataType dataType, IKvDBMultiVerTran // do the first step of commit record. // commit the transaction, and avoid other operation reading the new data. int SQLiteMultiVerDataStorage::CommitWritePhaseOne(IKvDBMultiVerTransaction *transaction, - const UpdateVerTimeStamp &multiVerTimeStamp) + const UpdateVerTimestamp &multiVerTimestamp) { if (transaction == nullptr) { LOGE("Invalid transaction!"); @@ -177,8 +177,8 @@ int SQLiteMultiVerDataStorage::CommitWritePhaseOne(IKvDBMultiVerTransaction *tra // Call the commit of the sqlite. Version versionInfo = transaction->GetVersion(); - if (multiVerTimeStamp.isNeedUpdate) { - (void)transaction->UpdateTimestampByVersion(versionInfo, multiVerTimeStamp.timestamp); + if (multiVerTimestamp.isNeedUpdate) { + (void)transaction->UpdateTimestampByVersion(versionInfo, multiVerTimestamp.timestamp); } int errCode = transaction->CommitTransaction(); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.h b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.h index 8fca392b5..d924196c6 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.h @@ -46,7 +46,7 @@ public: int StartWrite(KvDataType dataType, IKvDBMultiVerTransaction *&transaction) override; int CommitWritePhaseOne(IKvDBMultiVerTransaction *transaction, - const UpdateVerTimeStamp &multiVerTimeStamp) override; + const UpdateVerTimestamp &multiVerTimestamp) override; int RollbackWritePhaseOne(IKvDBMultiVerTransaction *transaction, const Version &versionInfo) override; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp index a6f2940fd..37bcfe7da 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp @@ -554,7 +554,7 @@ END: return errCode; } -int SQLiteMultiVerTransaction::GetPrePutValues(const Version &versionInfo, TimeStamp timestamp, +int SQLiteMultiVerTransaction::GetPrePutValues(const Version &versionInfo, Timestamp timestamp, std::vector &values) const { sqlite3_stmt *statement = nullptr; @@ -602,7 +602,7 @@ ERROR: return errCode; } -int SQLiteMultiVerTransaction::RemovePrePutEntries(const Version &versionInfo, TimeStamp timestamp) +int SQLiteMultiVerTransaction::RemovePrePutEntries(const Version &versionInfo, Timestamp timestamp) { sqlite3_stmt *statement = nullptr; int errCode = SQLiteUtils::GetStatement(db_, DELETE_PRE_PUT_VER_DATA_SQL, statement); @@ -734,7 +734,7 @@ ERROR: return errCode; } -TimeStamp SQLiteMultiVerTransaction::GetCurrentMaxTimestamp() const +Timestamp SQLiteMultiVerTransaction::GetCurrentMaxTimestamp() const { // consider to get the statement. sqlite3_stmt *statement = nullptr; @@ -743,7 +743,7 @@ TimeStamp SQLiteMultiVerTransaction::GetCurrentMaxTimestamp() const LOGE("Get current max timestamp statement error:%d", errCode); return 0; } - TimeStamp timestamp = 0; + Timestamp timestamp = 0; // Step for getting the latest version errCode = SQLiteUtils::StepWithRetry(statement); if (errCode != SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)) { @@ -751,14 +751,14 @@ TimeStamp SQLiteMultiVerTransaction::GetCurrentMaxTimestamp() const LOGI("Initial the current max timestamp"); } } else { - timestamp = static_cast(sqlite3_column_int64(statement, 0)); // the first result. + timestamp = static_cast(sqlite3_column_int64(statement, 0)); // the first result. } SQLiteUtils::ResetStatement(statement, true, errCode); return timestamp; } int SQLiteMultiVerTransaction::UpdateTimestampByVersion(const Version &version, - TimeStamp stamp) const + Timestamp stamp) const { if (isReadOnly_) { return -E_NOT_SUPPORT; @@ -1347,7 +1347,7 @@ int SQLiteMultiVerTransaction::GetOneEntry(const GetEntriesStatements &statement } } -bool SQLiteMultiVerTransaction::IsRecordCleared(const TimeStamp timestamp) const +bool SQLiteMultiVerTransaction::IsRecordCleared(const Timestamp timestamp) const { GetClearId(); if (clearTime_ < 0) { @@ -1391,16 +1391,16 @@ int SQLiteMultiVerTransaction::CheckIfNeedSaveRecord(sqlite3_stmt *statement, co errCode = E_OK; isNeedSave = true; } else if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)) { - auto readTime = static_cast(sqlite3_column_int64(statement, 0)); // the first for time - auto readOriTime = static_cast(sqlite3_column_int64(statement, 1)); // the second for orig time. + auto readTime = static_cast(sqlite3_column_int64(statement, 0)); // the first for time + auto readOriTime = static_cast(sqlite3_column_int64(statement, 1)); // the second for orig time. auto readVersion = static_cast(sqlite3_column_int64(statement, 2)); // the third for version. errCode = SQLiteUtils::GetColumnBlobValue(statement, 3, origVal); // the fourth for origin value. if (errCode != E_OK) { return errCode; } - TimeStamp timestamp = NO_TIMESTAMP; + Timestamp timestamp = NO_TIMESTAMP; static_cast(multiVerKvEntry)->GetTimestamp(timestamp); - TimeStamp oriTimestamp = NO_TIMESTAMP; + Timestamp oriTimestamp = NO_TIMESTAMP; static_cast(multiVerKvEntry)->GetOriTimestamp(oriTimestamp); // Only the latest origin time is same or the reading time is bigger than putting time. isNeedSave = ((readTime < timestamp) && (readOriTime != oriTimestamp || value != origVal)); @@ -1421,7 +1421,7 @@ int SQLiteMultiVerTransaction::CheckIfNeedSaveRecord(const MultiVerKvEntry *mult Value &value) const { auto entry = static_cast(multiVerKvEntry); - TimeStamp timestamp = NO_TIMESTAMP; + Timestamp timestamp = NO_TIMESTAMP; entry->GetTimestamp(timestamp); if (IsRecordCleared(timestamp)) { isNeedSave = false; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.h b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.h index 72c03751d..bee608f78 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.h @@ -72,12 +72,12 @@ public: int GetEntriesByVersion(const Version &versionInfo, std::vector &entries) const override; // Update the timestamp of the version. - int UpdateTimestampByVersion(const Version &version, TimeStamp stamp) const override; + int UpdateTimestampByVersion(const Version &version, Timestamp stamp) const override; bool IsDataChanged() const override; // Get the max timestamp to generate the new version for the writing transaction - TimeStamp GetCurrentMaxTimestamp() const override; + Timestamp GetCurrentMaxTimestamp() const override; // Reset the version. void ResetVersion(); @@ -86,7 +86,7 @@ public: int Reset(CipherType type, const CipherPassword &passwd); // Check if the entry already cleared - bool IsRecordCleared(const TimeStamp timestamp) const override; + bool IsRecordCleared(const Timestamp timestamp) const override; void SetVersion(const Version &versionInfo) override; @@ -146,7 +146,7 @@ private: int GetOneEntry(const GetEntriesStatements &statements, const Key &lastKey, Entry &entry, int &errCode) const; - int RemovePrePutEntries(const Version &versionInfo, TimeStamp timestamp); + int RemovePrePutEntries(const Version &versionInfo, Timestamp timestamp); int CheckToSaveRecord(const MultiVerKvEntry *entry, bool &isNeedSave, std::vector &values); @@ -162,7 +162,7 @@ private: int GetOriginKeyValueByHash(MultiVerEntryData &item, Value &value) const; - int GetPrePutValues(const Version &versionInfo, TimeStamp timestamp, std::vector &values) const; + int GetPrePutValues(const Version &versionInfo, Timestamp timestamp, std::vector &values) const; static const std::string CREATE_TABLE_SQL; static const std::string SELECT_ONE_SQL; // select the rowid diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp index 49dd55f1b..24b52f460 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp @@ -220,7 +220,7 @@ int SqliteQueryHelper::ToQuerySql() return errCode; } -int SqliteQueryHelper::ToQuerySyncSql(bool hasSubQuery, bool useTimeStampAlias) +int SqliteQueryHelper::ToQuerySyncSql(bool hasSubQuery, bool useTimestampAlias) { int errCode = ParseQueryObjNodeToSQL(true); if (errCode != E_OK) { @@ -229,7 +229,7 @@ int SqliteQueryHelper::ToQuerySyncSql(bool hasSubQuery, bool useTimeStampAlias) // Order by time when no order by and no limit and no need order by key. if (!hasOrderBy_ && !hasLimit_ && !isNeedOrderbyKey_) { - querySql_ += (useTimeStampAlias ? + querySql_ += (useTimestampAlias ? ("ORDER BY " + DBConstant::TIMESTAMP_ALIAS + " ASC") : "ORDER BY timestamp ASC"); } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.h b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.h index 1d719b8c2..c2b19a8b4 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.h @@ -101,7 +101,7 @@ public: private: int ToQuerySql(); - int ToQuerySyncSql(bool hasSubQuery, bool useTimeStampAlias = false); + int ToQuerySyncSql(bool hasSubQuery, bool useTimestampAlias = false); int ToGetCountSql(); int ParseQueryExpression(const QueryObjNode &queryNode, std::string &querySql, const std::string &accessStr = "", bool placeholder = true); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp index 6f7a84826..d585bf636 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp @@ -16,7 +16,7 @@ #include "sqlite_single_ver_continue_token.h" namespace DistributedDB { -SQLiteSingleVerContinueToken::SQLiteSingleVerContinueToken(TimeStamp begin, TimeStamp end) +SQLiteSingleVerContinueToken::SQLiteSingleVerContinueToken(Timestamp begin, Timestamp end) : timeRanges_(MulDevTimeRanges{{"", {begin, end}}}) {} @@ -39,27 +39,27 @@ bool SQLiteSingleVerContinueToken::CheckValid() const return ((magicBegin_ == MAGIC_BEGIN) && (magicEnd_ == MAGIC_END)); } -TimeStamp SQLiteSingleVerContinueToken::GetQueryBeginTime() const +Timestamp SQLiteSingleVerContinueToken::GetQueryBeginTime() const { - return GetBeginTimeStamp(timeRanges_); + return GetBeginTimestamp(timeRanges_); } -TimeStamp SQLiteSingleVerContinueToken::GetQueryEndTime() const +Timestamp SQLiteSingleVerContinueToken::GetQueryEndTime() const { - return GetEndTimeStamp(timeRanges_); + return GetEndTimestamp(timeRanges_); } -TimeStamp SQLiteSingleVerContinueToken::GetDeletedBeginTime() const +Timestamp SQLiteSingleVerContinueToken::GetDeletedBeginTime() const { - return GetBeginTimeStamp(deleteTimeRanges_); + return GetBeginTimestamp(deleteTimeRanges_); } -TimeStamp SQLiteSingleVerContinueToken::GetDeletedEndTime() const +Timestamp SQLiteSingleVerContinueToken::GetDeletedEndTime() const { - return GetEndTimeStamp(deleteTimeRanges_); + return GetEndTimestamp(deleteTimeRanges_); } -void SQLiteSingleVerContinueToken::SetNextBeginTime(const DeviceID &deviceID, TimeStamp nextBeginTime) +void SQLiteSingleVerContinueToken::SetNextBeginTime(const DeviceID &deviceID, Timestamp nextBeginTime) { RemovePrevDevAndSetBeginTime(deviceID, nextBeginTime, timeRanges_); } @@ -69,7 +69,7 @@ const MulDevTimeRanges& SQLiteSingleVerContinueToken::GetTimeRanges() return timeRanges_; } -void SQLiteSingleVerContinueToken::SetDeletedNextBeginTime(const DeviceID &deviceID, TimeStamp nextBeginTime) +void SQLiteSingleVerContinueToken::SetDeletedNextBeginTime(const DeviceID &deviceID, Timestamp nextBeginTime) { RemovePrevDevAndSetBeginTime(deviceID, nextBeginTime, deleteTimeRanges_); } @@ -112,7 +112,7 @@ QueryObject SQLiteSingleVerContinueToken::GetQuery() const return QueryObject{}; } -void SQLiteSingleVerContinueToken::RemovePrevDevAndSetBeginTime(const DeviceID &deviceID, TimeStamp nextBeginTime, +void SQLiteSingleVerContinueToken::RemovePrevDevAndSetBeginTime(const DeviceID &deviceID, Timestamp nextBeginTime, MulDevTimeRanges &timeRanges) { auto iter = timeRanges.find(deviceID); @@ -123,7 +123,7 @@ void SQLiteSingleVerContinueToken::RemovePrevDevAndSetBeginTime(const DeviceID & iter->second.first = nextBeginTime; } -TimeStamp SQLiteSingleVerContinueToken::GetBeginTimeStamp(const MulDevTimeRanges &timeRanges) const +Timestamp SQLiteSingleVerContinueToken::GetBeginTimestamp(const MulDevTimeRanges &timeRanges) const { if (timeRanges.empty()) { return 0; @@ -131,10 +131,10 @@ TimeStamp SQLiteSingleVerContinueToken::GetBeginTimeStamp(const MulDevTimeRanges return timeRanges.begin()->second.first; } -TimeStamp SQLiteSingleVerContinueToken::GetEndTimeStamp(const MulDevTimeRanges &timeRanges) const +Timestamp SQLiteSingleVerContinueToken::GetEndTimestamp(const MulDevTimeRanges &timeRanges) const { if (timeRanges.empty()) { - return static_cast(INT64_MAX); + return static_cast(INT64_MAX); } return timeRanges.begin()->second.second; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.h b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.h index 355b0c55a..5350cd34b 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.h @@ -25,7 +25,7 @@ namespace DistributedDB { class SQLiteSingleVerContinueToken { public: // For one device. - SQLiteSingleVerContinueToken(TimeStamp begin, TimeStamp end); + SQLiteSingleVerContinueToken(Timestamp begin, Timestamp end); // For one device in query sync. SQLiteSingleVerContinueToken(const SyncTimeRange &timeRange, const QueryObject &queryObject); @@ -42,14 +42,14 @@ public: */ bool CheckValid() const; - TimeStamp GetQueryBeginTime() const; - TimeStamp GetQueryEndTime() const; - TimeStamp GetDeletedBeginTime() const; - TimeStamp GetDeletedEndTime() const; + Timestamp GetQueryBeginTime() const; + Timestamp GetQueryEndTime() const; + Timestamp GetDeletedBeginTime() const; + Timestamp GetDeletedEndTime() const; - void SetNextBeginTime(const DeviceID &deviceID, TimeStamp nextBeginTime); + void SetNextBeginTime(const DeviceID &deviceID, Timestamp nextBeginTime); const MulDevTimeRanges &GetTimeRanges(); - void SetDeletedNextBeginTime(const DeviceID &deviceID, TimeStamp nextBeginTime); + void SetDeletedNextBeginTime(const DeviceID &deviceID, Timestamp nextBeginTime); const MulDevTimeRanges &GetDeletedTimeRanges() const; void FinishGetQueryData(); @@ -62,10 +62,10 @@ public: QueryObject GetQuery() const; private: - void RemovePrevDevAndSetBeginTime(const DeviceID &deviceID, TimeStamp nextBeginTime, MulDevTimeRanges &timeRanges); + void RemovePrevDevAndSetBeginTime(const DeviceID &deviceID, Timestamp nextBeginTime, MulDevTimeRanges &timeRanges); - TimeStamp GetBeginTimeStamp(const MulDevTimeRanges &timeRanges) const; - TimeStamp GetEndTimeStamp(const MulDevTimeRanges &timeRanges) const; + Timestamp GetBeginTimestamp(const MulDevTimeRanges &timeRanges) const; + Timestamp GetEndTimestamp(const MulDevTimeRanges &timeRanges) const; static const unsigned int MAGIC_BEGIN = 0x600D0AC7; // for token guard static const unsigned int MAGIC_END = 0x0AC7600D; // for token guard diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp index efd8b59f7..134edd218 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp @@ -61,7 +61,7 @@ namespace { return; } - TimeStamp nextBeginTime = dataItems.back().timeStamp + 1; + Timestamp nextBeginTime = dataItems.back().timestamp + 1; if (nextBeginTime > INT64_MAX) { nextBeginTime = INT64_MAX; } @@ -96,7 +96,7 @@ namespace { return; } - TimeStamp nextBeginTime = dataItems.back().timeStamp + 1; + Timestamp nextBeginTime = dataItems.back().timestamp + 1; if (nextBeginTime > INT64_MAX) { nextBeginTime = INT64_MAX; } @@ -158,7 +158,7 @@ namespace { } SQLiteSingleVerNaturalStore::SQLiteSingleVerNaturalStore() - : currentMaxTimeStamp_(0), + : currentMaxTimestamp_(0), storageEngine_(nullptr), notificationEventsRegistered_(false), notificationConflictEventsRegistered_(false), @@ -553,8 +553,8 @@ int SQLiteSingleVerNaturalStore::GetMetaData(const Key &key, Value &value) const return errCode; } - TimeStamp timeStamp; - errCode = handle->GetKvData(SingleVerDataType::META_TYPE, key, value, timeStamp); + Timestamp timestamp; + errCode = handle->GetKvData(SingleVerDataType::META_TYPE, key, value, timestamp); ReleaseHandle(handle); HeartBeatForLifeCycle(); return errCode; @@ -646,7 +646,7 @@ void SQLiteSingleVerNaturalStore::CommitAndReleaseNotifyData(SingleVerNaturalSto } } -int SQLiteSingleVerNaturalStore::GetSyncData(TimeStamp begin, TimeStamp end, std::vector &entries, +int SQLiteSingleVerNaturalStore::GetSyncData(Timestamp begin, Timestamp end, std::vector &entries, ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const { int errCode = CheckReadDataControlled(); @@ -681,7 +681,7 @@ ERROR: return errCode; } -int SQLiteSingleVerNaturalStore::GetSyncData(TimeStamp begin, TimeStamp end, std::vector &dataItems, +int SQLiteSingleVerNaturalStore::GetSyncData(Timestamp begin, Timestamp end, std::vector &dataItems, ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const { if (begin >= end || dataSizeInfo.blockSize > DBConstant::MAX_SYNC_BLOCK_SIZE) { @@ -900,8 +900,8 @@ int SQLiteSingleVerNaturalStore::PutSyncDataWithQuery(const QueryObject &query, DataItem item; item.origDev = entry->GetOrigDevice(); item.flag = entry->GetFlag(); - item.timeStamp = entry->GetTimestamp(); - item.writeTimeStamp = entry->GetWriteTimestamp(); + item.timestamp = entry->GetTimestamp(); + item.writeTimestamp = entry->GetWriteTimestamp(); entry->GetKey(item.key); entry->GetValue(item.value); dataItems.push_back(item); @@ -916,17 +916,17 @@ int SQLiteSingleVerNaturalStore::PutSyncDataWithQuery(const QueryObject &query, return errCode; } -void SQLiteSingleVerNaturalStore::GetMaxTimeStamp(TimeStamp &stamp) const +void SQLiteSingleVerNaturalStore::GetMaxTimestamp(Timestamp &stamp) const { - std::lock_guard lock(maxTimeStampMutex_); - stamp = currentMaxTimeStamp_; + std::lock_guard lock(maxTimestampMutex_); + stamp = currentMaxTimestamp_; } -int SQLiteSingleVerNaturalStore::SetMaxTimeStamp(TimeStamp timestamp) +int SQLiteSingleVerNaturalStore::SetMaxTimestamp(Timestamp timestamp) { - std::lock_guard lock(maxTimeStampMutex_); - if (timestamp > currentMaxTimeStamp_) { - currentMaxTimeStamp_ = timestamp; + std::lock_guard lock(maxTimestampMutex_); + if (timestamp > currentMaxTimestamp_) { + currentMaxTimestamp_ = timestamp; } return E_OK; } @@ -1158,8 +1158,8 @@ void SQLiteSingleVerNaturalStore::InitCurrentMaxStamp() return; } - handle->InitCurrentMaxStamp(currentMaxTimeStamp_); - LOGD("Init max timestamp:%" PRIu64, currentMaxTimeStamp_); + handle->InitCurrentMaxStamp(currentMaxTimestamp_); + LOGD("Init max timestamp:%" PRIu64, currentMaxTimestamp_); ReleaseHandle(handle); } @@ -1220,12 +1220,12 @@ int SQLiteSingleVerNaturalStore::SaveSyncDataToMain(const QueryObject &query, st return -E_OUT_OF_MEMORY; } InitConflictNotifiedFlag(committedData); - TimeStamp maxTimestamp = 0; + Timestamp maxTimestamp = 0; bool isNeedCommit = false; int errCode = SaveSyncItems(query, dataItems, deviceInfo, maxTimestamp, committedData); if (errCode == E_OK) { isNeedCommit = true; - (void)SetMaxTimeStamp(maxTimestamp); + (void)SetMaxTimestamp(maxTimestamp); } CommitAndReleaseNotifyData(committedData, isNeedCommit, SQLITE_GENERAL_NS_SYNC_EVENT); @@ -1235,7 +1235,7 @@ int SQLiteSingleVerNaturalStore::SaveSyncDataToMain(const QueryObject &query, st // Currently, this function only suitable to be call from sync in insert_record_from_sync procedure // Take attention if future coder attempt to call it in other situation procedure int SQLiteSingleVerNaturalStore::SaveSyncItems(const QueryObject &query, std::vector &dataItems, - const DeviceInfo &deviceInfo, TimeStamp &maxTimestamp, SingleVerNaturalStoreCommitNotifyData *commitData) const + const DeviceInfo &deviceInfo, Timestamp &maxTimestamp, SingleVerNaturalStoreCommitNotifyData *commitData) const { int errCode = E_OK; int innerCode = E_OK; @@ -1293,20 +1293,20 @@ int SQLiteSingleVerNaturalStore::SaveSyncDataToCacheDB(const QueryObject &query, return errCode; } - TimeStamp maxTimestamp = 0; + Timestamp maxTimestamp = 0; errCode = SaveSyncItemsInCacheMode(handle, query, dataItems, deviceInfo, maxTimestamp); if (errCode != E_OK) { LOGE("[SingleVerNStore] Failed to save sync data in cache mode, err : %d", errCode); } else { - (void)SetMaxTimeStamp(maxTimestamp); + (void)SetMaxTimestamp(maxTimestamp); } ReleaseHandle(handle); return errCode; } -TimeStamp SQLiteSingleVerNaturalStore::GetCurrentTimeStamp() +Timestamp SQLiteSingleVerNaturalStore::GetCurrentTimestamp() { - return GetTimeStamp(); + return GetTimestamp(); } int SQLiteSingleVerNaturalStore::InitStorageEngine(const KvDBProperties &kvDBProp, bool isNeedUpdateSecOpt) @@ -1601,11 +1601,11 @@ int SQLiteSingleVerNaturalStore::GetSchema(SchemaObject &schema) const return errCode; } - TimeStamp timeStamp; + Timestamp timestamp; std::string schemaKey = DBConstant::SCHEMA_KEY; Key key(schemaKey.begin(), schemaKey.end()); Value value; - errCode = handle->GetKvData(SingleVerDataType::META_TYPE, key, value, timeStamp); + errCode = handle->GetKvData(SingleVerDataType::META_TYPE, key, value, timestamp); if (errCode == E_OK) { std::string schemaValue(value.begin(), value.end()); errCode = schema.ParseFromSchemaString(schemaValue); @@ -1643,7 +1643,7 @@ int SQLiteSingleVerNaturalStore::DecideReadOnlyBaseOnSchema(const KvDBProperties void SQLiteSingleVerNaturalStore::InitialLocalDataTimestamp() { - TimeStamp timeStamp = GetCurrentTimeStamp(); + Timestamp timestamp = GetCurrentTimestamp(); int errCode = E_OK; auto handle = GetHandle(true, errCode); @@ -1651,7 +1651,7 @@ void SQLiteSingleVerNaturalStore::InitialLocalDataTimestamp() return; } - errCode = handle->UpdateLocalDataTimestamp(timeStamp); + errCode = handle->UpdateLocalDataTimestamp(timestamp); if (errCode != E_OK) { LOGE("Update the timestamp for local data failed:%d", errCode); } @@ -1952,7 +1952,7 @@ void SQLiteSingleVerNaturalStore::CheckAmendValueContentForSyncProcedure(std::ve int SQLiteSingleVerNaturalStore::SaveSyncItemsInCacheMode(SQLiteSingleVerStorageExecutor *handle, const QueryObject &query, std::vector &dataItems, const DeviceInfo &deviceInfo, - TimeStamp &maxTimestamp) const + Timestamp &maxTimestamp) const { int errCode = handle->StartTransaction(TransactType::IMMEDIATE); if (errCode != E_OK) { @@ -1998,7 +1998,7 @@ void SQLiteSingleVerNaturalStore::NotifyRemotePushFinished(const std::string &ta NotifyRemotePushFinishedInner(targetId); } -int SQLiteSingleVerNaturalStore::GetDatabaseCreateTimeStamp(TimeStamp &outTime) const +int SQLiteSingleVerNaturalStore::GetDatabaseCreateTimestamp(Timestamp &outTime) const { // Found in memory. { @@ -2013,11 +2013,11 @@ int SQLiteSingleVerNaturalStore::GetDatabaseCreateTimeStamp(TimeStamp &outTime) Value value; int errCode = GetMetaData(key, value); if (errCode != E_OK) { - LOGD("GetDatabaseCreateTimeStamp failed, errCode = %d.", errCode); + LOGD("GetDatabaseCreateTimestamp failed, errCode = %d.", errCode); return errCode; } - TimeStamp createDBTime = 0; + Timestamp createDBTime = 0; Parcel parcel(value.data(), value.size()); (void)parcel.ReadUInt64(createDBTime); if (parcel.IsError()) { @@ -2044,7 +2044,7 @@ int SQLiteSingleVerNaturalStore::CheckIntegrity() const int SQLiteSingleVerNaturalStore::SaveCreateDBTime() { - TimeStamp createDBTime = GetCurrentTimeStamp(); + Timestamp createDBTime = GetCurrentTimestamp(); const Key key(CREATE_DB_TIME.begin(), CREATE_DB_TIME.end()); Value value(Parcel::GetUInt64Len()); Parcel parcel(value.data(), Parcel::GetUInt64Len()); @@ -2068,8 +2068,8 @@ int SQLiteSingleVerNaturalStore::SaveCreateDBTime() int SQLiteSingleVerNaturalStore::SaveCreateDBTimeIfNotExisted() { - TimeStamp createDBTime = 0; - int errCode = GetDatabaseCreateTimeStamp(createDBTime); + Timestamp createDBTime = 0; + int errCode = GetDatabaseCreateTimestamp(createDBTime); if (errCode == -E_NOT_FOUND) { errCode = SaveCreateDBTime(); } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.h b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.h index 20d84ee59..ba92829f7 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.h @@ -72,10 +72,10 @@ public: int GetAllMetaKeys(std::vector &keys) const override; - int GetSyncData(TimeStamp begin, TimeStamp end, std::vector &dataItems, ContinueToken &continueStmtToken, + int GetSyncData(Timestamp begin, Timestamp end, std::vector &dataItems, ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const override; - int GetSyncData(TimeStamp begin, TimeStamp end, std::vector &entries, + int GetSyncData(Timestamp begin, Timestamp end, std::vector &entries, ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const override; int GetSyncData(QueryObject &query, const SyncTimeRange &timeRange, const DataSizeSpecInfo &dataSizeInfo, @@ -92,9 +92,9 @@ public: int PutSyncDataWithQuery(const QueryObject &query, const std::vector &entries, const std::string &deviceName) override; - void GetMaxTimeStamp(TimeStamp &stamp) const override; + void GetMaxTimestamp(Timestamp &stamp) const override; - int SetMaxTimeStamp(TimeStamp timestamp); + int SetMaxTimestamp(Timestamp timestamp); int Rekey(const CipherPassword &passwd) override; @@ -123,7 +123,7 @@ public: bool CheckCompatible(const std::string &schema, uint8_t type) const override; - TimeStamp GetCurrentTimeStamp(); + Timestamp GetCurrentTimestamp(); SchemaObject GetSchemaObject() const; @@ -163,7 +163,7 @@ public: void NotifyRemotePushFinished(const std::string &targetId) const override; - int GetDatabaseCreateTimeStamp(TimeStamp &outTime) const override; + int GetDatabaseCreateTimestamp(Timestamp &outTime) const override; int CheckIntegrity() const override; @@ -245,13 +245,13 @@ private: // Currently, this function only suitable to be call from sync in insert_record_from_sync procedure // Take attention if future coder attempt to call it in other situation procedure int SaveSyncItems(const QueryObject& query, std::vector &dataItems, const DeviceInfo &deviceInfo, - TimeStamp &maxTimestamp, SingleVerNaturalStoreCommitNotifyData *commitData) const; + Timestamp &maxTimestamp, SingleVerNaturalStoreCommitNotifyData *commitData) const; int SaveSyncDataToCacheDB(const QueryObject &query, std::vector &dataItems, const DeviceInfo &deviceInfo); int SaveSyncItemsInCacheMode(SQLiteSingleVerStorageExecutor *handle, const QueryObject &query, - std::vector &dataItems, const DeviceInfo &deviceInfo, TimeStamp &maxTimestamp) const; + std::vector &dataItems, const DeviceInfo &deviceInfo, Timestamp &maxTimestamp) const; int ClearIncompleteDatabase(const KvDBProperties &kvDBPro) const; @@ -267,7 +267,7 @@ private: DECLARE_OBJECT_TAG(SQLiteSingleVerNaturalStore); - TimeStamp currentMaxTimeStamp_ = 0; + Timestamp currentMaxTimestamp_ = 0; SQLiteSingleVerStorageEngine *storageEngine_; bool notificationEventsRegistered_; bool notificationConflictEventsRegistered_; @@ -275,12 +275,12 @@ private: bool isReadOnly_; mutable std::mutex syncerMutex_; mutable std::mutex initialMutex_; - mutable std::mutex maxTimeStampMutex_; + mutable std::mutex maxTimestampMutex_; mutable std::mutex lifeCycleMutex_; mutable DatabaseLifeCycleNotifier lifeCycleNotifier_; mutable TimerId lifeTimerId_; uint32_t autoLifeTime_; - mutable TimeStamp createDBTime_; + mutable Timestamp createDBTime_; mutable std::mutex createDBTimeMutex_; mutable std::shared_mutex dataInterceptorMutex_; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp index 958b5aceb..9150f8e88 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp @@ -42,7 +42,7 @@ SQLiteSingleVerNaturalStoreConnection::SQLiteSingleVerNaturalStoreConnection(SQL cacheMaxSizeForNewResultSet_(DEFAULT_RESULT_SET_CACHE_MAX_SIZE), conflictType_(0), transactionEntrySize_(0), - currentMaxTimeStamp_(0), + currentMaxTimestamp_(0), committedData_(nullptr), localCommittedData_(nullptr), transactionExeFlag_(false), @@ -100,8 +100,8 @@ int SQLiteSingleVerNaturalStoreConnection::Get(const IOption &option, const Key std::lock_guard lock(transactionMutex_); if (writeHandle_ != nullptr) { LOGD("Transaction started already."); - TimeStamp recordTimeStamp; - return writeHandle_->GetKvData(dataType, key, value, recordTimeStamp); + Timestamp recordTimestamp; + return writeHandle_->GetKvData(dataType, key, value, recordTimestamp); } } @@ -110,8 +110,8 @@ int SQLiteSingleVerNaturalStoreConnection::Get(const IOption &option, const Key return errCode; } - TimeStamp timeStamp; - errCode = handle->GetKvData(dataType, key, value, timeStamp); + Timestamp timestamp; + errCode = handle->GetKvData(dataType, key, value, timestamp); ReleaseExecutor(handle); return errCode; } @@ -960,7 +960,7 @@ int SQLiteSingleVerNaturalStoreConnection::DeleteLocalEntries(const std::vector< // This function currently only be called in local procedure to change sync_data table, do not use in sync procedure. // It will check and amend value when need if it is a schema database. return error if some value disagree with the // schema. But in sync procedure, we just neglect the value that disagree with schema. -int SQLiteSingleVerNaturalStoreConnection::SaveEntry(const Entry &entry, bool isDelete, TimeStamp timeStamp) +int SQLiteSingleVerNaturalStoreConnection::SaveEntry(const Entry &entry, bool isDelete, Timestamp timestamp) { SQLiteSingleVerNaturalStore *naturalStore = GetDB(); if (naturalStore == nullptr) { @@ -981,15 +981,15 @@ int SQLiteSingleVerNaturalStoreConnection::SaveEntry(const Entry &entry, bool is } } - dataItem.timeStamp = naturalStore->GetCurrentTimeStamp(); - if (currentMaxTimeStamp_ > dataItem.timeStamp) { - dataItem.timeStamp = currentMaxTimeStamp_; + dataItem.timestamp = naturalStore->GetCurrentTimestamp(); + if (currentMaxTimestamp_ > dataItem.timestamp) { + dataItem.timestamp = currentMaxTimestamp_; } - if (timeStamp != 0) { - dataItem.writeTimeStamp = timeStamp; + if (timestamp != 0) { + dataItem.writeTimestamp = timestamp; } else { - dataItem.writeTimeStamp = dataItem.timeStamp; + dataItem.writeTimestamp = dataItem.timestamp; } if (IsExtendedCacheDBMode()) { @@ -1014,8 +1014,8 @@ int SQLiteSingleVerNaturalStoreConnection::SaveLocalEntry(const Entry &entry, bo if (isDelete) { dataItem.flag = DataItem::DELETE_FLAG; } - dataItem.timeStamp = naturalStore->GetCurrentTimeStamp(); - LOGD("TimeStamp is %" PRIu64, dataItem.timeStamp); + dataItem.timestamp = naturalStore->GetCurrentTimestamp(); + LOGD("Timestamp is %" PRIu64, dataItem.timestamp); if (IsCacheDBMode()) { return SaveLocalItemInCacheMode(dataItem); @@ -1029,11 +1029,11 @@ int SQLiteSingleVerNaturalStoreConnection::SaveLocalItem(const LocalDataItem &da int errCode = E_OK; if ((dataItem.flag & DataItem::DELETE_FLAG) == 0) { errCode = writeHandle_->PutKvData(SingleVerDataType::LOCAL_TYPE, dataItem.key, dataItem.value, - dataItem.timeStamp, localCommittedData_); + dataItem.timestamp, localCommittedData_); } else { Value value; - TimeStamp localTimeStamp = 0; - errCode = writeHandle_->DeleteLocalKvData(dataItem.key, localCommittedData_, value, localTimeStamp); + Timestamp localTimestamp = 0; + errCode = writeHandle_->DeleteLocalKvData(dataItem.key, localCommittedData_, value, localTimestamp); } return errCode; } @@ -1060,12 +1060,12 @@ int SQLiteSingleVerNaturalStoreConnection::SaveEntryNormally(DataItem &dataItem) return errCode; } - TimeStamp maxTimestamp = 0; + Timestamp maxTimestamp = 0; DeviceInfo deviceInfo = {true, ""}; errCode = writeHandle_->SaveSyncDataItem(dataItem, deviceInfo, maxTimestamp, committedData_); if (errCode == E_OK) { - if (maxTimestamp > currentMaxTimeStamp_) { - currentMaxTimeStamp_ = maxTimestamp; + if (maxTimestamp > currentMaxTimestamp_) { + currentMaxTimestamp_ = maxTimestamp; } } else { LOGE("Save entry failed, err:%d", errCode); @@ -1081,13 +1081,13 @@ int SQLiteSingleVerNaturalStoreConnection::SaveEntryInCacheMode(DataItem &dataIt return errCode; } - TimeStamp maxTimestamp = 0; + Timestamp maxTimestamp = 0; DeviceInfo deviceInfo = {true, ""}; QueryObject query(Query::Select()); errCode = writeHandle_->SaveSyncDataItemInCacheMode(dataItem, deviceInfo, maxTimestamp, recordVersion, query); if (errCode == E_OK) { - if (maxTimestamp > currentMaxTimeStamp_) { - currentMaxTimeStamp_ = maxTimestamp; + if (maxTimestamp > currentMaxTimestamp_) { + currentMaxTimestamp_ = maxTimestamp; } } else { LOGE("Save entry failed, err:%d", errCode); @@ -1337,7 +1337,7 @@ int SQLiteSingleVerNaturalStoreConnection::CommitInner() if (naturalStore == nullptr) { return -E_INVALID_DB; } - naturalStore->SetMaxTimeStamp(currentMaxTimeStamp_); + naturalStore->SetMaxTimestamp(currentMaxTimestamp_); if (isCacheOrMigrating) { naturalStore->IncreaseCacheRecordVersion(); @@ -1349,7 +1349,7 @@ int SQLiteSingleVerNaturalStoreConnection::RollbackInner() { int errCode = writeHandle_->Rollback(); transactionEntrySize_ = 0; - currentMaxTimeStamp_ = 0; + currentMaxTimestamp_ = 0; if (!IsExtendedCacheDBMode()) { ReleaseCommitData(committedData_); ReleaseCommitData(localCommittedData_); @@ -1453,7 +1453,7 @@ int SQLiteSingleVerNaturalStoreConnection::PublishLocal(const Key &key, bool del int SQLiteSingleVerNaturalStoreConnection::PublishLocalCallback(bool updateTimestamp, const SingleVerRecord &localRecord, const SingleVerRecord &syncRecord, const KvStoreNbPublishAction &onConflict) { - bool isLocalLastest = updateTimestamp ? true : (localRecord.timeStamp > syncRecord.writeTimeStamp); + bool isLocalLastest = updateTimestamp ? true : (localRecord.timestamp > syncRecord.writeTimestamp); if ((syncRecord.flag & DataItem::DELETE_FLAG) == DataItem::DELETE_FLAG) { onConflict({localRecord.key, localRecord.value}, nullptr, isLocalLastest); } else { @@ -1474,13 +1474,13 @@ int SQLiteSingleVerNaturalStoreConnection::PublishInner(SingleVerNaturalStoreCom if (committedData != nullptr) { errCode = writeHandle_->DeleteLocalKvData(localRecord.key, committedData, localRecord.value, - localRecord.timeStamp); + localRecord.timestamp); if (errCode != E_OK) { LOGE("Delete local kv data err:%d", errCode); return errCode; } } else { - if (!writeHandle_->CheckIfKeyExisted(localRecord.key, true, localRecord.value, localRecord.timeStamp)) { + if (!writeHandle_->CheckIfKeyExisted(localRecord.key, true, localRecord.value, localRecord.timestamp)) { LOGE("Record not found."); return -E_NOT_FOUND; } @@ -1501,16 +1501,16 @@ int SQLiteSingleVerNaturalStoreConnection::PublishInner(SingleVerNaturalStoreCom if (updateTimestamp) { // local win errCode = SaveEntry({localRecord.key, localRecord.value}, false); } else { - if (localRecord.timeStamp <= syncRecord.writeTimeStamp) { // sync win + if (localRecord.timestamp <= syncRecord.writeTimestamp) { // sync win errCode = -E_STALE; } else { - errCode = SaveEntry({localRecord.key, localRecord.value}, false, localRecord.timeStamp); + errCode = SaveEntry({localRecord.key, localRecord.value}, false, localRecord.timestamp); } } } else { isNeedCallback = false; if (errCode == -E_NOT_FOUND) { - errCode = SaveEntry({localRecord.key, localRecord.value}, false, localRecord.timeStamp); + errCode = SaveEntry({localRecord.key, localRecord.value}, false, localRecord.timestamp); } } return errCode; @@ -1585,13 +1585,13 @@ int SQLiteSingleVerNaturalStoreConnection::UnpublishInner(SingleVerNaturalStoreC SingleVerRecord localRecord; innerErrCode = -E_LOCAL_DEFEAT; - if (writeHandle_->CheckIfKeyExisted(syncRecord.key, true, localRecord.value, localRecord.timeStamp)) { + if (writeHandle_->CheckIfKeyExisted(syncRecord.key, true, localRecord.value, localRecord.timestamp)) { if ((syncRecord.flag & DataItem::DELETE_FLAG) == DataItem::DELETE_FLAG) { - if (updateTimestamp || localRecord.timeStamp <= syncRecord.writeTimeStamp) { // sync win + if (updateTimestamp || localRecord.timestamp <= syncRecord.writeTimestamp) { // sync win innerErrCode = -E_LOCAL_DELETED; localOperation = LOCAL_OPR_DEL; } - } else if (updateTimestamp || localRecord.timeStamp <= syncRecord.writeTimeStamp) { // sync win + } else if (updateTimestamp || localRecord.timestamp <= syncRecord.writeTimestamp) { // sync win innerErrCode = -E_LOCAL_COVERED; localOperation = LOCAL_OPR_PUT; } @@ -1629,13 +1629,13 @@ int SQLiteSingleVerNaturalStoreConnection::UnpublishOper(SingleVerNaturalStoreCo return errCode; } - TimeStamp time = updateTimestamp ? naturalStore->GetCurrentTimeStamp() : syncRecord.writeTimeStamp; + Timestamp time = updateTimestamp ? naturalStore->GetCurrentTimestamp() : syncRecord.writeTimestamp; errCode = writeHandle_->PutKvData(SingleVerDataType::LOCAL_TYPE, syncRecord.key, syncRecord.value, time, committedData); } else if (operType == LOCAL_OPR_DEL) { - TimeStamp localTimeStamp = 0; + Timestamp localTimestamp = 0; Value value; - errCode = writeHandle_->DeleteLocalKvData(syncRecord.key, committedData, value, localTimeStamp); + errCode = writeHandle_->DeleteLocalKvData(syncRecord.key, committedData, value, localTimestamp); } return errCode; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.h b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.h index 51a712483..dfaf1d681 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.h @@ -120,7 +120,7 @@ private: int DeleteSyncEntries(const std::vector &keys); int DeleteLocalEntries(const std::vector &keys); - int SaveEntry(const Entry &entry, bool isDelete, TimeStamp timeStamp = 0); + int SaveEntry(const Entry &entry, bool isDelete, Timestamp timestamp = 0); int CheckDataStatus(const Key &key, const Value &value, bool isDelete) const; @@ -211,7 +211,7 @@ private: int conflictType_; uint32_t transactionEntrySize_; // used for transaction - TimeStamp currentMaxTimeStamp_; // used for transaction + Timestamp currentMaxTimestamp_; // used for transaction SingleVerNaturalStoreCommitNotifyData *committedData_; // used for transaction SingleVerNaturalStoreCommitNotifyData *localCommittedData_; std::atomic transactionExeFlag_; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp index 3060169d1..671d87321 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp @@ -57,7 +57,7 @@ int SQLiteSingleVerRelationalContinueToken::GetStatement(sqlite3 *db, sqlite3_st void SQLiteSingleVerRelationalContinueToken::SetNextBeginTime(const DataItem &theLastItem) { - TimeStamp nextBeginTime = theLastItem.timeStamp + 1; + Timestamp nextBeginTime = theLastItem.timestamp + 1; if (nextBeginTime > INT64_MAX) { nextBeginTime = INT64_MAX; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp index cf008c14b..35b2f41e4 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp @@ -447,7 +447,7 @@ static int GetLogData(sqlite3_stmt *logStatement, LogInfo &logInfo) } logInfo.originDev = std::string(oriDev.begin(), oriDev.end()); logInfo.timestamp = static_cast(sqlite3_column_int64(logStatement, 3)); // 3 means timestamp index - logInfo.wTimeStamp = static_cast(sqlite3_column_int64(logStatement, 4)); // 4 means w_timestamp index + logInfo.wTimestamp = static_cast(sqlite3_column_int64(logStatement, 4)); // 4 means w_timestamp index logInfo.flag = static_cast(sqlite3_column_int64(logStatement, 5)); // 5 means flag index logInfo.flag &= (~DataItem::LOCAL_FLAG); logInfo.flag &= (~DataItem::UPDATE_FLAG); @@ -658,7 +658,7 @@ int SQLiteSingleVerRelationalStorageExecutor::PrepareForSavingData(const QueryOb } int SQLiteSingleVerRelationalStorageExecutor::SaveSyncLog(sqlite3_stmt *statement, sqlite3_stmt *queryStmt, - const DataItem &dataItem, TimeStamp &maxTimestamp, int64_t rowid) + const DataItem &dataItem, Timestamp &maxTimestamp, int64_t rowid) { int errCode = SQLiteUtils::BindBlobToStatement(queryStmt, 1, dataItem.hashKey); // 1 means hashkey index. if (errCode != E_OK) { @@ -680,14 +680,14 @@ int SQLiteSingleVerRelationalStorageExecutor::SaveSyncLog(sqlite3_stmt *statemen LogInfo logInfoBind; logInfoBind.hashKey = dataItem.hashKey; logInfoBind.device = dataItem.dev; - logInfoBind.timestamp = dataItem.timeStamp; + logInfoBind.timestamp = dataItem.timestamp; logInfoBind.flag = dataItem.flag; - logInfoBind.wTimeStamp = maxTimestamp; + logInfoBind.wTimestamp = maxTimestamp; if (errCode == -E_NOT_FOUND) { // insert logInfoBind.originDev = dataItem.dev; } else if (errCode == E_OK) { // update - logInfoBind.wTimeStamp = logInfoGet.wTimeStamp; + logInfoBind.wTimestamp = logInfoGet.wTimestamp; logInfoBind.originDev = logInfoGet.originDev; } else { return errCode; @@ -698,7 +698,7 @@ int SQLiteSingleVerRelationalStorageExecutor::SaveSyncLog(sqlite3_stmt *statemen std::vector originDev(logInfoBind.originDev.begin(), logInfoBind.originDev.end()); SQLiteUtils::BindBlobToStatement(statement, 2, originDev); // 2 means ori_dev index SQLiteUtils::BindInt64ToStatement(statement, 3, logInfoBind.timestamp); // 3 means timestamp index - SQLiteUtils::BindInt64ToStatement(statement, 4, logInfoBind.wTimeStamp); // 4 means w_timestamp index + SQLiteUtils::BindInt64ToStatement(statement, 4, logInfoBind.wTimestamp); // 4 means w_timestamp index SQLiteUtils::BindInt64ToStatement(statement, 5, logInfoBind.flag); // 5 means flag index SQLiteUtils::BindBlobToStatement(statement, 6, logInfoBind.hashKey); // 6 means hashKey index errCode = SQLiteUtils::StepWithRetry(statement, isMemDb_); @@ -837,7 +837,7 @@ int SQLiteSingleVerRelationalStorageExecutor::GetSyncDataPre(const DataItem &dat } else { errCode = GetLogData(saveStmt_.queryStmt, logInfoGet); } - itemGet.timeStamp = logInfoGet.timestamp; + itemGet.timestamp = logInfoGet.timestamp; SQLiteUtils::ResetStatement(saveStmt_.queryStmt, false, errCode); return errCode; } @@ -855,12 +855,12 @@ int SQLiteSingleVerRelationalStorageExecutor::CheckDataConflictDefeated(const Da LOGE("Failed to get raw data. %d", errCode); return errCode; } - isDefeated = (dataItem.timeStamp <= itemGet.timeStamp); // defeated if item timestamp is earlier then raw data + isDefeated = (dataItem.timestamp <= itemGet.timestamp); // defeated if item timestamp is earlier then raw data return E_OK; } int SQLiteSingleVerRelationalStorageExecutor::SaveSyncDataItem(const std::vector &fieldInfos, - const std::string &deviceName, DataItem &item, TimeStamp &maxTimestamp) + const std::string &deviceName, DataItem &item, Timestamp &maxTimestamp) { item.dev = deviceName; bool isDefeated = false; @@ -886,7 +886,7 @@ int SQLiteSingleVerRelationalStorageExecutor::SaveSyncDataItem(const std::vector } int SQLiteSingleVerRelationalStorageExecutor::SaveSyncDataItems(const QueryObject &object, - std::vector &dataItems, const std::string &deviceName, TimeStamp &maxTimestamp) + std::vector &dataItems, const std::string &deviceName, Timestamp &maxTimestamp) { int errCode = PrepareForSavingData(object, saveStmt_.saveDataStmt); if (errCode != E_OK) { @@ -910,7 +910,7 @@ int SQLiteSingleVerRelationalStorageExecutor::SaveSyncDataItems(const QueryObjec if (errCode != E_OK) { break; } - maxTimestamp = std::max(item.timeStamp, maxTimestamp); + maxTimestamp = std::max(item.timestamp, maxTimestamp); // Need not reset rmDataStmt and rmLogStmt here. saveStmt_.ResetStatements(false); } @@ -922,7 +922,7 @@ int SQLiteSingleVerRelationalStorageExecutor::SaveSyncDataItems(const QueryObjec } int SQLiteSingleVerRelationalStorageExecutor::SaveSyncItems(const QueryObject &object, std::vector &dataItems, - const std::string &deviceName, const TableInfo &table, TimeStamp &timeStamp) + const std::string &deviceName, const TableInfo &table, Timestamp ×tamp) { int errCode = StartTransaction(TransactType::IMMEDIATE); if (errCode != E_OK) { @@ -932,7 +932,7 @@ int SQLiteSingleVerRelationalStorageExecutor::SaveSyncItems(const QueryObject &o SetTableInfo(table); const std::string tableName = DBCommon::GetDistributedTableName(deviceName, baseTblName_); table_.SetTableName(tableName); - errCode = SaveSyncDataItems(object, dataItems, deviceName, timeStamp); + errCode = SaveSyncDataItems(object, dataItems, deviceName, timestamp); if (errCode == E_OK) { errCode = Commit(); } else { @@ -982,7 +982,7 @@ int SQLiteSingleVerRelationalStorageExecutor::GetMissQueryData(sqlite3_stmt *ful } namespace { -int StepNext(bool isMemDB, sqlite3_stmt *stmt, TimeStamp ×tamp) +int StepNext(bool isMemDB, sqlite3_stmt *stmt, Timestamp ×tamp) { if (stmt == nullptr) { return -E_INVALID_ARGS; @@ -1018,7 +1018,7 @@ int AppendData(const DataSizeSpecInfo &sizeInfo, size_t appendLength, size_t &ov } int SQLiteSingleVerRelationalStorageExecutor::GetQueryDataAndStepNext(bool isFirstTime, bool isGettingDeletedData, - sqlite3_stmt *queryStmt, DataItem &item, TimeStamp &queryTime) + sqlite3_stmt *queryStmt, DataItem &item, Timestamp &queryTime) { if (!isFirstTime) { // For the first time, never step before, can get nothing int errCode = GetDataItemForSync(queryStmt, item, isGettingDeletedData); @@ -1030,7 +1030,7 @@ int SQLiteSingleVerRelationalStorageExecutor::GetQueryDataAndStepNext(bool isFir } int SQLiteSingleVerRelationalStorageExecutor::GetMissQueryDataAndStepNext(sqlite3_stmt *fullStmt, DataItem &item, - TimeStamp &missQueryTime) + Timestamp &missQueryTime) { int errCode = GetMissQueryData(fullStmt, item); if (errCode != E_OK) { @@ -1053,8 +1053,8 @@ int SQLiteSingleVerRelationalStorageExecutor::GetSyncDataByQuery(std::vector &dataItems, - const std::string &deviceName, const TableInfo &table, TimeStamp &timeStamp); + const std::string &deviceName, const TableInfo &table, Timestamp ×tamp); int AnalysisRelationalSchema(const std::string &tableName, TableInfo &tableInfo); @@ -81,7 +81,7 @@ private: int ResetStatements(bool isNeedFinalize); }; - int PrepareForSyncDataByTime(TimeStamp begin, TimeStamp end, + int PrepareForSyncDataByTime(Timestamp begin, Timestamp end, sqlite3_stmt *&statement, bool getDeletedData) const; int GetDataItemForSync(sqlite3_stmt *statement, DataItem &dataItem, bool isGettingDeletedData) const; @@ -91,17 +91,17 @@ private: int CheckDataConflictDefeated(const DataItem &item, bool &isDefeated); int SaveSyncDataItem(const std::vector &fieldInfos, const std::string &deviceName, DataItem &item, - TimeStamp &maxTimestamp); + Timestamp &maxTimestamp); int SaveSyncDataItems(const QueryObject &object, std::vector &dataItems, - const std::string &deviceName, TimeStamp &timeStamp); + const std::string &deviceName, Timestamp ×tamp); int SaveSyncDataItem(const DataItem &dataItem, sqlite3_stmt *&saveDataStmt, sqlite3_stmt *&rmDataStmt, const std::vector &fieldInfos, int64_t &rowid); int DeleteSyncDataItem(const DataItem &dataItem, sqlite3_stmt *&rmDataStmt); int SaveSyncLog(sqlite3_stmt *statement, sqlite3_stmt *queryStmt, const DataItem &dataItem, - TimeStamp &maxTimestamp, int64_t rowid); + Timestamp &maxTimestamp, int64_t rowid); int PrepareForSavingData(const QueryObject &object, sqlite3_stmt *&statement) const; int PrepareForSavingLog(const QueryObject &object, const std::string &deviceName, sqlite3_stmt *&statement, sqlite3_stmt *&queryStmt) const; @@ -112,8 +112,8 @@ private: int ProcessMissQueryData(const DataItem &item, sqlite3_stmt *&rmDataStmt, sqlite3_stmt *&rmLogStmt); int GetMissQueryData(sqlite3_stmt *fullStmt, DataItem &item); int GetQueryDataAndStepNext(bool isFirstTime, bool isGettingDeletedData, sqlite3_stmt *queryStmt, DataItem &item, - TimeStamp &queryTime); - int GetMissQueryDataAndStepNext(sqlite3_stmt *fullStmt, DataItem &item, TimeStamp &missQueryTime); + Timestamp &queryTime); + int GetMissQueryDataAndStepNext(sqlite3_stmt *fullStmt, DataItem &item, Timestamp &missQueryTime); void SetTableInfo(const TableInfo &tableInfo); // When put or get sync data, must call the func first. std::string baseTblName_; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp index f999cdb5f..3c3e07592 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp @@ -165,10 +165,10 @@ int SQLiteSingleVerStorageEngine::MigrateSyncDataByVersion(SQLiteSingleVerStorag CommitNotifyForMigrateCache(syncData); - TimeStamp timestamp = 0; - errCode = handle->GetMaxTimeStampDuringMigrating(timestamp); + Timestamp timestamp = 0; + errCode = handle->GetMaxTimestampDuringMigrating(timestamp); if (errCode == E_OK) { - SetMaxTimeStamp(timestamp); + SetMaxTimestamp(timestamp); } errCode = ReleaseHandleTransiently(handle, 2ull); // temporary release handle 2ms @@ -523,7 +523,7 @@ void SQLiteSingleVerStorageEngine::EndMigrate(SQLiteSingleVerStorageExecutor *&h } // Notify max timestamp offset for SyncEngine. // When time change offset equals 0, SyncEngine can adjust local time offset according to max timestamp. - RuntimeContext::GetInstance()->NotifyTimeStampChanged(0); + RuntimeContext::GetInstance()->NotifyTimestampChanged(0); if (isNeedTriggerSync) { commitNotifyFunc_(SQLITE_GENERAL_FINISH_MIGRATE_EVENT, nullptr); } @@ -1064,7 +1064,7 @@ void SQLiteSingleVerStorageEngine::InitConflictNotifiedFlag(SingleVerNaturalStor committedData->SetConflictedNotifiedFlag(static_cast(conflictFlag)); } -void SQLiteSingleVerStorageEngine::SetMaxTimeStamp(TimeStamp maxTimeStamp) const +void SQLiteSingleVerStorageEngine::SetMaxTimestamp(Timestamp maxTimestamp) const { auto kvdbManager = KvDBManager::GetInstance(); if (kvdbManager == nullptr) { @@ -1073,12 +1073,12 @@ void SQLiteSingleVerStorageEngine::SetMaxTimeStamp(TimeStamp maxTimeStamp) const auto identifier = GetIdentifier(); auto kvdb = kvdbManager->FindKvDB(identifier); if (kvdb == nullptr) { - LOGE("[SQLiteSingleVerStorageEngine::SetMaxTimeStamp] kvdb is null."); + LOGE("[SQLiteSingleVerStorageEngine::SetMaxTimestamp] kvdb is null."); return; } auto kvStore = static_cast(kvdb); - kvStore->SetMaxTimeStamp(maxTimeStamp); + kvStore->SetMaxTimestamp(maxTimestamp); RefObject::DecObjRef(kvdb); return; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.h b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.h index 103f72e73..1418ae4bd 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.h @@ -85,7 +85,7 @@ private: void EndMigrate(SQLiteSingleVerStorageExecutor *&handle, EngineState stateBeforeMigrate, int errCode, bool isNeedTriggerSync); void ResetCacheRecordVersion(); - void SetMaxTimeStamp(TimeStamp maxTimeStamp) const; + void SetMaxTimestamp(Timestamp maxTimestamp) const; int EraseDeviceWaterMark(SQLiteSingleVerStorageExecutor *&handle, const std::vector &dataItems); // For db. diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp index 5744bc88c..5e9d96c4c 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp @@ -70,7 +70,7 @@ SQLiteSingleVerStorageExecutor::SQLiteSingleVerStorageExecutor(sqlite3 *dbHandle isTransactionOpen_(false), attachMetaMode_(false), executorState_(ExecutorState::INVALID), - maxTimeStampInMainDB_(0), + maxTimestampInMainDB_(0), migrateTimeOffset_(0), isSyncMigrating_(false), conflictResolvePolicy_(DEFAULT_LAST_WIN) @@ -85,7 +85,7 @@ SQLiteSingleVerStorageExecutor::SQLiteSingleVerStorageExecutor(sqlite3 *dbHandle isTransactionOpen_(false), attachMetaMode_(false), executorState_(executorState), - maxTimeStampInMainDB_(0), + maxTimestampInMainDB_(0), migrateTimeOffset_(0), isSyncMigrating_(false), conflictResolvePolicy_(DEFAULT_LAST_WIN) @@ -100,7 +100,7 @@ SQLiteSingleVerStorageExecutor::~SQLiteSingleVerStorageExecutor() } int SQLiteSingleVerStorageExecutor::GetKvData(SingleVerDataType type, const Key &key, Value &value, - TimeStamp &timeStamp) const + Timestamp ×tamp) const { std::string sql; if (type == SingleVerDataType::LOCAL_TYPE) { @@ -140,9 +140,9 @@ int SQLiteSingleVerStorageExecutor::GetKvData(SingleVerDataType type, const Key // get timestamp if (type == SingleVerDataType::LOCAL_TYPE) { - timeStamp = static_cast(sqlite3_column_int64(statement, GET_KV_RES_LOCAL_TIME_INDEX)); + timestamp = static_cast(sqlite3_column_int64(statement, GET_KV_RES_LOCAL_TIME_INDEX)); } else if (type == SingleVerDataType::SYNC_TYPE) { - timeStamp = static_cast(sqlite3_column_int64(statement, GET_KV_RES_SYNC_TIME_INDEX)); + timestamp = static_cast(sqlite3_column_int64(statement, GET_KV_RES_SYNC_TIME_INDEX)); } END: @@ -151,7 +151,7 @@ END: } int SQLiteSingleVerStorageExecutor::BindPutKvData(sqlite3_stmt *statement, const Key &key, const Value &value, - TimeStamp timestamp, SingleVerDataType type) + Timestamp timestamp, SingleVerDataType type) { int errCode = SQLiteUtils::BindBlobToStatement(statement, BIND_KV_KEY_INDEX, key, false); if (errCode != E_OK) { @@ -205,8 +205,8 @@ int SQLiteSingleVerStorageExecutor::GetKvDataByHashKey(const Key &hashKey, Singl errCode = SQLiteUtils::StepWithRetry(statement, isMemDb_); if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)) { result.hashKey = hashKey; - result.timeStamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_TIME_INDEX)); - result.writeTimeStamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_W_TIME_INDEX)); + result.timestamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_TIME_INDEX)); + result.writeTimestamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_W_TIME_INDEX)); result.flag = static_cast(sqlite3_column_int64(statement, SYNC_RES_FLAG_INDEX)); // get key errCode = SQLiteUtils::GetColumnBlobValue(statement, SYNC_RES_KEY_INDEX, result.key); @@ -241,7 +241,7 @@ END: } int SQLiteSingleVerStorageExecutor::SaveKvData(SingleVerDataType type, const Key &key, const Value &value, - TimeStamp timestamp) + Timestamp timestamp) { sqlite3_stmt *statement = nullptr; std::string sql; @@ -272,16 +272,16 @@ ERROR: } int SQLiteSingleVerStorageExecutor::PutKvData(SingleVerDataType type, const Key &key, const Value &value, - TimeStamp timestamp, SingleVerNaturalStoreCommitNotifyData *committedData) + Timestamp timestamp, SingleVerNaturalStoreCommitNotifyData *committedData) { if (type != SingleVerDataType::LOCAL_TYPE && type != SingleVerDataType::META_TYPE) { return -E_INVALID_ARGS; } // committedData is only for local data, not for meta data. bool isLocal = (SingleVerDataType::LOCAL_TYPE == type); - TimeStamp localTimeStamp = 0; + Timestamp localTimestamp = 0; Value readValue; - bool isExisted = CheckIfKeyExisted(key, isLocal, readValue, localTimeStamp); + bool isExisted = CheckIfKeyExisted(key, isLocal, readValue, localTimestamp); if (isLocal && committedData != nullptr) { ExistStatus existedStatus = isExisted ? ExistStatus::EXIST : ExistStatus::NONE; Key hashKey; @@ -400,7 +400,7 @@ END: return CheckCorruptedStatus(errCode); } -void SQLiteSingleVerStorageExecutor::InitCurrentMaxStamp(TimeStamp &maxStamp) +void SQLiteSingleVerStorageExecutor::InitCurrentMaxStamp(Timestamp &maxStamp) { if (dbHandle_ == nullptr) { return; @@ -420,7 +420,7 @@ void SQLiteSingleVerStorageExecutor::InitCurrentMaxStamp(TimeStamp &maxStamp) SQLiteUtils::ResetStatement(statement, true, errCode); } -int SQLiteSingleVerStorageExecutor::PrepareForSyncDataByTime(TimeStamp begin, TimeStamp end, +int SQLiteSingleVerStorageExecutor::PrepareForSyncDataByTime(Timestamp begin, Timestamp end, sqlite3_stmt *&statement, bool getDeletedData) const { if (dbHandle_ == nullptr) { @@ -464,8 +464,8 @@ void SQLiteSingleVerStorageExecutor::ReleaseContinueStatement() namespace { int GetDataItemForSync(sqlite3_stmt *statement, DataItem &dataItem) { - dataItem.timeStamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_TIME_INDEX)); - dataItem.writeTimeStamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_W_TIME_INDEX)); + dataItem.timestamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_TIME_INDEX)); + dataItem.writeTimestamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_W_TIME_INDEX)); dataItem.flag = static_cast(sqlite3_column_int64(statement, SYNC_RES_FLAG_INDEX)); dataItem.flag &= (~DataItem::LOCAL_FLAG); std::vector devVect; @@ -522,7 +522,7 @@ int SQLiteSingleVerStorageExecutor::GetSyncDataItems(std::vector &data } int SQLiteSingleVerStorageExecutor::GetSyncDataByTimestamp(std::vector &dataItems, size_t appendLength, - TimeStamp begin, TimeStamp end, const DataSizeSpecInfo &dataSizeInfo) const + Timestamp begin, Timestamp end, const DataSizeSpecInfo &dataSizeInfo) const { sqlite3_stmt *statement = nullptr; int errCode = PrepareForSyncDataByTime(begin, end, statement); @@ -536,7 +536,7 @@ int SQLiteSingleVerStorageExecutor::GetSyncDataByTimestamp(std::vector } int SQLiteSingleVerStorageExecutor::GetDeletedSyncDataByTimestamp(std::vector &dataItems, size_t appendLength, - TimeStamp begin, TimeStamp end, const DataSizeSpecInfo &dataSizeInfo) const + Timestamp begin, Timestamp end, const DataSizeSpecInfo &dataSizeInfo) const { sqlite3_stmt *statement = nullptr; int errCode = PrepareForSyncDataByTime(begin, end, statement, true); @@ -564,7 +564,7 @@ int AppendDataItem(std::vector &dataItems, const DataItem &item, size_ return E_OK; } -int GetFullDataStatement(sqlite3 *db, const std::pair &timeRange, sqlite3_stmt *&stmt) +int GetFullDataStatement(sqlite3 *db, const std::pair &timeRange, sqlite3_stmt *&stmt) { int errCode = SQLiteUtils::GetStatement(db, SELECT_SYNC_MODIFY_SQL, stmt); if (errCode != E_OK) { @@ -587,7 +587,7 @@ ERR: return errCode; } -int GetQueryDataStatement(sqlite3 *db, QueryObject query, const std::pair &timeRange, +int GetQueryDataStatement(sqlite3 *db, QueryObject query, const std::pair &timeRange, sqlite3_stmt *&stmt) { int errCode = E_OK; @@ -609,7 +609,7 @@ int GetNextDataItem(sqlite3_stmt *stmt, bool isMemDB, DataItem &item) } int SQLiteSingleVerStorageExecutor::GetSyncDataWithQuery(const QueryObject &query, size_t appendLength, - const DataSizeSpecInfo &dataSizeInfo, const std::pair &timeRange, + const DataSizeSpecInfo &dataSizeInfo, const std::pair &timeRange, std::vector &dataItems) const { sqlite3_stmt *fullStmt = nullptr; // statement for get all modified data in the time range @@ -1050,14 +1050,14 @@ int SQLiteSingleVerStorageExecutor::Rollback() } bool SQLiteSingleVerStorageExecutor::CheckIfKeyExisted(const Key &key, bool isLocal, - Value &value, TimeStamp &timeStamp) const + Value &value, Timestamp ×tamp) const { // not local value, no need to get the value. if (!isLocal) { return false; } - int errCode = GetKvData(SingleVerDataType::LOCAL_TYPE, key, value, timeStamp); + int errCode = GetKvData(SingleVerDataType::LOCAL_TYPE, key, value, timestamp); if (errCode != E_OK) { return false; } @@ -1225,14 +1225,14 @@ DataOperStatus SQLiteSingleVerStorageExecutor::JudgeSyncSaveType(DataItem &dataI status.preStatus = DataStatus::EXISTED; } std::string deviceName = DBCommon::TransferHashString(devName); - if (itemGet.writeTimeStamp >= dataItem.writeTimeStamp) { + if (itemGet.writeTimestamp >= dataItem.writeTimestamp) { // for multi user mode, no permit to forcewrite if ((!deviceName.empty()) && (itemGet.dev == deviceName) && isPermitForceWrite) { LOGI("Force overwrite the data:%" PRIu64 " vs %" PRIu64, - itemGet.writeTimeStamp, dataItem.writeTimeStamp); + itemGet.writeTimestamp, dataItem.writeTimestamp); status.isDefeated = false; - dataItem.writeTimeStamp = itemGet.writeTimeStamp + 1; - dataItem.timeStamp = itemGet.timeStamp; + dataItem.writeTimestamp = itemGet.writeTimestamp + 1; + dataItem.timestamp = itemGet.timestamp; } else { status.isDefeated = true; } @@ -1337,7 +1337,7 @@ int SQLiteSingleVerStorageExecutor::PrepareForNotifyConflictAndObserver(DataItem } int SQLiteSingleVerStorageExecutor::SaveSyncDataItem(DataItem &dataItem, const DeviceInfo &deviceInfo, - TimeStamp &maxStamp, SingleVerNaturalStoreCommitNotifyData *committedData, bool isPermitForceWrite) + Timestamp &maxStamp, SingleVerNaturalStoreCommitNotifyData *committedData, bool isPermitForceWrite) { NotifyConflictAndObserverData notify = { .committedData = committedData @@ -1362,7 +1362,7 @@ int SQLiteSingleVerStorageExecutor::SaveSyncDataItem(DataItem &dataItem, const D errCode = SaveSyncDataToDatabase(dataItem, notify.hashKey, origDev, deviceInfo.deviceName, isUpdate); if (errCode == E_OK) { PutIntoCommittedData(dataItem, notify.getData, notify.dataStatus, notify.hashKey, committedData); - maxStamp = std::max(dataItem.timeStamp, maxStamp); + maxStamp = std::max(dataItem.timestamp, maxStamp); } else { LOGE("Save sync data to db failed:%d", errCode); } @@ -1499,16 +1499,16 @@ int SQLiteSingleVerStorageExecutor::BindSavedSyncData(sqlite3_stmt *statement, c return errCode; } - errCode = SQLiteUtils::BindInt64ToStatement(statement, BIND_SYNC_STAMP_INDEX, dataItem.timeStamp); + errCode = SQLiteUtils::BindInt64ToStatement(statement, BIND_SYNC_STAMP_INDEX, dataItem.timestamp); if (errCode != E_OK) { LOGE("Bind saved sync data stamp failed:%d", errCode); return errCode; } const int writeTimeIndex = isUpdate ? BIND_SYNC_UPDATE_W_TIME_INDEX : BIND_SYNC_W_TIME_INDEX; - errCode = SQLiteUtils::BindInt64ToStatement(statement, writeTimeIndex, dataItem.writeTimeStamp); + errCode = SQLiteUtils::BindInt64ToStatement(statement, writeTimeIndex, dataItem.writeTimestamp); LOGD("Write timestamp:%" PRIu64 " timestamp:%" PRIu64 ", %" PRIu64, - dataItem.writeTimeStamp, dataItem.timeStamp, dataItem.flag); + dataItem.writeTimestamp, dataItem.timestamp, dataItem.flag); if (errCode != E_OK) { LOGE("Bind saved sync data write stamp failed:%d", errCode); return errCode; @@ -1606,8 +1606,8 @@ int SQLiteSingleVerStorageExecutor::GetSyncDataPreByHashKey(const Key &hashKey, if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_DONE)) { // no find the key errCode = -E_NOT_FOUND; } else if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)) { - itemGet.timeStamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_TIME_INDEX)); - itemGet.writeTimeStamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_W_TIME_INDEX)); + itemGet.timestamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_TIME_INDEX)); + itemGet.writeTimestamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_W_TIME_INDEX)); itemGet.flag = static_cast(sqlite3_column_int64(statement, SYNC_RES_FLAG_INDEX)); errCode = SQLiteUtils::GetColumnBlobValue(statement, SYNC_RES_KEY_INDEX, itemGet.key); if (errCode != E_OK) { @@ -1677,9 +1677,9 @@ ERROR: } int SQLiteSingleVerStorageExecutor::DeleteLocalKvData(const Key &key, - SingleVerNaturalStoreCommitNotifyData *committedData, Value &value, TimeStamp &timeStamp) + SingleVerNaturalStoreCommitNotifyData *committedData, Value &value, Timestamp ×tamp) { - int errCode = GetKvData(SingleVerDataType::LOCAL_TYPE, key, value, timeStamp); + int errCode = GetKvData(SingleVerDataType::LOCAL_TYPE, key, value, timestamp); if (errCode != E_OK) { return CheckCorruptedStatus(errCode); } @@ -1935,7 +1935,7 @@ int SQLiteSingleVerStorageExecutor::InitResultSet(QueryObject &queryObj, sqlite3 return CheckCorruptedStatus(errCode); } -int SQLiteSingleVerStorageExecutor::UpdateLocalDataTimestamp(TimeStamp timestamp) +int SQLiteSingleVerStorageExecutor::UpdateLocalDataTimestamp(Timestamp timestamp) { const std::string updateSql = "UPDATE local_data SET timestamp="; std::string sql = updateSql + std::to_string(timestamp) + " WHERE timestamp=0;"; @@ -1961,7 +1961,7 @@ int SQLiteSingleVerStorageExecutor::GetOneRawDataItem(sqlite3_stmt *statement, D return errCode; } - dataItem.timeStamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_TIME_INDEX)); + dataItem.timestamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_TIME_INDEX)); dataItem.flag = static_cast(sqlite3_column_int64(statement, SYNC_RES_FLAG_INDEX)); std::vector devVect; @@ -1982,7 +1982,7 @@ int SQLiteSingleVerStorageExecutor::GetOneRawDataItem(sqlite3_stmt *statement, D if (errCode != E_OK) { return errCode; } - dataItem.writeTimeStamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_W_TIME_INDEX)); + dataItem.writeTimestamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_W_TIME_INDEX)); if (errCode != E_OK) { return errCode; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.h b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.h index 2022713f4..ddc9154c1 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.h @@ -53,12 +53,12 @@ struct DataOperStatus { struct SingleVerRecord { Key key; Value value; - TimeStamp timeStamp = 0; + Timestamp timestamp = 0; uint64_t flag = 0; std::string device; std::string origDevice; Key hashKey; - TimeStamp writeTimeStamp = 0; + Timestamp writeTimestamp = 0; }; struct DeviceInfo { @@ -69,7 +69,7 @@ struct DeviceInfo { struct LocalDataItem { Key key; Value value; - TimeStamp timeStamp = 0; + Timestamp timestamp = 0; Key hashKey; uint64_t flag = 0; }; @@ -104,14 +104,14 @@ public: DISABLE_COPY_ASSIGN_MOVE(SQLiteSingleVerStorageExecutor); // Get the Kv data according the type(sync, meta, local data). - int GetKvData(SingleVerDataType type, const Key &key, Value &value, TimeStamp &timeStamp) const; + int GetKvData(SingleVerDataType type, const Key &key, Value &value, Timestamp ×tamp) const; // Get the sync data record by hash key. int GetKvDataByHashKey(const Key &hashKey, SingleVerRecord &result) const; // Put the Kv data according the type(meta and the local data). int PutKvData(SingleVerDataType type, const Key &key, const Value &value, - TimeStamp timestamp, SingleVerNaturalStoreCommitNotifyData *committedData); + Timestamp timestamp, SingleVerNaturalStoreCommitNotifyData *committedData); int GetEntries(SingleVerDataType type, const Key &keyPrefix, std::vector &entries) const; @@ -125,10 +125,10 @@ public: int GetAllSyncedEntries(const std::string &deviceName, std::vector &entries) const; int SaveSyncDataItem(DataItem &dataItem, const DeviceInfo &deviceInfo, - TimeStamp &maxStamp, SingleVerNaturalStoreCommitNotifyData *committedData, bool isPermitForceWrite = true); + Timestamp &maxStamp, SingleVerNaturalStoreCommitNotifyData *committedData, bool isPermitForceWrite = true); int DeleteLocalKvData(const Key &key, SingleVerNaturalStoreCommitNotifyData *committedData, Value &value, - TimeStamp &timeStamp); + Timestamp ×tamp); // delete a row data by hashKey, with no tombstone left. int EraseSyncData(const Key &hashKey); @@ -137,14 +137,14 @@ public: int RemoveDeviceDataInCacheMode(const std::string &deviceName, bool isNeedNotify, uint64_t recordVersion) const; - void InitCurrentMaxStamp(TimeStamp &maxStamp); + void InitCurrentMaxStamp(Timestamp &maxStamp); void ReleaseContinueStatement(); - int GetSyncDataByTimestamp(std::vector &dataItems, size_t appendedLength, TimeStamp begin, - TimeStamp end, const DataSizeSpecInfo &dataSizeInfo) const; - int GetDeletedSyncDataByTimestamp(std::vector &dataItems, size_t appendedLength, TimeStamp begin, - TimeStamp end, const DataSizeSpecInfo &dataSizeInfo) const; + int GetSyncDataByTimestamp(std::vector &dataItems, size_t appendedLength, Timestamp begin, + Timestamp end, const DataSizeSpecInfo &dataSizeInfo) const; + int GetDeletedSyncDataByTimestamp(std::vector &dataItems, size_t appendedLength, Timestamp begin, + Timestamp end, const DataSizeSpecInfo &dataSizeInfo) const; int GetDeviceIdentifier(PragmaEntryDeviceIdentifier *identifier); @@ -180,7 +180,7 @@ public: int Rollback(); - bool CheckIfKeyExisted(const Key &key, bool isLocal, Value &value, TimeStamp &timeStamp) const; + bool CheckIfKeyExisted(const Key &key, bool isLocal, Value &value, Timestamp ×tamp) const; int PrepareForSavingData(SingleVerDataType type); @@ -188,13 +188,13 @@ public: int Reset() override; - int UpdateLocalDataTimestamp(TimeStamp timestamp); + int UpdateLocalDataTimestamp(Timestamp timestamp); void SetAttachMetaMode(bool attachMetaMode); int PutLocalDataToCacheDB(const LocalDataItem &dataItem) const; - int SaveSyncDataItemInCacheMode(DataItem &dataItem, const DeviceInfo &deviceInfo, TimeStamp &maxStamp, + int SaveSyncDataItemInCacheMode(DataItem &dataItem, const DeviceInfo &deviceInfo, Timestamp &maxStamp, uint64_t recordVersion, const QueryObject &query); int PrepareForSavingCacheData(SingleVerDataType type); @@ -214,7 +214,7 @@ public: void ClearMigrateData(); // Get current max timestamp. - int GetMaxTimeStampDuringMigrating(TimeStamp &maxTimeStamp) const; + int GetMaxTimestampDuringMigrating(Timestamp &maxTimestamp) const; void SetConflictResolvePolicy(int policy); @@ -242,7 +242,7 @@ public: int RemoveTrigger(const std::vector &triggers); int GetSyncDataWithQuery(const QueryObject &query, size_t appendLength, const DataSizeSpecInfo &dataSizeInfo, - const std::pair &timeRange, std::vector &dataItems) const; + const std::pair &timeRange, std::vector &dataItems) const; int ForceCheckPoint() const; @@ -285,7 +285,7 @@ private: int GetSyncDataPreByHashKey(const Key &hashKey, DataItem &itemGet) const; - int PrepareForSyncDataByTime(TimeStamp begin, TimeStamp end, sqlite3_stmt *&statement, bool getDeletedData = false) + int PrepareForSyncDataByTime(Timestamp begin, Timestamp end, sqlite3_stmt *&statement, bool getDeletedData = false) const; int StepForResultEntries(sqlite3_stmt *statement, std::vector &entries) const; @@ -302,13 +302,13 @@ private: int GetAllEntries(sqlite3_stmt *statement, std::vector &entries) const; - int BindPutKvData(sqlite3_stmt *statement, const Key &key, const Value &value, TimeStamp timestamp, + int BindPutKvData(sqlite3_stmt *statement, const Key &key, const Value &value, Timestamp timestamp, SingleVerDataType type); int SaveSyncDataToDatabase(const DataItem &dataItem, const Key &hashKey, const std::string &origDev, const std::string &deviceName, bool isUpdate); - int SaveKvData(SingleVerDataType type, const Key &key, const Value &value, TimeStamp timestamp); + int SaveKvData(SingleVerDataType type, const Key &key, const Value &value, Timestamp timestamp); int DeleteLocalDataInner(SingleVerNaturalStoreCommitNotifyData *committedData, const Key &key, const Value &value); @@ -330,7 +330,7 @@ private: int BindPrimaryKeySyncDataInCacheMode( sqlite3_stmt *statement, const Key &hashKey, uint64_t recordVersion) const; - int BindTimeStampSyncDataInCacheMode(sqlite3_stmt *statement, const DataItem &dataItem) const; + int BindTimestampSyncDataInCacheMode(sqlite3_stmt *statement, const DataItem &dataItem) const; int BindDevSyncDataInCacheMode(sqlite3_stmt *statement, const std::string &origDev, const std::string &deviceName) const; @@ -347,13 +347,13 @@ private: int BindLocalDataInCacheMode(sqlite3_stmt *statement, const LocalDataItem &dataItem) const; // Process timestamp for syncdata in cacheDB when migrating. - int ProcessTimeStampForSyncDataInCacheDB(std::vector &dataItems); + int ProcessTimestampForSyncDataInCacheDB(std::vector &dataItems); // Get migrateTimeOffset_. - int InitMigrateTimeStampOffset(); + int InitMigrateTimestampOffset(); // Get min timestamp of local data in sync_data, cacheDB. - int GetMinTimestampInCacheDB(TimeStamp &minStamp) const; + int GetMinTimestampInCacheDB(Timestamp &minStamp) const; // Prepare conflict notify and commit notify data. int PrepareForNotifyConflictAndObserver(DataItem &dataItem, const DeviceInfo &deviceInfo, @@ -406,13 +406,13 @@ private: ExecutorState executorState_; // Max timestamp in mainDB. Used for migrating. - TimeStamp maxTimeStampInMainDB_; + Timestamp maxTimestampInMainDB_; // The offset between min timestamp in cacheDB and max timestamp in mainDB. Used for migrating. TimeOffset migrateTimeOffset_; // Migrating sync flag. When the flag is true, mainDB and cacheDB are attached, migrateSyncStatements_ is set, - // maxTimeStampInMainDB_ and migrateTimeOffset_ is meaningful. + // maxTimestampInMainDB_ and migrateTimeOffset_ is meaningful. bool isSyncMigrating_; int conflictResolvePolicy_; }; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp index 41dce8384..2ace92b4c 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp @@ -400,7 +400,7 @@ int SQLiteSingleVerStorageExecutor::MigrateSyncDataByVersion(uint64_t recordVer, } // fix dataItem timestamp for migrate - errCode = ProcessTimeStampForSyncDataInCacheDB(dataItems); + errCode = ProcessTimestampForSyncDataInCacheDB(dataItems); if (errCode != E_OK) { LOGE("Chang the time stamp for migrate failed! errCode = [%d]", errCode); goto END; @@ -533,14 +533,14 @@ int SQLiteSingleVerStorageExecutor::BindSyncDataInCacheMode(sqlite3_stmt *statem } LOGD("Write timestamp:%" PRIu64 " timestamp:%" PRIu64 ", flag:%" PRIu64 ", version:%" PRIu64, - dataItem.writeTimeStamp, dataItem.timeStamp, dataItem.flag, recordVersion); + dataItem.writeTimestamp, dataItem.timestamp, dataItem.flag, recordVersion); errCode = SQLiteUtils::BindInt64ToStatement(statement, BIND_CACHE_SYNC_FLAG_INDEX, static_cast(dataItem.flag)); if (errCode != E_OK) { LOGE("Bind saved sync data flag failed:%d", errCode); return errCode; } - errCode = BindTimeStampSyncDataInCacheMode(statement, dataItem); + errCode = BindTimestampSyncDataInCacheMode(statement, dataItem); if (errCode != E_OK) { LOGE("Bind saved sync data time stamp failed:%d", errCode); return errCode; @@ -563,16 +563,16 @@ int SQLiteSingleVerStorageExecutor::BindPrimaryKeySyncDataInCacheMode( return errCode; } -int SQLiteSingleVerStorageExecutor::BindTimeStampSyncDataInCacheMode( +int SQLiteSingleVerStorageExecutor::BindTimestampSyncDataInCacheMode( sqlite3_stmt *statement, const DataItem &dataItem) const { - int errCode = SQLiteUtils::BindInt64ToStatement(statement, BIND_CACHE_SYNC_STAMP_INDEX, dataItem.timeStamp); + int errCode = SQLiteUtils::BindInt64ToStatement(statement, BIND_CACHE_SYNC_STAMP_INDEX, dataItem.timestamp); if (errCode != E_OK) { LOGE("Bind saved sync data stamp failed:%d", errCode); return errCode; } - errCode = SQLiteUtils::BindInt64ToStatement(statement, BIND_CACHE_SYNC_W_TIME_INDEX, dataItem.writeTimeStamp); + errCode = SQLiteUtils::BindInt64ToStatement(statement, BIND_CACHE_SYNC_W_TIME_INDEX, dataItem.writeTimestamp); if (errCode != E_OK) { LOGE("Bind saved sync data write stamp failed:%d", errCode); } @@ -633,7 +633,7 @@ END: } int SQLiteSingleVerStorageExecutor::SaveSyncDataItemInCacheMode(DataItem &dataItem, const DeviceInfo &deviceInfo, - TimeStamp &maxStamp, uint64_t recordVersion, const QueryObject &query) + Timestamp &maxStamp, uint64_t recordVersion, const QueryObject &query) { Key hashKey; int errCode = E_OK; @@ -662,7 +662,7 @@ int SQLiteSingleVerStorageExecutor::SaveSyncDataItemInCacheMode(DataItem &dataIt dataItem.origDev = origDev; errCode = SaveSyncDataToCacheDatabase(dataItem, hashKey, recordVersion); if (errCode == E_OK) { - maxStamp = std::max(dataItem.timeStamp, maxStamp); + maxStamp = std::max(dataItem.timestamp, maxStamp); } else { LOGE("Save sync data to db failed:%d", errCode); } @@ -739,7 +739,7 @@ int SQLiteSingleVerStorageExecutor::BindLocalDataInCacheMode(sqlite3_stmt *state return errCode; } - errCode = SQLiteUtils::BindInt64ToStatement(statement, BIND_CACHE_LOCAL_TIMESTAMP_INDEX, dataItem.timeStamp); + errCode = SQLiteUtils::BindInt64ToStatement(statement, BIND_CACHE_LOCAL_TIMESTAMP_INDEX, dataItem.timestamp); if (errCode != E_OK) { LOGE("[SingleVerExe][BindLocalData]Bind timestamp error:%d", errCode); return errCode; @@ -783,7 +783,7 @@ int SQLiteSingleVerStorageExecutor::PutIntoConflictAndCommitForMigrateCache(Data return ResetForMigrateCacheData(); } -int SQLiteSingleVerStorageExecutor::GetMinTimestampInCacheDB(TimeStamp &minStamp) const +int SQLiteSingleVerStorageExecutor::GetMinTimestampInCacheDB(Timestamp &minStamp) const { if (dbHandle_ == nullptr) { return E_OK; @@ -811,7 +811,7 @@ ERROR: return errCode; } -int SQLiteSingleVerStorageExecutor::InitMigrateTimeStampOffset() +int SQLiteSingleVerStorageExecutor::InitMigrateTimestampOffset() { // Not first migrate, migrateTimeOffset_ has been set. if (migrateTimeOffset_ != 0) { @@ -819,7 +819,7 @@ int SQLiteSingleVerStorageExecutor::InitMigrateTimeStampOffset() } // Get min timestamp of local data in sync_data, cacheDB. - TimeStamp minTimeInCache = 0; + Timestamp minTimeInCache = 0; int errCode = GetMinTimestampInCacheDB(minTimeInCache); if (errCode != E_OK) { return errCode; @@ -833,7 +833,7 @@ int SQLiteSingleVerStorageExecutor::InitMigrateTimeStampOffset() } // Get max timestamp in mainDB. - TimeStamp maxTimeInMain = 0; + Timestamp maxTimeInMain = 0; InitCurrentMaxStamp(maxTimeInMain); // Get timestamp offset between mainDB and cacheDB. @@ -845,28 +845,28 @@ int SQLiteSingleVerStorageExecutor::InitMigrateTimeStampOffset() return E_OK; } -int SQLiteSingleVerStorageExecutor::ProcessTimeStampForSyncDataInCacheDB(std::vector &dataItems) +int SQLiteSingleVerStorageExecutor::ProcessTimestampForSyncDataInCacheDB(std::vector &dataItems) { if (dataItems.empty()) { - LOGE("[SQLiteSingleVerStorageExecutor::ProcessTimeStampForCacheDB] Invalid parameter : dataItems."); + LOGE("[SQLiteSingleVerStorageExecutor::ProcessTimestampForCacheDB] Invalid parameter : dataItems."); return -E_INVALID_ARGS; } // Get the offset between the min timestamp in dataitems and max timestamp in mainDB. - int errCode = InitMigrateTimeStampOffset(); + int errCode = InitMigrateTimestampOffset(); if (errCode != E_OK) { return errCode; } // Set real timestamp for DataItem in dataItems and get the max timestamp in these dataitems. - TimeStamp maxTimeInDataItems = 0; + Timestamp maxTimeInDataItems = 0; for (auto &item : dataItems) { - item.timeStamp -= migrateTimeOffset_; - maxTimeInDataItems = std::max(maxTimeInDataItems, item.timeStamp); + item.timestamp -= migrateTimeOffset_; + maxTimeInDataItems = std::max(maxTimeInDataItems, item.timestamp); } // Update max timestamp in mainDB. - maxTimeStampInMainDB_ = maxTimeInDataItems; + maxTimestampInMainDB_ = maxTimeInDataItems; return E_OK; } @@ -923,7 +923,7 @@ void SQLiteSingleVerStorageExecutor::ClearMigrateData() { // Reset data. migrateTimeOffset_ = 0; - maxTimeStampInMainDB_ = 0; + maxTimestampInMainDB_ = 0; // Reset statement. int errCode = migrateSyncStatements_.ResetStatement(); @@ -934,12 +934,12 @@ void SQLiteSingleVerStorageExecutor::ClearMigrateData() isSyncMigrating_ = false; } -int SQLiteSingleVerStorageExecutor::GetMaxTimeStampDuringMigrating(TimeStamp &maxTimeStamp) const +int SQLiteSingleVerStorageExecutor::GetMaxTimestampDuringMigrating(Timestamp &maxTimestamp) const { - if (maxTimeStampInMainDB_ == 0) { + if (maxTimestampInMainDB_ == 0) { return -E_NOT_INIT; } - maxTimeStamp = maxTimeStampInMainDB_; + maxTimestamp = maxTimestampInMainDB_; return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp index e7217e167..3ab1bd85d 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp @@ -54,12 +54,12 @@ int SQLiteSingleVerStorageExecutor::CheckMissQueryDataItem(sqlite3_stmt *stmt, c LOGE("Get data device info failed. %d", errCode); return errCode; } - auto timeStamp = static_cast(sqlite3_column_int64(stmt, SYNC_RES_TIME_INDEX)); + auto timestamp = static_cast(sqlite3_column_int64(stmt, SYNC_RES_TIME_INDEX)); std::string device = std::string(dev.begin(), dev.end()); // this data item should be neglected when it's out of date of it's from same device // otherwise, it should be erased after resolved the conflict - item.neglect = (timeStamp > item.timeStamp) || - (timeStamp == item.timeStamp && device == DBCommon::TransferHashString(deviceName)); + item.neglect = (timestamp > item.timestamp) || + (timestamp == item.timestamp && device == DBCommon::TransferHashString(deviceName)); return E_OK; } else if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_DONE)) { // the value with same hashKey in DB does not match the query, this data item should be neglected. diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_engine.cpp index 55d346353..5c328dca7 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_engine.cpp @@ -78,12 +78,12 @@ void SyncAbleEngine::StopSync(int syncId) } // Get The current virtual timestamp -uint64_t SyncAbleEngine::GetTimeStamp() +uint64_t SyncAbleEngine::GetTimestamp() { if (!started_) { StartSyncer(); } - return syncer_.GetTimeStamp(); + return syncer_.GetTimestamp(); } int SyncAbleEngine::EraseDeviceWaterMark(const std::string &deviceId, bool isNeedHash, const std::string &tableName) diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_engine.h b/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_engine.h index e43d5194b..87afcc74c 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_engine.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_engine.h @@ -44,7 +44,7 @@ public: void StopSync(int syncId); // Get The current virtual timestamp - uint64_t GetTimeStamp(); + uint64_t GetTimestamp(); int EraseDeviceWaterMark(const std::string &deviceId, bool isNeedHash, const std::string &tableName = ""); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_kvdb.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_kvdb.cpp index f833394ec..c2c328675 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_kvdb.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_kvdb.cpp @@ -252,12 +252,12 @@ void SyncAbleKvDB::ChangeUserListerner() } // Get The current virtual timestamp -uint64_t SyncAbleKvDB::GetTimeStamp() +uint64_t SyncAbleKvDB::GetTimestamp() { if (!started_ && !isSyncModuleActiveCheck_) { StartSyncer(); } - return syncer_.GetTimeStamp(); + return syncer_.GetTimestamp(); } // Get the dataItem's append length diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_kvdb.h b/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_kvdb.h index 06912bafe..df6f2602a 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_kvdb.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sync_able_kvdb.h @@ -50,7 +50,7 @@ public: void StopSync(); // Get The current virtual timestamp - uint64_t GetTimeStamp(); + uint64_t GetTimestamp(); void WakeUpSyncer() override; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/include/isyncer.h b/services/distributeddataservice/libs/distributeddb/syncer/include/isyncer.h index 131f43f5b..3fbc70fac 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/include/isyncer.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/include/isyncer.h @@ -70,7 +70,7 @@ public: virtual int StopSync() = 0; // Get The current virtual timestamp - virtual uint64_t GetTimeStamp() = 0; + virtual uint64_t GetTimestamp() = 0; // Enable auto sync function virtual void EnableAutoSync(bool enable) = 0; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/include/syncer_proxy.h b/services/distributeddataservice/libs/distributeddb/syncer/include/syncer_proxy.h index caf30d763..8a1c8c279 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/include/syncer_proxy.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/include/syncer_proxy.h @@ -54,7 +54,7 @@ public: int StopSync() override; // Get The current virtual timestamp - uint64_t GetTimeStamp() override; + uint64_t GetTimestamp() override; // Enable auto sync function void EnableAutoSync(bool enable) override; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp index f50b713f0..71000def9 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp @@ -891,9 +891,9 @@ int AbilitySync::SetAbilityRequestBodyInfo(AbilitySyncRequestPacket &packet, uin { uint64_t dbCreateTime; int errCode = - (static_cast(storageInterface_))->GetDatabaseCreateTimeStamp(dbCreateTime); + (static_cast(storageInterface_))->GetDatabaseCreateTimestamp(dbCreateTime); if (errCode != E_OK) { - LOGE("[AbilitySync][FillAbilityRequest] GetDatabaseCreateTimeStamp failed, err %d", errCode); + LOGE("[AbilitySync][FillAbilityRequest] GetDatabaseCreateTimestamp failed, err %d", errCode); return errCode; } SecurityOption option; @@ -947,9 +947,9 @@ int AbilitySync::SetAbilityAckBodyInfo(AbilitySyncAckPacket &ackPacket, int ackC ackPacket.SetSecFlag(option.securityFlag); uint64_t dbCreateTime = 0; errCode = - (static_cast(storageInterface_))->GetDatabaseCreateTimeStamp(dbCreateTime); + (static_cast(storageInterface_))->GetDatabaseCreateTimestamp(dbCreateTime); if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] GetDatabaseCreateTimeStamp failed, err %d", errCode); + LOGE("[AbilitySync][SyncStart] GetDatabaseCreateTimestamp failed, err %d", errCode); ackCode = errCode; } DbAbility dbAbility; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp index b91f2549f..83dd6c1cc 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp @@ -96,7 +96,7 @@ int GenericSyncer::Initialize(ISyncInterface *syncInterface, bool isNeedActive) // It will be clear in destructor. int errCodeMetadata = InitMetaData(syncInterface); - // As timeHelper_ will be used in GetTimeStamp, it should not be clear even if engine init failed. + // As timeHelper_ will be used in GetTimestamp, it should not be clear even if engine init failed. // It will be clear in destructor. int errCodeTimeHelper = InitTimeHelper(syncInterface); if (errCodeMetadata != E_OK || errCodeTimeHelper != E_OK) { @@ -272,7 +272,7 @@ int GenericSyncer::StopSync() return E_OK; } -uint64_t GenericSyncer::GetTimeStamp() +uint64_t GenericSyncer::GetTimestamp() { if (timeHelper_ == nullptr) { return TimeHelper::GetSysCurrentTime(); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.h b/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.h index b56d2d275..e675d4d9e 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.h @@ -59,7 +59,7 @@ public: int StopSync() override; // Get The current virtual timestamp - uint64_t GetTimeStamp() override; + uint64_t GetTimestamp() override; // Get manual sync queue size int GetQueuedSyncSize(int *queuedSyncSize) const override; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/isync_task_context.h b/services/distributeddataservice/libs/distributeddb/syncer/src/isync_task_context.h index 7577cce3d..804b6fc4e 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/isync_task_context.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/isync_task_context.h @@ -138,7 +138,7 @@ public: virtual void SafeExit() = 0; // Get current localtime from TimeHelper - virtual TimeStamp GetCurrentLocalTime() const = 0; + virtual Timestamp GetCurrentLocalTime() const = 0; // Set the remount software version num virtual void SetRemoteSoftwareVersion(uint32_t version) = 0; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp index ed1060c76..75ed7cdfc 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp @@ -181,7 +181,7 @@ int Metadata::EraseDeviceWaterMark(const std::string &deviceId, bool isNeedHash, return E_OK; } -void Metadata::SetLastLocalTime(TimeStamp lastLocalTime) +void Metadata::SetLastLocalTime(Timestamp lastLocalTime) { std::lock_guard lock(lastLocalTimeLock_); if (lastLocalTime > lastLocalTime_) { @@ -189,7 +189,7 @@ void Metadata::SetLastLocalTime(TimeStamp lastLocalTime) } } -TimeStamp Metadata::GetLastLocalTime() const +Timestamp Metadata::GetLastLocalTime() const { std::lock_guard lock(lastLocalTimeLock_); return lastLocalTime_; @@ -427,21 +427,21 @@ int Metadata::SetSendQueryWaterMark(const std::string &queryIdentify, return querySyncWaterMarkHelper_.SetSendQueryWaterMark(queryIdentify, deviceId, waterMark); } -int Metadata::GetLastQueryTime(const std::string &queryIdentify, const std::string &deviceId, TimeStamp &timeStamp) +int Metadata::GetLastQueryTime(const std::string &queryIdentify, const std::string &deviceId, Timestamp ×tamp) { QueryWaterMark queryWaterMark; int errCode = querySyncWaterMarkHelper_.GetQueryWaterMark(queryIdentify, deviceId, queryWaterMark); if (errCode != E_OK) { return errCode; } - timeStamp = queryWaterMark.lastQueryTime; + timestamp = queryWaterMark.lastQueryTime; return E_OK; } int Metadata::SetLastQueryTime(const std::string &queryIdentify, const std::string &deviceId, - const TimeStamp &timeStamp) + const Timestamp ×tamp) { - return querySyncWaterMarkHelper_.SetLastQueryTime(queryIdentify, deviceId, timeStamp); + return querySyncWaterMarkHelper_.SetLastQueryTime(queryIdentify, deviceId, timestamp); } int Metadata::GetSendDeleteSyncWaterMark(const DeviceID &deviceId, WaterMark &waterMark, bool isAutoLift) diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.h b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.h index 16d7cbb20..7b2a0051a 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.h @@ -31,7 +31,7 @@ struct MetaDataValue { uint64_t lastUpdateTime = 0; uint64_t localWaterMark = 0; uint64_t peerWaterMark = 0; - TimeStamp dbCreateTime = 0; + Timestamp dbCreateTime = 0; uint64_t clearDeviceDataMark = 0; // Default 0 for not remove device data. }; @@ -62,9 +62,9 @@ public: int EraseDeviceWaterMark(const std::string &deviceId, bool isNeedHash, const std::string &tableName); - void SetLastLocalTime(TimeStamp lastLocalTime); + void SetLastLocalTime(Timestamp lastLocalTime); - TimeStamp GetLastLocalTime() const; + Timestamp GetLastLocalTime() const; int SetSendQueryWaterMark(const std::string &queryIdentify, const std::string &deviceId, const WaterMark &waterMark); @@ -83,9 +83,9 @@ public: const std::string &deviceId, WaterMark &waterMark); virtual int SetLastQueryTime(const std::string &queryIdentify, const std::string &deviceId, - const TimeStamp &timeStamp); + const Timestamp ×tamp); - virtual int GetLastQueryTime(const std::string &queryIdentify, const std::string &deviceId, TimeStamp &timeStamp); + virtual int GetLastQueryTime(const std::string &queryIdentify, const std::string &deviceId, Timestamp ×tamp); int SetSendDeleteSyncWaterMark(const std::string &deviceId, const WaterMark &waterMark); @@ -164,7 +164,7 @@ private: // store localTimeOffset in ram, used to make timestamp increase mutable std::mutex lastLocalTimeLock_; - TimeStamp lastLocalTime_; + Timestamp lastLocalTime_; QuerySyncWaterMarkHelper querySyncWaterMarkHelper_; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp index 1a9c5a9a5..c63868a76 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp @@ -29,16 +29,16 @@ namespace DistributedDB { namespace { -void ChangeEntriesTimeStamp(std::vector &entries, TimeOffset outOffset, TimeOffset timefixOffset) +void ChangeEntriesTimestamp(std::vector &entries, TimeOffset outOffset, TimeOffset timefixOffset) { for (MultiVerKvEntry *entry : entries) { if (entry == nullptr) { continue; } - TimeStamp timeStamp; - entry->GetTimestamp(timeStamp); - timeStamp = timeStamp - static_cast(outOffset + timefixOffset); - entry->SetTimestamp(timeStamp); + Timestamp timestamp; + entry->GetTimestamp(timestamp); + timestamp = timestamp - static_cast(outOffset + timefixOffset); + entry->SetTimestamp(timestamp); } } } @@ -469,16 +469,16 @@ int MultiVerSyncStateMachine::OneCommitSyncFinish() LOGI("MultiVerSyncStateMachine::OneCommitSyncFinish GetTimeOffset fail errCode:%d", errCode); return errCode; } - TimeStamp currentLocalTime = context_->GetCurrentLocalTime(); - commit.timestamp -= static_cast(outOffset); + Timestamp currentLocalTime = context_->GetCurrentLocalTime(); + commit.timestamp -= static_cast(outOffset); // Due to time sync error, commit timestamp may bigger than currentLocalTime, we need to fix the timestamp TimeOffset timefixOffset = (commit.timestamp < currentLocalTime) ? 0 : (commit.timestamp - - static_cast(currentLocalTime)); + static_cast(currentLocalTime)); LOGD("MultiVerSyncStateMachine::OneCommitSyncFinish src=%s, timefixOffset = %" PRId64, STR_MASK(context_->GetDeviceId()), timefixOffset); - commit.timestamp -= static_cast(timefixOffset); - ChangeEntriesTimeStamp(entries, outOffset, timefixOffset); + commit.timestamp -= static_cast(timefixOffset); + ChangeEntriesTimestamp(entries, outOffset, timefixOffset); PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); if (performance != nullptr) { performance->StepTimeRecordStart(MV_TEST_RECORDS::RECORD_PUT_COMMIT_DATA); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp index 74797b8d0..4fbeb8a0d 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp @@ -194,7 +194,7 @@ int QuerySyncWaterMarkHelper::SetRecvQueryWaterMark(const std::string &queryIden } int QuerySyncWaterMarkHelper::SetLastQueryTime(const std::string &queryIdentify, - const std::string &deviceId, const TimeStamp &timeStamp) + const std::string &deviceId, const Timestamp ×tamp) { std::string cacheKey; GetHashQuerySyncDeviceId(deviceId, queryIdentify, cacheKey); @@ -204,7 +204,7 @@ int QuerySyncWaterMarkHelper::SetLastQueryTime(const std::string &queryIdentify, if (errCode != E_OK) { return errCode; } - queryWaterMark.lastQueryTime = timeStamp; + queryWaterMark.lastQueryTime = timestamp; return UpdateCacheAndSave(cacheKey, queryWaterMark); } @@ -526,7 +526,7 @@ int QuerySyncWaterMarkHelper::RemoveLeastUsedQuerySyncItems(const std::vector> allItems; + std::vector> allItems; std::map> idMap; std::vector> waitToRemove; for (const auto &id : querySyncIds) { @@ -557,7 +557,7 @@ int QuerySyncWaterMarkHelper::RemoveLeastUsedQuerySyncItems(const std::vector &w1, std::pair &w2) { + [](std::pair &w1, std::pair &w2) { return w1.second < w2.second; }); for (uint32_t i = 0; i < removeCount; ++i) { diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.h b/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.h index bf0a37c90..f0e6a8b4a 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.h @@ -29,9 +29,9 @@ struct QueryWaterMark { uint32_t version = 0; // start with 103 WaterMark sendWaterMark = 0; WaterMark recvWaterMark = 0; - TimeStamp lastUsedTime = 0; // use for delete data + Timestamp lastUsedTime = 0; // use for delete data std::string sql; // for analyze sql from logs - TimeStamp lastQueryTime = 0; // use for miss query scene add in 106 + Timestamp lastQueryTime = 0; // use for miss query scene add in 106 }; struct DeleteWaterMark { @@ -78,7 +78,7 @@ public: const std::string &deviceId, const WaterMark &waterMark); int SetLastQueryTime(const std::string &queryIdentify, - const std::string &deviceId, const TimeStamp &timeStamp); + const std::string &deviceId, const Timestamp ×tamp); int GetDeleteSyncWaterMark(const std::string &deviceId, DeleteWaterMark &deleteWaterMark); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp index 0fbc3153f..70317ff5e 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp @@ -166,7 +166,7 @@ int SingleVerDataSync::TryContinueSync(SingleVerSyncTaskContext *context, const LOGI("[DataSync] ignore ack,sessionId is different"); return E_OK; } - TimeStamp lastQueryTime = 0; + Timestamp lastQueryTime = 0; if (reSendMap_.count(sequenceId) != 0) { lastQueryTime = reSendMap_[sequenceId].end; reSendMap_.erase(sequenceId); @@ -176,7 +176,7 @@ int SingleVerDataSync::TryContinueSync(SingleVerSyncTaskContext *context, const return E_OK; } if (context->IsQuerySync() && storage_->GetInterfaceType() == ISyncInterface::SYNC_RELATION) { - TimeStamp dbLastQueryTime = 0; + Timestamp dbLastQueryTime = 0; int errCode = metadata_->GetLastQueryTime(context->GetQuerySyncId(), context->GetDeviceId(), dbLastQueryTime); if (errCode == E_OK && dbLastQueryTime < lastQueryTime) { errCode = metadata_->SetLastQueryTime(context->GetQuerySyncId(), context->GetDeviceId(), lastQueryTime); @@ -337,13 +337,13 @@ int SingleVerDataSync::GetUnsyncData(SingleVerSyncTaskContext *context, std::vec } else { WaterMark deletedStartMark = 0; GetLocalDeleteSyncWaterMark(context, deletedStartMark); - TimeStamp lastQueryTimeStamp = 0; + Timestamp lastQueryTimestamp = 0; errCode = metadata_->GetLastQueryTime(context->GetQuerySyncId(), - context->GetDeviceId(), lastQueryTimeStamp); + context->GetDeviceId(), lastQueryTimestamp); if (errCode == E_OK) { QuerySyncObject queryObj = context->GetQuery(); errCode = storage_->GetSyncData(queryObj, - SyncTimeRange{ startMark, deletedStartMark, endMark, endMark, lastQueryTimeStamp}, + SyncTimeRange{ startMark, deletedStartMark, endMark, endMark, lastQueryTimestamp}, syncDataSizeInfo, token, outData); } } @@ -585,14 +585,14 @@ int SingleVerDataSync::DealRemoveDeviceDataByAck(SingleVerSyncTaskContext *conte return errCode; } -void SingleVerDataSync::SetSessionEndTimeStamp(TimeStamp end) +void SingleVerDataSync::SetSessionEndTimestamp(Timestamp end) { - sessionEndTimeStamp_ = end; + sessionEndTimestamp_ = end; } -TimeStamp SingleVerDataSync::GetSessionEndTimeStamp() const +Timestamp SingleVerDataSync::GetSessionEndTimestamp() const { - return sessionEndTimeStamp_; + return sessionEndTimestamp_; } void SingleVerDataSync::UpdateSendInfo(SyncTimeRange dataTimeRange, SingleVerSyncTaskContext *context) @@ -695,7 +695,7 @@ int SingleVerDataSync::RequestStart(SingleVerSyncTaskContext *context, int mode) UpdateWaterMark isUpdateWaterMark; SyncTimeRange dataTime = GetSyncDataTimeRange(curType, context, syncData.entries, isUpdateWaterMark); if (errCode == E_OK) { - SetSessionEndTimeStamp(std::max(dataTime.endTime, dataTime.deleteEndTime)); + SetSessionEndTimestamp(std::max(dataTime.endTime, dataTime.deleteEndTime)); } FillDataRequestPacket(packet, context, syncData, errCode, mode); errCode = SendDataPacket(curType, packet, context); @@ -809,7 +809,7 @@ int SingleVerDataSync::PullResponseStart(SingleVerSyncTaskContext *context) UpdateWaterMark isUpdateWaterMark; SyncTimeRange dataTime = GetSyncDataTimeRange(curType, context, syncData.entries, isUpdateWaterMark); if (errCode == E_OK) { - SetSessionEndTimeStamp(std::max(dataTime.endTime, dataTime.deleteEndTime)); + SetSessionEndTimestamp(std::max(dataTime.endTime, dataTime.deleteEndTime)); } errCode = SendPullResponseDataPkt(ackCode, syncData, context); if (errCode == E_OK || errCode == -E_TIMEOUT) { @@ -1641,12 +1641,12 @@ void SingleVerDataSync::FillRequestReSendPacket(const SingleVerSyncTaskContext * // transer reSend mode, RESPONSE_PULL transfer to push or query push // PUSH_AND_PULL mode which sequenceId lager than first transfer to push or query push int reSendMode = SingleVerDataSyncUtils::GetReSendMode(context->GetMode(), reSendInfo.sequenceId, curType); - if (GetSessionEndTimeStamp() == std::max(reSendInfo.end, reSendInfo.deleteDataEnd) || + if (GetSessionEndTimestamp() == std::max(reSendInfo.end, reSendInfo.deleteDataEnd) || SyncOperation::TransferSyncMode(context->GetMode()) == SyncModeType::PULL) { LOGI("[DataSync][ReSend] set lastid,label=%s,dev=%s", label_.c_str(), STR_MASK(GetDeviceId())); packet->SetLastSequence(); } - if (sendCode == E_OK && GetSessionEndTimeStamp() == std::max(reSendInfo.end, reSendInfo.deleteDataEnd) && + if (sendCode == E_OK && GetSessionEndTimestamp() == std::max(reSendInfo.end, reSendInfo.deleteDataEnd) && context->GetMode() == SyncModeType::RESPONSE_PULL) { sendCode = SEND_FINISHED; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.h b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.h index 657dd3c02..076ef7a21 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.h @@ -31,10 +31,10 @@ namespace DistributedDB { using SendDataItem = SingleVerKvEntry *; struct ReSendInfo { - TimeStamp start = 0; - TimeStamp end = 0; - TimeStamp deleteBeginTime = 0; - TimeStamp deleteEndTime = 0; + Timestamp start = 0; + Timestamp end = 0; + Timestamp deleteBeginTime = 0; + Timestamp deleteEndTime = 0; // packetId is used for matched ackpacket packetId which saved in ackPacket.reserve // if equaled, means need to handle the ack, or drop. it is always increased uint64_t packetId = 0; @@ -43,10 +43,10 @@ struct ReSendInfo { struct DataSyncReSendInfo { uint32_t sessionId = 0; uint32_t sequenceId = 0; - TimeStamp start = 0; // means normal or sync data localwatermark - TimeStamp end = 0; - TimeStamp deleteDataStart = 0; // means delete data localwatermark - TimeStamp deleteDataEnd = 0; + Timestamp start = 0; // means normal or sync data localwatermark + Timestamp end = 0; + Timestamp deleteDataStart = 0; // means delete data localwatermark + Timestamp deleteDataEnd = 0; uint64_t packetId = 0; }; @@ -134,9 +134,9 @@ protected: int32_t ReSend(SingleVerSyncTaskContext *context, DataSyncReSendInfo reSendInfo); - void SetSessionEndTimeStamp(TimeStamp end); + void SetSessionEndTimestamp(Timestamp end); - TimeStamp GetSessionEndTimeStamp() const; + Timestamp GetSessionEndTimestamp() const; void FillDataRequestPacket(DataRequestPacket *packet, SingleVerSyncTaskContext *context, SyncEntry &syncData, int sendCode, int mode); @@ -267,8 +267,8 @@ protected: // max sequenceId has been sent uint32_t maxSequenceIdHasSent_ = 0; bool isAllDataHasSent_ = false; - // in a sync session, the last data timeStamp - TimeStamp sessionEndTimeStamp_ = 0; + // in a sync session, the last data timestamp + Timestamp sessionEndTimestamp_ = 0; }; } // namespace DistributedDB diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp index 5647815de..bbdc1b2ca 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp @@ -106,7 +106,7 @@ void SingleVerDataSyncUtils::TransDbDataItemToSendDataItem(const std::string &lo } outData[i]->SetOrigDevice(outData[i]->GetOrigDevice().empty() ? localHashName : outData[i]->GetOrigDevice()); if (i == 0 || i == (outData.size() - 1)) { - LOGD("[DataSync][TransToSendItem] printData packet=%zu,timeStamp=%" PRIu64 ",flag=%" PRIu64, i, + LOGD("[DataSync][TransToSendItem] printData packet=%zu,timestamp=%" PRIu64 ",flag=%" PRIu64, i, outData[i]->GetTimestamp(), outData[i]->GetFlag()); } } @@ -125,17 +125,17 @@ void SingleVerDataSyncUtils::TransSendDataItemToLocal(const SingleVerSyncTaskCon const std::string &localHashName, const std::vector &data) { TimeOffset offset = context->GetTimeOffset(); - TimeStamp currentLocalTime = context->GetCurrentLocalTime(); + Timestamp currentLocalTime = context->GetCurrentLocalTime(); for (auto &item : data) { if (item == nullptr) { continue; } item->SetOrigDevice(TransferForeignOrigDevName(item->GetOrigDevice(), localHashName)); - TimeStamp tempTimestamp = item->GetTimestamp(); - TimeStamp tempWriteTimestamp = item->GetWriteTimestamp(); - item->SetTimestamp(tempTimestamp - static_cast(offset)); + Timestamp tempTimestamp = item->GetTimestamp(); + Timestamp tempWriteTimestamp = item->GetWriteTimestamp(); + item->SetTimestamp(tempTimestamp - static_cast(offset)); if (tempWriteTimestamp != 0) { - item->SetWriteTimestamp(tempWriteTimestamp - static_cast(offset)); + item->SetWriteTimestamp(tempWriteTimestamp - static_cast(offset)); } if (item->GetTimestamp() > currentLocalTime) { @@ -327,14 +327,14 @@ bool SingleVerDataSyncUtils::IsGetDataSuccessfully(int errCode) return (errCode == E_OK || errCode == -E_UNFINISHED); } -TimeStamp SingleVerDataSyncUtils::GetMaxSendDataTime(const std::vector &inData) +Timestamp SingleVerDataSyncUtils::GetMaxSendDataTime(const std::vector &inData) { - TimeStamp stamp = 0; + Timestamp stamp = 0; for (size_t i = 0; i < inData.size(); i++) { if (inData[i] == nullptr) { continue; } - TimeStamp tempStamp = inData[i]->GetTimestamp(); + Timestamp tempStamp = inData[i]->GetTimestamp(); if (stamp < tempStamp) { stamp = tempStamp; } @@ -345,22 +345,22 @@ TimeStamp SingleVerDataSyncUtils::GetMaxSendDataTime(const std::vector &inData, WaterMark localMark, UpdateWaterMark &isUpdate) { - TimeStamp maxTimeStamp = localMark; - TimeStamp minTimeStamp = localMark; + Timestamp maxTimestamp = localMark; + Timestamp minTimestamp = localMark; for (size_t i = 0; i < inData.size(); i++) { if (inData[i] == nullptr) { continue; } - TimeStamp tempStamp = inData[i]->GetTimestamp(); - if (maxTimeStamp < tempStamp) { - maxTimeStamp = tempStamp; + Timestamp tempStamp = inData[i]->GetTimestamp(); + if (maxTimestamp < tempStamp) { + maxTimestamp = tempStamp; } - if (minTimeStamp > tempStamp) { - minTimeStamp = tempStamp; + if (minTimestamp > tempStamp) { + minTimestamp = tempStamp; } isUpdate.normalUpdateMark = true; } - return {minTimeStamp, 0, maxTimeStamp, 0}; + return {minTimestamp, 0, maxTimestamp, 0}; } SyncTimeRange SingleVerDataSyncUtils::GetQuerySyncDataTimeRange(const std::vector &inData, @@ -371,7 +371,7 @@ SyncTimeRange SingleVerDataSyncUtils::GetQuerySyncDataTimeRange(const std::vecto if (inData[i] == nullptr) { continue; } - TimeStamp tempStamp = inData[i]->GetTimestamp(); + Timestamp tempStamp = inData[i]->GetTimestamp(); if ((inData[i]->GetFlag() & DataItem::DELETE_FLAG) == 0) { // query data if (dataTimeRange.endTime < tempStamp) { dataTimeRange.endTime = tempStamp; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.h b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.h index e58b762fd..f075ffaf2 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.h @@ -70,7 +70,7 @@ public: static bool IsGetDataSuccessfully(int errCode); - static TimeStamp GetMaxSendDataTime(const std::vector &inData); + static Timestamp GetMaxSendDataTime(const std::vector &inData); static SyncTimeRange GetFullSyncDataTimeRange(const std::vector &inData, WaterMark localMark, UpdateWaterMark &isUpdate); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp index 2f6a66862..805f558b1 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp @@ -119,7 +119,7 @@ int SingleVerSyncTaskContext::AddSyncOperation(SyncOperation *operation) return -E_OUT_OF_MEMORY; } newTarget->SetSyncOperation(operation); - TimeStamp timstamp = timeHelper_->GetTime(); + Timestamp timstamp = timeHelper_->GetTime(); newTarget->SetEndWaterMark(timstamp); newTarget->SetTaskType(ISyncTarget::REQUEST); AddSyncTarget(newTarget); @@ -504,17 +504,17 @@ bool SingleVerSyncTaskContext::IsCurrentSyncTaskCanBeSkipped() const return false; } - TimeStamp maxTimeStampInDb; - syncInterface_->GetMaxTimeStamp(maxTimeStampInDb); + Timestamp maxTimestampInDb; + syncInterface_->GetMaxTimestamp(maxTimestampInDb); uint64_t localWaterMark = 0; int errCode = GetCorrectedSendWaterMarkForCurrentTask(localWaterMark); if (errCode != E_OK) { LOGE("GetLocalWaterMark in state machine failed: %d", errCode); return false; } - if (localWaterMark > maxTimeStampInDb) { - LOGI("skip current push task, deviceId_ = %s, localWaterMark = %" PRIu64 ", maxTimeStampInDb = %" PRIu64, - STR_MASK(deviceId_), localWaterMark, maxTimeStampInDb); + if (localWaterMark > maxTimestampInDb) { + LOGI("skip current push task, deviceId_ = %s, localWaterMark = %" PRIu64 ", maxTimestampInDb = %" PRIu64, + STR_MASK(deviceId_), localWaterMark, maxTimestampInDb); return true; } return false; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp index 5a932f3b7..8ebefdd9a 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp @@ -963,10 +963,10 @@ int SyncEngine::InitTimeChangedListener() TimeOffset changedTimeOffset = *(reinterpret_cast(changedOffset)) * static_cast(TimeHelper::TO_100_NS); TimeOffset orgOffset = this->metadata_->GetLocalTimeOffset() - changedTimeOffset; - TimeStamp currentSysTime = TimeHelper::GetSysCurrentTime(); - TimeStamp maxItemTime = 0; - this->syncInterface_->GetMaxTimeStamp(maxItemTime); - if ((currentSysTime + static_cast(orgOffset)) <= maxItemTime) { + Timestamp currentSysTime = TimeHelper::GetSysCurrentTime(); + Timestamp maxItemTime = 0; + this->syncInterface_->GetMaxTimestamp(maxItemTime); + if ((currentSysTime + static_cast(orgOffset)) <= maxItemTime) { orgOffset = static_cast(maxItemTime - currentSysTime + TimeHelper::MS_TO_100_NS); // 1ms } this->metadata_->SaveLocalTimeOffset(orgOffset); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_task_context.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_task_context.cpp index 38ca255b3..ac2b9d305 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_task_context.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_task_context.cpp @@ -445,7 +445,7 @@ void SyncTaskContext::SafeExit() } } -TimeStamp SyncTaskContext::GetCurrentLocalTime() const +Timestamp SyncTaskContext::GetCurrentLocalTime() const { if (timeHelper_ == nullptr) { return TimeHelper::INVALID_TIMESTAMP; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_task_context.h b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_task_context.h index a1df05992..310ba3004 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_task_context.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_task_context.h @@ -150,7 +150,7 @@ public: void SafeExit() override; // Get current local time from TimeHelper - TimeStamp GetCurrentLocalTime() const override; + Timestamp GetCurrentLocalTime() const override; // Set the remount software version num void SetRemoteSoftwareVersion(uint32_t version) override; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/syncer_proxy.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/syncer_proxy.cpp index 71a9fbe24..0c71b0da4 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/syncer_proxy.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/syncer_proxy.cpp @@ -88,12 +88,12 @@ int SyncerProxy::StopSync() return syncer_->StopSync(); } -uint64_t SyncerProxy::GetTimeStamp() +uint64_t SyncerProxy::GetTimestamp() { if (syncer_ == nullptr) { - return SyncerFactory::GetSyncer(ISyncInterface::SYNC_SVD)->GetTimeStamp(); + return SyncerFactory::GetSyncer(ISyncInterface::SYNC_SVD)->GetTimestamp(); } - return syncer_->GetTimeStamp(); + return syncer_->GetTimestamp(); } void SyncerProxy::EnableAutoSync(bool enable) diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.cpp index 2e7727853..c54b7fa6d 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.cpp @@ -21,10 +21,10 @@ namespace DistributedDB { std::mutex TimeHelper::systemTimeLock_; -TimeStamp TimeHelper::lastSystemTimeUs_ = 0; -TimeStamp TimeHelper::currentIncCount_ = 0; +Timestamp TimeHelper::lastSystemTimeUs_ = 0; +Timestamp TimeHelper::currentIncCount_ = 0; -TimeStamp TimeHelper::GetSysCurrentTime() +Timestamp TimeHelper::GetSysCurrentTime() { uint64_t curTime = 0; std::lock_guard lock(systemTimeLock_); @@ -43,7 +43,7 @@ TimeStamp TimeHelper::GetSysCurrentTime() lastSystemTimeUs_ = curTime; currentIncCount_ = 0; } - return (curTime * TO_100_NS) + currentIncCount_; // Currently TimeStamp is uint64_t + return (curTime * TO_100_NS) + currentIncCount_; // Currently Timestamp is uint64_t } TimeHelper::TimeHelper() @@ -65,9 +65,9 @@ int TimeHelper::Initialize(const ISyncInterface *inStorage, std::shared_ptr MAX_VALID_TIME || localTimeOffset > MAX_VALID_TIME || maxItemTime > MAX_VALID_TIME) { return -E_INVALID_TIME; } @@ -79,16 +79,16 @@ int TimeHelper::Initialize(const ISyncInterface *inStorage, std::shared_ptrSetLastLocalTime(currentSysTime + static_cast(localTimeOffset)); + metadata_->SetLastLocalTime(currentSysTime + static_cast(localTimeOffset)); return E_OK; } -TimeStamp TimeHelper::GetTime() +Timestamp TimeHelper::GetTime() { - TimeStamp currentSysTime = GetSysCurrentTime(); + Timestamp currentSysTime = GetSysCurrentTime(); TimeOffset localTimeOffset = GetLocalTimeOffset(); - TimeStamp currentLocalTime = currentSysTime + localTimeOffset; - TimeStamp lastLocalTime = metadata_->GetLastLocalTime(); + Timestamp currentLocalTime = currentSysTime + localTimeOffset; + Timestamp lastLocalTime = metadata_->GetLastLocalTime(); if (currentLocalTime <= lastLocalTime || currentLocalTime > MAX_VALID_TIME) { lastLocalTime++; currentLocalTime = lastLocalTime; @@ -99,10 +99,10 @@ TimeStamp TimeHelper::GetTime() return currentLocalTime; } -TimeStamp TimeHelper::GetMaxDataItemTime() +Timestamp TimeHelper::GetMaxDataItemTime() { - TimeStamp timestamp = 0; - storage_->GetMaxTimeStamp(timestamp); + Timestamp timestamp = 0; + storage_->GetMaxTimestamp(timestamp); return timestamp; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.h b/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.h index 63765e0c8..d19d00bd8 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.h @@ -33,10 +33,10 @@ public: static const uint64_t MS_TO_100_NS = 10000; // 1ms to 100ns - static const TimeStamp INVALID_TIMESTAMP = 0; + static const Timestamp INVALID_TIMESTAMP = 0; // Get current system time - static TimeStamp GetSysCurrentTime(); + static Timestamp GetSysCurrentTime(); TimeHelper(); ~TimeHelper(); @@ -44,11 +44,11 @@ public: // Init the TimeHelper int Initialize(const ISyncInterface *inStorage, std::shared_ptr &inMetadata); - // Get TimeStamp when write data into db, export interface; - TimeStamp GetTime(); + // Get Timestamp when write data into db, export interface; + Timestamp GetTime(); // Get max data time from db - TimeStamp GetMaxDataItemTime(); + Timestamp GetMaxDataItemTime(); // Get local time offset TimeOffset GetLocalTimeOffset() const; @@ -60,8 +60,8 @@ public: private: static std::mutex systemTimeLock_; - static TimeStamp lastSystemTimeUs_; - static TimeStamp currentIncCount_; + static Timestamp lastSystemTimeUs_; + static Timestamp currentIncCount_; static const uint64_t MAX_INC_COUNT = 9; // last bit from 0-9 const ISyncInterface *storage_; std::shared_ptr metadata_; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp index f0d865527..a7a401788 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp @@ -45,42 +45,42 @@ TimeSyncPacket::~TimeSyncPacket() { } -void TimeSyncPacket::SetSourceTimeBegin(TimeStamp sourceTimeBegin) +void TimeSyncPacket::SetSourceTimeBegin(Timestamp sourceTimeBegin) { sourceTimeBegin_ = sourceTimeBegin; } -TimeStamp TimeSyncPacket::GetSourceTimeBegin() const +Timestamp TimeSyncPacket::GetSourceTimeBegin() const { return sourceTimeBegin_; } -void TimeSyncPacket::SetSourceTimeEnd(TimeStamp sourceTimeEnd) +void TimeSyncPacket::SetSourceTimeEnd(Timestamp sourceTimeEnd) { sourceTimeEnd_ = sourceTimeEnd; } -TimeStamp TimeSyncPacket::GetSourceTimeEnd() const +Timestamp TimeSyncPacket::GetSourceTimeEnd() const { return sourceTimeEnd_; } -void TimeSyncPacket::SetTargetTimeBegin(TimeStamp targetTimeBegin) +void TimeSyncPacket::SetTargetTimeBegin(Timestamp targetTimeBegin) { targetTimeBegin_ = targetTimeBegin; } -TimeStamp TimeSyncPacket::GetTargetTimeBegin() const +Timestamp TimeSyncPacket::GetTargetTimeBegin() const { return targetTimeBegin_; } -void TimeSyncPacket::SetTargetTimeEnd(TimeStamp targetTimeEnd) +void TimeSyncPacket::SetTargetTimeEnd(Timestamp targetTimeEnd) { targetTimeEnd_ = targetTimeEnd; } -TimeStamp TimeSyncPacket::GetTargetTimeEnd() const +Timestamp TimeSyncPacket::GetTargetTimeEnd() const { return targetTimeEnd_; } @@ -194,7 +194,7 @@ int TimeSync::SyncStart(const CommErrHandler &handler, uint32_t sessionId) { isOnline_ = true; TimeSyncPacket packet; - TimeStamp startTime = timeHelper_->GetTime(); + Timestamp startTime = timeHelper_->GetTime(); packet.SetSourceTimeBegin(startTime); // send timeSync request LOGD("[TimeSync] startTime = %" PRIu64 ", dev = %s{private}", startTime, deviceId_.c_str()); @@ -246,10 +246,10 @@ int TimeSync::Serialization(uint8_t *buffer, uint32_t length, const Message *inM } Parcel parcel(buffer, length); - TimeStamp srcBegin = packet->GetSourceTimeBegin(); - TimeStamp srcEnd = packet->GetSourceTimeEnd(); - TimeStamp targetBegin = packet->GetTargetTimeBegin(); - TimeStamp targetEnd = packet->GetTargetTimeEnd(); + Timestamp srcBegin = packet->GetSourceTimeBegin(); + Timestamp srcEnd = packet->GetSourceTimeEnd(); + Timestamp targetBegin = packet->GetTargetTimeBegin(); + Timestamp targetEnd = packet->GetTargetTimeEnd(); int errCode = parcel.WriteUInt32(TIME_SYNC_VERSION_V1); if (errCode != E_OK) { @@ -283,10 +283,10 @@ int TimeSync::DeSerialization(const uint8_t *buffer, uint32_t length, Message *i } TimeSyncPacket packet; Parcel parcel(const_cast(buffer), length); - TimeStamp srcBegin; - TimeStamp srcEnd; - TimeStamp targetBegin; - TimeStamp targetEnd; + Timestamp srcBegin; + Timestamp srcEnd; + Timestamp targetBegin; + Timestamp targetEnd; uint32_t version = 0; parcel.ReadUInt32(version); @@ -330,7 +330,7 @@ int TimeSync::AckRecv(const Message *message, uint32_t targetSessionId) } TimeSyncPacket packetData = TimeSyncPacket(*packet); - TimeStamp sourceTimeEnd = timeHelper_->GetTime(); + Timestamp sourceTimeEnd = timeHelper_->GetTime(); packetData.SetSourceTimeEnd(sourceTimeEnd); if (packetData.GetSourceTimeBegin() > packetData.GetSourceTimeEnd() || packetData.GetTargetTimeBegin() > packetData.GetTargetTimeEnd() || @@ -367,7 +367,7 @@ int TimeSync::RequestRecv(const Message *message) if (!IsPacketValid(message, TYPE_REQUEST)) { return -E_INVALID_ARGS; } - TimeStamp targetTimeBegin = timeHelper_->GetTime(); + Timestamp targetTimeBegin = timeHelper_->GetTime(); const TimeSyncPacket *packet = message->GetObject(); if (packet == nullptr) { @@ -377,7 +377,7 @@ int TimeSync::RequestRecv(const Message *message) // build timeSync ack packet TimeSyncPacket ackPacket = TimeSyncPacket(*packet); ackPacket.SetTargetTimeBegin(targetTimeBegin); - TimeStamp targetTimeEnd = timeHelper_->GetTime(); + Timestamp targetTimeEnd = timeHelper_->GetTime(); ackPacket.SetTargetTimeEnd(targetTimeEnd); LOGD("TimeSync::RequestRecv, dev = %s{private}, sTimeEnd = %" PRIu64 ", tTimeEnd = %" PRIu64 ", sbegin = %" PRIu64 ", tbegin = %" PRIu64, deviceId_.c_str(), ackPacket.GetSourceTimeEnd(), ackPacket.GetTargetTimeEnd(), diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.h b/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.h index df84e6fb1..5aaa8a115 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.h @@ -27,21 +27,21 @@ public: TimeSyncPacket(); ~TimeSyncPacket(); - void SetSourceTimeBegin(TimeStamp sourceTimeBegin); + void SetSourceTimeBegin(Timestamp sourceTimeBegin); - TimeStamp GetSourceTimeBegin() const; + Timestamp GetSourceTimeBegin() const; - void SetSourceTimeEnd(TimeStamp sourceTimeEnd); + void SetSourceTimeEnd(Timestamp sourceTimeEnd); - TimeStamp GetSourceTimeEnd() const; + Timestamp GetSourceTimeEnd() const; - void SetTargetTimeBegin(TimeStamp targetTimeBegin); + void SetTargetTimeBegin(Timestamp targetTimeBegin); - TimeStamp GetTargetTimeBegin() const; + Timestamp GetTargetTimeBegin() const; - void SetTargetTimeEnd(TimeStamp targetTimeEnd); + void SetTargetTimeEnd(Timestamp targetTimeEnd); - TimeStamp GetTargetTimeEnd() const; + Timestamp GetTargetTimeEnd() const; void SetVersion(uint32_t version); @@ -49,10 +49,10 @@ public: static uint32_t CalculateLen(); private: - TimeStamp sourceTimeBegin_; // start point time on peer - TimeStamp sourceTimeEnd_; // end point time on local - TimeStamp targetTimeBegin_; // start point time on peer - TimeStamp targetTimeEnd_; // end point time on peer + Timestamp sourceTimeBegin_; // start point time on peer + Timestamp sourceTimeEnd_; // end point time on local + Timestamp targetTimeBegin_; // start point time on peer + Timestamp targetTimeEnd_; // end point time on peer uint32_t version_; }; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_auto_launch_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_auto_launch_test.cpp index e75c7cd63..970373b36 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_auto_launch_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_auto_launch_test.cpp @@ -52,7 +52,7 @@ namespace { const int WAIT_TIME = 1000; // 1000ms const int LIFE_CYCLE_TIME = 5000; // 5000ms const int WAIT_SHORT_TIME = 200; // 20ms - const TimeStamp TIME_ADD = 1000; // not zero is ok + const Timestamp TIME_ADD = 1000; // not zero is ok const std::string REMOTE_DEVICE_ID = "remote_device"; const std::string THIS_DEVICE = "real_device"; @@ -172,8 +172,8 @@ static void PutSyncData(const KvDBProperties &prop, const Key &key, const Value ASSERT_NE(connection, nullptr); if (kvStore != nullptr) { std::vector vect; - TimeStamp time; - kvStore->GetMaxTimeStamp(time); + Timestamp time; + kvStore->GetMaxTimestamp(time); time += TIME_ADD; LOGD("time:%" PRIu64, time); vect.push_back({key, value, time, 0, DBCommon::TransferHashString(REMOTE_DEVICE_ID)}); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_tools_unit_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_tools_unit_test.cpp index e3c5551a3..6d4db3a0c 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_tools_unit_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_tools_unit_test.cpp @@ -635,7 +635,7 @@ void DistributedDBToolsUnitTest::ConvertSingleVerEntryToItems(std::vectorGetOrigDevice(); item.flag = entry->GetFlag(); - item.timeStamp = entry->GetTimestamp(); + item.timestamp = entry->GetTimestamp(); entry->GetKey(item.key); entry->GetValue(item.value); dataItems.push_back(item); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_auto_launch_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_auto_launch_test.cpp index 2be6f5f43..f3772f70c 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_auto_launch_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_auto_launch_test.cpp @@ -302,8 +302,8 @@ void PutSyncData(const std::string &storeId, const Key &key, const Value &value, ASSERT_NE(connection, nullptr); if (kvStore != nullptr) { std::vector vect; - TimeStamp time = 100; // initial valid timestamp. - kvStore->GetMaxTimeStamp(time); + Timestamp time = 100; // initial valid timestamp. + kvStore->GetMaxTimestamp(time); if (isCover) { time += 10; // add the diff for 10. } else { diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_data_transformer_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_data_transformer_test.cpp index f1e605a05..b3c6b353d 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_data_transformer_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_data_transformer_test.cpp @@ -104,7 +104,7 @@ bool Equal(const LogInfo &origin, const LogInfo &target) if (origin.timestamp != target.timestamp) { return false; } - if (origin.wTimeStamp != target.wTimeStamp) { + if (origin.wTimestamp != target.wTimestamp) { return false; } return true; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_relational_get_data_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_relational_get_data_test.cpp index 195c47bee..369c7e171 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_relational_get_data_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_relational_get_data_test.cpp @@ -84,7 +84,7 @@ int AddOrUpdateRecord(int64_t key, int64_t value) return errCode; } -int GetLogData(int key, uint64_t &flag, TimeStamp ×tamp, const DeviceID &device = "") +int GetLogData(int key, uint64_t &flag, Timestamp ×tamp, const DeviceID &device = "") { string tableName = g_tableName; if (!device.empty()) { @@ -111,8 +111,8 @@ int GetLogData(int key, uint64_t &flag, TimeStamp ×tamp, const DeviceID &de } errCode = SQLiteUtils::StepWithRetry(statement, false); if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)) { - timestamp = static_cast(sqlite3_column_int64(statement, 0)); - flag = static_cast(sqlite3_column_int64(statement, 1)); + timestamp = static_cast(sqlite3_column_int64(statement, 0)); + flag = static_cast(sqlite3_column_int64(statement, 1)); errCode = E_OK; } else if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_DONE)) { errCode = -E_NOT_FOUND; @@ -317,7 +317,7 @@ HWTEST_F(DistributedDBRelationalGetDataTest, LogTbl1, TestSize.Level1) * @tc.expected: Record exists. */ uint64_t flag = 0; - TimeStamp timestamp1 = 0; + Timestamp timestamp1 = 0; EXPECT_EQ(GetLogData(insertKey, flag, timestamp1), E_OK); EXPECT_EQ(flag, DataItem::LOCAL_FLAG); EXPECT_NE(timestamp1, 0ULL); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_commit_storage_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_commit_storage_test.cpp index 89df0e470..615b8eb5d 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_commit_storage_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_commit_storage_test.cpp @@ -61,25 +61,25 @@ namespace { DeviceID g_remoteDeviceB = "remote_device_B"; DeviceID g_remoteDeviceC = "remote_device_C"; DeviceID g_remoteDeviceD = "remote_device_D"; - const TimeStamp TIME_STAMP1 = 100; - const TimeStamp TIME_STAMP2 = 200; - const TimeStamp TIME_STAMP3 = 300; - const TimeStamp TIME_STAMP4 = 400; - const TimeStamp TIME_STAMP5 = 500; - const TimeStamp TIME_STAMP6 = 600; - const TimeStamp TIME_STAMP7 = 700; - const TimeStamp TIME_STAMP8 = 800; - const TimeStamp TIME_STAMP9 = 900; - const TimeStamp TIME_STAMP10 = 1000; - const TimeStamp TIME_STAMP11 = 1100; - const TimeStamp TIME_STAMP12 = 1200; + const Timestamp TIME_STAMP1 = 100; + const Timestamp TIME_STAMP2 = 200; + const Timestamp TIME_STAMP3 = 300; + const Timestamp TIME_STAMP4 = 400; + const Timestamp TIME_STAMP5 = 500; + const Timestamp TIME_STAMP6 = 600; + const Timestamp TIME_STAMP7 = 700; + const Timestamp TIME_STAMP8 = 800; + const Timestamp TIME_STAMP9 = 900; + const Timestamp TIME_STAMP10 = 1000; + const Timestamp TIME_STAMP11 = 1100; + const Timestamp TIME_STAMP12 = 1200; struct CommitInfo { Version version; string commitID; string leftCommitID; string rightCommitID; - TimeStamp timestamp; + Timestamp timestamp; bool localFlag; DeviceID deviceInfo; }; @@ -107,7 +107,7 @@ namespace { CommitID rightCommitID = commit->GetRightParentId(); string rightCommitIDStr = TransCommitIDToStr(rightCommitID); ASSERT_STREQ(rightCommitIDStr.c_str(), commitInfo.rightCommitID.c_str()); - TimeStamp timestamp = commit->GetTimestamp(); + Timestamp timestamp = commit->GetTimestamp(); ASSERT_EQ(timestamp, commitInfo.timestamp); bool localFlag = commit->GetLocalFlag(); ASSERT_EQ(localFlag, commitInfo.localFlag); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_memory_single_ver_naturall_store_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_memory_single_ver_naturall_store_test.cpp index 132e387ae..3d7eb017f 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_memory_single_ver_naturall_store_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_memory_single_ver_naturall_store_test.cpp @@ -205,9 +205,9 @@ HWTEST_F(DistributedDBStorageMemorySingleVerNaturalStoreTest, PutSyncData001, Te * @tc.steps:step1/2. Set Ioption to synchronous data and insert a (key1, value1) data record by put interface. */ /** - * @tc.steps:step3. Insert a (key1, value2!=value1, timeStamp, false) data record - * through the PutSyncData interface. The value of timeStamp is less than or equal - * to the value of timeStamp. For Compare the timestamp to determine whether to synchronization data. + * @tc.steps:step3. Insert a (key1, value2!=value1, timestamp, false) data record + * through the PutSyncData interface. The value of timestamp is less than or equal + * to the value of timestamp. For Compare the timestamp to determine whether to synchronization data. * @tc.expected: step3. Return OK. */ /** @@ -216,9 +216,9 @@ HWTEST_F(DistributedDBStorageMemorySingleVerNaturalStoreTest, PutSyncData001, Te * @tc.expected: step4. Return OK.The obtained value is value1. */ /** - * @tc.steps:step5. Insert a (key1, value3!=value1, timeStamp, false) data record - * through the PutSyncData interface of the NaturalStore. The value of timeStamp - * is greater than that of timeStamp inserted in 2. + * @tc.steps:step5. Insert a (key1, value3!=value1, timestamp, false) data record + * through the PutSyncData interface of the NaturalStore. The value of timestamp + * is greater than that of timestamp inserted in 2. * @tc.expected: step5. Return OK. */ /** @@ -252,9 +252,9 @@ HWTEST_F(DistributedDBStorageMemorySingleVerNaturalStoreTest, PutSyncData002, Te * @tc.steps:step1/2. Set Ioption to synchronous data and insert a (key1, value1) data record by put interface. */ /** - * @tc.steps:step3. Insert a (key1, value2!=value1, timeStamp, false) data record - * through the PutSyncData interface. The value of timeStamp is less than or equal - * to the value of timeStamp. For Compare the timestamp to determine whether delete data. + * @tc.steps:step3. Insert a (key1, value2!=value1, timestamp, false) data record + * through the PutSyncData interface. The value of timestamp is less than or equal + * to the value of timestamp. For Compare the timestamp to determine whether delete data. * @tc.expected: step3. Return OK. */ /** @@ -263,9 +263,9 @@ HWTEST_F(DistributedDBStorageMemorySingleVerNaturalStoreTest, PutSyncData002, Te * @tc.expected: step4. Return OK.The obtained value is value1. */ /** - * @tc.steps:step5. Insert a (key1, value3!=value1, timeStamp, false) data record - * through the PutSyncData interfac. The value of timeStamp - * is greater than that of timeStamp inserted in step2. + * @tc.steps:step5. Insert a (key1, value3!=value1, timestamp, false) data record + * through the PutSyncData interfac. The value of timestamp + * is greater than that of timestamp inserted in step2. * @tc.expected: step5. Return OK. */ /** @@ -416,13 +416,13 @@ HWTEST_F(DistributedDBStorageMemorySingleVerNaturalStoreTest, GetMetaData001, Te } /** - * @tc.name: GetCurrentMaxTimeStamp001 + * @tc.name: GetCurrentMaxTimestamp001 * @tc.desc: To test the function of obtaining the maximum timestamp when a record exists in the database. * @tc.type: FUNC * @tc.require: AR000CCPOM * @tc.author: wangbingquan */ -HWTEST_F(DistributedDBStorageMemorySingleVerNaturalStoreTest, GetCurrentMaxTimeStamp001, TestSize.Level1) +HWTEST_F(DistributedDBStorageMemorySingleVerNaturalStoreTest, GetCurrentMaxTimestamp001, TestSize.Level1) { /** * @tc.steps:step1/2. Insert a data record into the synchronization database. @@ -437,23 +437,23 @@ HWTEST_F(DistributedDBStorageMemorySingleVerNaturalStoreTest, GetCurrentMaxTimeS * @tc.steps:step5. Obtain the maximum timestamp B and check whether B>=A exists. * @tc.expected: step5. The obtained timestamp is B>=A. */ - DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimeStamp001(g_store, g_connection); + DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimestamp001(g_store, g_connection); } /** - * @tc.name: GetCurrentMaxTimeStamp002 + * @tc.name: GetCurrentMaxTimestamp002 * @tc.desc: Obtain the maximum timestamp when no record exists in the test record library. * @tc.type: FUNC * @tc.require: AR000CCPOM * @tc.author: wangbingquan */ -HWTEST_F(DistributedDBStorageMemorySingleVerNaturalStoreTest, GetCurrentMaxTimeStamp002, TestSize.Level1) +HWTEST_F(DistributedDBStorageMemorySingleVerNaturalStoreTest, GetCurrentMaxTimestamp002, TestSize.Level1) { /** * @tc.steps:step1. Obtains the maximum timestamp in the current database record. * @tc.expected: step1. Return timestamp is 0. */ - DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimeStamp002(g_store); + DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimestamp002(g_store); } /** diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_query_sync_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_query_sync_test.cpp index 0de7b73d6..c8791c199 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_query_sync_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_query_sync_test.cpp @@ -261,7 +261,7 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, GetQuerySyncData002, TestSize.Level1 * @tc.steps: step3. Put k3. k3's timestamp t3 is random. * @tc.expected: step3. Put k3. */ - auto time3 = static_cast(DistributedDBToolsUnitTest::GetRandInt64(0, g_store->GetCurrentTimeStamp())); + auto time3 = static_cast(DistributedDBToolsUnitTest::GetRandInt64(0, g_store->GetCurrentTimestamp())); DataItem data3{KEY3, VALUE3, time3, DataItem::LOCAL_FLAG, REMOTE_DEVICE_ID}; EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(g_store, vector{data3}, REMOTE_DEVICE_ID), E_OK); @@ -280,14 +280,14 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, GetQuerySyncData002, TestSize.Level1 * @tc.expected: step5. Delete k1 k3 successfully. */ IOption option{ IOption::SYNC_DATA }; - TimeStamp deleteBeginTime = g_store->GetCurrentTimeStamp(); + Timestamp deleteBeginTime = g_store->GetCurrentTimestamp(); g_connection->DeleteBatch(option, vector{KEY1, KEY3}); /** * @tc.steps: step6. Get deleted data. * @tc.expected: step6. Get k1 k3. */ - TimeStamp deleteEndTime = g_store->GetCurrentTimeStamp(); + Timestamp deleteEndTime = g_store->GetCurrentTimestamp(); EXPECT_EQ(g_store->GetSyncData(queryObj, SyncTimeRange{0, deleteBeginTime, 0, deleteEndTime}, specInfo, token, entries), E_OK); EXPECT_EQ(entries.size(), 2UL); @@ -330,7 +330,7 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, GetQuerySyncData004, TestSize.Level1 * @tc.steps: step3. Put k3. k3's timestamp t3 is random. * @tc.expected: step3. Put k3. */ - auto time3 = static_cast(DistributedDBToolsUnitTest::GetRandInt64(0, g_store->GetCurrentTimeStamp())); + auto time3 = static_cast(DistributedDBToolsUnitTest::GetRandInt64(0, g_store->GetCurrentTimestamp())); DataItem data3{KEY3, VALUE3, time3, DataItem::LOCAL_FLAG, REMOTE_DEVICE_ID}; EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(g_store, vector{data3}, REMOTE_DEVICE_ID), E_OK); @@ -349,14 +349,14 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, GetQuerySyncData004, TestSize.Level1 * @tc.expected: step5. Delete k1 k3 successfully. */ IOption option{ IOption::SYNC_DATA }; - TimeStamp deleteBeginTime = g_store->GetCurrentTimeStamp(); + Timestamp deleteBeginTime = g_store->GetCurrentTimestamp(); g_connection->DeleteBatch(option, vector{KEY1, KEY3}); /** * @tc.steps: step6. Get deleted data. * @tc.expected: step6. Get k1 k3. */ - TimeStamp deleteEndTime = g_store->GetCurrentTimeStamp(); + Timestamp deleteEndTime = g_store->GetCurrentTimestamp(); token = new (std::nothrow) SQLiteSingleVerContinueToken{SyncTimeRange{0, deleteBeginTime, 0, deleteEndTime}, queryObj}; EXPECT_EQ(g_store->GetSyncDataNext(entries, token, specInfo), E_OK); @@ -393,7 +393,7 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, GetQuerySyncData006, TestSize.Level1 * @tc.steps: step2. Get sync data with invalid SyncTimeRange(beginTime is greater than endTime). * @tc.expected: step2. GetSyncData return E_INVALID_ARGS. */ - auto time = static_cast(DistributedDBToolsUnitTest::GetRandInt64(0, INT64_MAX)); + auto time = static_cast(DistributedDBToolsUnitTest::GetRandInt64(0, INT64_MAX)); EXPECT_EQ(g_store->GetSyncData(queryObj, SyncTimeRange{time, 0, 0}, specInfo, token, entries), -E_INVALID_ARGS); } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_register_conflict_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_register_conflict_test.cpp index 31a3c0008..a7d5f6228 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_register_conflict_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_register_conflict_test.cpp @@ -274,7 +274,7 @@ static void SyncPutConflictData(int deltaTime) IOption option; option.dataType = IOption::SYNC_DATA; - TimeStamp timeEnd = TimeHelper::GetSysCurrentTime(); + Timestamp timeEnd = TimeHelper::GetSysCurrentTime(); std::vector vect; vect.push_back({KEY_1, VALUE_1, timeEnd, 0, DBCommon::TransferHashString("deviceB")}); EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(g_store, vect, "deviceB"), E_OK); @@ -308,7 +308,7 @@ static void SyncDeleteConflictData(const int deltaTime) IOption option; option.dataType = IOption::SYNC_DATA; - TimeStamp time = TimeHelper::GetSysCurrentTime(); + Timestamp time = TimeHelper::GetSysCurrentTime(); std::vector vect; vect.push_back({KEY_1, VALUE_1, time, 0, DBCommon::TransferHashString("deviceB")}); @@ -332,7 +332,7 @@ static void SyncPutFromDiffDevConflictData(const int deltaTime) IOption option; option.dataType = IOption::SYNC_DATA; - TimeStamp time = TimeHelper::GetSysCurrentTime(); + Timestamp time = TimeHelper::GetSysCurrentTime(); std::vector vect; vect.push_back({KEY_1, VALUE_1, time, 0, DBCommon::TransferHashString("deviceB")}); @@ -353,7 +353,7 @@ static void SyncDeleteFromDiffDevConflictData(const int deltaTime) IOption option; option.dataType = IOption::SYNC_DATA; - TimeStamp time = TimeHelper::GetSysCurrentTime(); + Timestamp time = TimeHelper::GetSysCurrentTime(); std::vector vect; vect.push_back({KEY_1, VALUE_1, time, 0, DBCommon::TransferHashString("deviceB")}); @@ -463,7 +463,7 @@ HWTEST_F(DistributedDBStorageRegisterConflictTest, ConflictNotificationTest003, */ HWTEST_F(DistributedDBStorageRegisterConflictTest, ConflictNotificationTest004, TestSize.Level1) { - TimeStamp time = TimeHelper::GetSysCurrentTime(); + Timestamp time = TimeHelper::GetSysCurrentTime(); /** * @tc.steps:step1/2. Sync a kv data into database with KEY_1, VALUE_1 and setup conflict notifier. * @tc.expected: step1/2. setup conflict notifier success. @@ -496,7 +496,7 @@ HWTEST_F(DistributedDBStorageRegisterConflictTest, ConflictNotificationTest004, */ HWTEST_F(DistributedDBStorageRegisterConflictTest, ConflictNotificationTest005, TestSize.Level1) { - TimeStamp time = TimeHelper::GetSysCurrentTime(); + Timestamp time = TimeHelper::GetSysCurrentTime(); /** * @tc.steps:step1/2. Sync a kv data into database with KEY_1, VALUE_1 and setup conflict notifier. * @tc.expected: step1/2. setup conflict notifier success. @@ -533,7 +533,7 @@ HWTEST_F(DistributedDBStorageRegisterConflictTest, ConflictNotificationTest006, * @tc.expected: step1/2. setup conflict notifier success and no conflict being triggered. */ EXPECT_TRUE(g_kvNbDelegatePtr->SetConflictNotifier(CONFLICT_ALL, NotifierCallback) == OK); - TimeStamp time = TimeHelper::GetSysCurrentTime(); + Timestamp time = TimeHelper::GetSysCurrentTime(); std::vector vect; vect.push_back({KEY_1, VALUE_1, time, 1, DBCommon::TransferHashString("deviceB")}); EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(g_store, vect, "deviceB"), E_OK); @@ -725,7 +725,7 @@ HWTEST_F(DistributedDBStorageRegisterConflictTest, ConflictNotificationTest014, */ HWTEST_F(DistributedDBStorageRegisterConflictTest, ConflictNotificationTest015, TestSize.Level1) { - TimeStamp timeEnd = TimeHelper::GetSysCurrentTime(); + Timestamp timeEnd = TimeHelper::GetSysCurrentTime(); std::vector vect; vect.push_back({KEY_1, VALUE_1, timeEnd, 0, "deviceB", 0, "deviceB"}); @@ -754,7 +754,7 @@ HWTEST_F(DistributedDBStorageRegisterConflictTest, ConflictNotificationTest016, { IOption option; option.dataType = IOption::SYNC_DATA; - TimeStamp timeEnd = TimeHelper::GetSysCurrentTime(); + Timestamp timeEnd = TimeHelper::GetSysCurrentTime(); std::vector vect; vect.push_back({KEY_1, VALUE_1, timeEnd, 0, DBCommon::TransferHashString("deviceB")}); @@ -823,7 +823,7 @@ HWTEST_F(DistributedDBStorageRegisterConflictTest, ConflictNotificationTest017, g_connection->Put(option, KEY_1, VALUE_1); ASSERT_EQ(g_connection->SetConflictNotifier(CONFLICT_ALL, NotifierConnectCallback), E_OK); - TimeStamp timeEnd = TimeHelper::GetSysCurrentTime(); + Timestamp timeEnd = TimeHelper::GetSysCurrentTime(); static const uint32_t addTimestamp = 10000; vect.push_back({KEY_1, VALUE_2, timeEnd + addTimestamp, 0, "", timeEnd + addTimestamp, DBCommon::TransferHashString("deviceB")}); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_register_observer_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_register_observer_test.cpp index 614a9751c..a4f8bdeab 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_register_observer_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_register_observer_test.cpp @@ -195,14 +195,14 @@ namespace { entries.push_back(entry); // test sync insert - TimeStamp time; - g_singleVerNaturaStore->GetMaxTimeStamp(time); + Timestamp time; + g_singleVerNaturaStore->GetMaxTimestamp(time); DataItem dataItem; dataItem.key = entry.key; dataItem.value = entry.value; - dataItem.timeStamp = time + 1; - dataItem.writeTimeStamp = dataItem.timeStamp; + dataItem.timestamp = time + 1; + dataItem.writeTimestamp = dataItem.timestamp; dataItem.flag = 0; vector insertDataItems; insertDataItems.push_back(dataItem); @@ -212,8 +212,8 @@ namespace { TestAndClearCallbackResult(isSyncRegisted, entries, g_emptyEntries, g_emptyEntries); // test sync update vector updateDataItems; - dataItem.timeStamp++; - dataItem.writeTimeStamp = dataItem.timeStamp; + dataItem.timestamp++; + dataItem.writeTimestamp = dataItem.timestamp; updateDataItems.push_back(dataItem); result = DistributedDBToolsUnitTest::PutSyncDataTest(g_singleVerNaturaStore, updateDataItems, "deviceB"); @@ -223,8 +223,8 @@ namespace { // test sync delete vector deleteDataItems; DataItem dataItem1 = dataItem; - dataItem1.timeStamp++; - dataItem1.writeTimeStamp = dataItem1.timeStamp; + dataItem1.timestamp++; + dataItem1.writeTimestamp = dataItem1.timestamp; dataItem1.flag = 1; DistributedDBToolsUnitTest::CalcHash(dataItem.key, dataItem1.key); deleteDataItems.push_back(dataItem1); @@ -677,11 +677,11 @@ HWTEST_F(DistributedDBStorageRegisterObserverTest, RegisterObserver013, TestSize return; } -static void PreSyncDataForRegisterObserver014(TimeStamp time, vector &dataItems) +static void PreSyncDataForRegisterObserver014(Timestamp time, vector &dataItems) { // sync data - DataItem dataItem = {g_entry1.key, g_entry1.value, .timeStamp = ++time, .flag = 1}; - dataItem.writeTimeStamp = dataItem.timeStamp; + DataItem dataItem = {g_entry1.key, g_entry1.value, .timestamp = ++time, .flag = 1}; + dataItem.writeTimestamp = dataItem.timestamp; DistributedDBToolsUnitTest::CalcHash(g_entry1.key, dataItem.key); dataItems.push_back(dataItem); @@ -725,8 +725,8 @@ HWTEST_F(DistributedDBStorageRegisterObserverTest, RegisterObserver014, TestSize g_singleVerNaturaStoreConnection->Put(opt, g_oldEntry3.key, g_oldEntry3.value); g_singleVerNaturaStoreConnection->Put(opt, g_oldEntry4.key, g_oldEntry4.value); // get max time - TimeStamp time; - g_singleVerNaturaStore->GetMaxTimeStamp(time); + Timestamp time; + g_singleVerNaturaStore->GetMaxTimestamp(time); std::this_thread::sleep_for(std::chrono::milliseconds(OBSERVER_SLEEP_TIME)); /** diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp index 889ffe032..4ca1b1b46 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp @@ -53,16 +53,16 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::GetSyncData001(SQLiteSin */ IOption option; option.dataType = IOption::SYNC_DATA; - TimeStamp timeBegin; - store->GetMaxTimeStamp(timeBegin); + Timestamp timeBegin; + store->GetMaxTimestamp(timeBegin); Key key1; Value value1; DistributedDBToolsUnitTest::GetRandomKeyValue(key1); DistributedDBToolsUnitTest::GetRandomKeyValue(value1); EXPECT_EQ(connection->Put(option, key1, value1), E_OK); - TimeStamp timeEnd; - store->GetMaxTimeStamp(timeEnd); + Timestamp timeEnd; + store->GetMaxTimestamp(timeEnd); EXPECT_GT(timeEnd, timeBegin); std::vector vect; @@ -101,8 +101,8 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::GetSyncData002(SQLiteSin DistributedDBToolsUnitTest::GetRandomKeyValue(value); EXPECT_EQ(connection->Put(option, key, value), E_OK); - TimeStamp timestamp; - store->GetMaxTimeStamp(timestamp); + Timestamp timestamp; + store->GetMaxTimestamp(timestamp); std::vector vect; ContinueToken token = nullptr; @@ -131,8 +131,8 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::GetSyncData003(SQLiteSin */ IOption option; option.dataType = IOption::SYNC_DATA; - TimeStamp timeBegin = 1000; // random - TimeStamp timeEnd = 700; // random + Timestamp timeBegin = 1000; // random + Timestamp timeEnd = 700; // random std::vector vect; ContinueToken token = nullptr; SyncInputArg inputArg1(timeBegin, timeEnd, MAX_TEST_VAL_SIZE); @@ -142,14 +142,14 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::GetSyncData003(SQLiteSin SyncInputArg inputArg2(timeBegin, timeEnd, MAX_TEST_VAL_SIZE); EXPECT_EQ(DistributedDBToolsUnitTest::GetSyncDataTest(inputArg2, store, vect, token), -E_INVALID_ARGS); - store->GetMaxTimeStamp(timeBegin); + store->GetMaxTimestamp(timeBegin); Key key1; Value value1; DistributedDBToolsUnitTest::GetRandomKeyValue(key1); DistributedDBToolsUnitTest::GetRandomKeyValue(value1); EXPECT_EQ(connection->Put(option, key1, value1), E_OK); - store->GetMaxTimeStamp(timeEnd); + store->GetMaxTimestamp(timeEnd); SyncInputArg inputArg3(timeEnd, timeBegin, MAX_TEST_VAL_SIZE); EXPECT_EQ(DistributedDBToolsUnitTest::GetSyncDataTest(inputArg3, store, vect, token), -E_INVALID_ARGS); @@ -178,8 +178,8 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::GetSyncData004(SQLiteSin EXPECT_EQ(connection->Put(option, key, value), E_OK); } - TimeStamp timestamp = 0; - store->GetMaxTimeStamp(timestamp); + Timestamp timestamp = 0; + store->GetMaxTimestamp(timestamp); /** * @tc.steps:step1. Obtain the data within the time stamp range @@ -241,8 +241,8 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::GetSyncData005(SQLiteSin EXPECT_EQ(connection->Put(option, key, value), E_OK); } - TimeStamp timestamp = 0; - store->GetMaxTimeStamp(timestamp); + Timestamp timestamp = 0; + store->GetMaxTimestamp(timestamp); ContinueToken token = nullptr; std::vector dataItems; @@ -277,8 +277,8 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::GetSyncData006(SQLiteSin IOption option; option.dataType = IOption::SYNC_DATA; EXPECT_EQ(connection->Put(option, key, value), E_OK); - TimeStamp timestamp = 0; - store->GetMaxTimeStamp(timestamp); + Timestamp timestamp = 0; + store->GetMaxTimestamp(timestamp); ContinueToken token = nullptr; std::vector dataItems; @@ -308,8 +308,8 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::PutSyncData001(SQLiteSin { IOption option; option.dataType = IOption::SYNC_DATA; - TimeStamp timeBegin; - store->GetMaxTimeStamp(timeBegin); + Timestamp timeBegin; + store->GetMaxTimestamp(timeBegin); Key key1; Value value1; DistributedDBToolsUnitTest::GetRandomKeyValue(key1, 13); // random size @@ -319,23 +319,23 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::PutSyncData001(SQLiteSin * @tc.steps:step1/2. Set Ioption to synchronous data and insert a (key1, value1) data record by put interface. */ EXPECT_EQ(connection->Put(option, key1, value1), E_OK); - TimeStamp timeEnd; - store->GetMaxTimeStamp(timeEnd); + Timestamp timeEnd; + store->GetMaxTimestamp(timeEnd); EXPECT_GT(timeEnd, timeBegin); DataItem item1; std::vector vect; item1.key = key1; DistributedDBToolsUnitTest::GetRandomKeyValue(item1.value, 18); // random size - item1.timeStamp = timeBegin; - item1.writeTimeStamp = item1.timeStamp; + item1.timestamp = timeBegin; + item1.writeTimestamp = item1.timestamp; item1.flag = 0; vect.push_back(item1); /** - * @tc.steps:step3. Insert a (key1, value2!=value1, timeStamp, false) data record - * through the PutSyncData interface. The value of timeStamp is less than or equal - * to the value of timeStamp. For Compare the timestamp to determine whether to synchronization data. + * @tc.steps:step3. Insert a (key1, value2!=value1, timestamp, false) data record + * through the PutSyncData interface. The value of timestamp is less than or equal + * to the value of timestamp. For Compare the timestamp to determine whether to synchronization data. * @tc.expected: step3. Return OK. */ EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(store, vect, "deviceB"), E_OK); @@ -349,15 +349,15 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::PutSyncData001(SQLiteSin EXPECT_EQ(connection->Get(option, key1, valueRead), E_OK); EXPECT_EQ(DistributedDBToolsUnitTest::IsValueEqual(valueRead, value1), true); - item1.timeStamp = timeEnd + 1; - item1.writeTimeStamp = item1.timeStamp; + item1.timestamp = timeEnd + 1; + item1.writeTimestamp = item1.timestamp; vect.clear(); vect.push_back(item1); /** - * @tc.steps:step5. Insert a (key1, value3!=value1, timeStamp, false) data record - * through the PutSyncData interface of the NaturalStore. The value of timeStamp - * is greater than that of timeStamp inserted in 2. + * @tc.steps:step5. Insert a (key1, value3!=value1, timestamp, false) data record + * through the PutSyncData interface of the NaturalStore. The value of timestamp + * is greater than that of timestamp inserted in 2. * @tc.expected: step5. Return OK. */ EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(store, vect, "deviceB"), E_OK); @@ -403,8 +403,8 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::PutSyncData002(SQLiteSin { IOption option; option.dataType = IOption::SYNC_DATA; - TimeStamp timeBegin; - store->GetMaxTimeStamp(timeBegin); + Timestamp timeBegin; + store->GetMaxTimestamp(timeBegin); Key key1; Value value1; DistributedDBToolsUnitTest::GetRandomKeyValue(key1, 37); // random size @@ -414,23 +414,23 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::PutSyncData002(SQLiteSin * @tc.steps:step1/2. Set Ioption to synchronous data and insert a (key1, value1) data record by put interface. */ EXPECT_EQ(connection->Put(option, key1, value1), E_OK); - TimeStamp timeEnd; - store->GetMaxTimeStamp(timeEnd); + Timestamp timeEnd; + store->GetMaxTimestamp(timeEnd); EXPECT_GT(timeEnd, timeBegin); DataItem item1; std::vector vect; item1.key = key1; DistributedDBToolsUnitTest::GetRandomKeyValue(item1.value, 18); // random size - item1.timeStamp = timeBegin; - item1.writeTimeStamp = item1.timeStamp; + item1.timestamp = timeBegin; + item1.writeTimestamp = item1.timestamp; item1.flag = 1; DistributedDBToolsUnitTest::CalcHash(key1, item1.key); vect.push_back(item1); /** - * @tc.steps:step3. Insert a (key1, value2!=value1, timeStamp, false) data record - * through the PutSyncData interface. The value of timeStamp is less than or equal - * to the value of timeStamp. For Compare the timestamp to determine whether delete data. + * @tc.steps:step3. Insert a (key1, value2!=value1, timestamp, false) data record + * through the PutSyncData interface. The value of timestamp is less than or equal + * to the value of timestamp. For Compare the timestamp to determine whether delete data. * @tc.expected: step3. Return OK. */ EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(store, vect, "deviceB"), E_OK); @@ -444,15 +444,15 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::PutSyncData002(SQLiteSin EXPECT_EQ(connection->Get(option, key1, valueRead), E_OK); EXPECT_EQ(DistributedDBToolsUnitTest::IsValueEqual(valueRead, value1), true); - item1.timeStamp = timeEnd + 1; - item1.writeTimeStamp = item1.timeStamp; + item1.timestamp = timeEnd + 1; + item1.writeTimestamp = item1.timestamp; vect.clear(); vect.push_back(item1); /** - * @tc.steps:step5. Insert a (key1, value3!=value1, timeStamp, false) data record - * through the PutSyncData interfac. The value of timeStamp - * is greater than that of timeStamp inserted in step2. + * @tc.steps:step5. Insert a (key1, value3!=value1, timestamp, false) data record + * through the PutSyncData interfac. The value of timestamp + * is greater than that of timestamp inserted in step2. * @tc.expected: step5. Return OK. */ EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(store, vect, "deviceB"), E_OK); @@ -487,18 +487,18 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::PutSyncData003(SQLiteSin { IOption option; option.dataType = IOption::SYNC_DATA; - TimeStamp timeBegin; - store->GetMaxTimeStamp(timeBegin); + Timestamp timeBegin; + store->GetMaxTimestamp(timeBegin); DataItem dataItem1; DataItem dataItem2; DistributedDBToolsUnitTest::GetRandomKeyValue(dataItem1.key, 23); // random size DistributedDBToolsUnitTest::GetRandomKeyValue(dataItem2.key, 15); // random size DistributedDBToolsUnitTest::GetRandomKeyValue(dataItem1.value); DistributedDBToolsUnitTest::GetRandomKeyValue(dataItem2.value); - dataItem1.timeStamp = timeBegin + 1; // ensure bigger timeStamp - dataItem1.writeTimeStamp = dataItem1.timeStamp; - dataItem2.timeStamp = timeBegin + 2; // ensure bigger timeStamp - dataItem2.writeTimeStamp = dataItem2.timeStamp; + dataItem1.timestamp = timeBegin + 1; // ensure bigger timestamp + dataItem1.writeTimestamp = dataItem1.timestamp; + dataItem2.timestamp = timeBegin + 2; // ensure bigger timestamp + dataItem2.writeTimestamp = dataItem2.timestamp; dataItem1.flag = dataItem2.flag = 0; /** @@ -530,8 +530,8 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::PutSyncData003(SQLiteSin DataItem dataItem4 = dataItem1; dataItem4.flag = 1; - dataItem4.timeStamp += 1; - dataItem4.writeTimeStamp = dataItem4.timeStamp; + dataItem4.timestamp += 1; + dataItem4.writeTimestamp = dataItem4.timestamp; DistributedDBToolsUnitTest::CalcHash(dataItem1.key, dataItem4.key); vect = {dataItem4, dataItem3}; EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(store, vect, "deviceB"), E_OK); @@ -602,27 +602,27 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::DeleteMetaData001(SQLite } /** - * @tc.name: GetCurrentMaxTimeStamp001 + * @tc.name: GetCurrentMaxTimestamp001 * @tc.desc: To test the function of obtaining the maximum timestamp when a record exists in the database. * @tc.type: FUNC * @tc.require: AR000CCPOM * @tc.author: wangbingquan */ -void DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimeStamp001(SQLiteSingleVerNaturalStore *&store, +void DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimestamp001(SQLiteSingleVerNaturalStore *&store, SQLiteSingleVerNaturalStoreConnection *&connection) { Key key1; Value value1; DistributedDBToolsUnitTest::GetRandomKeyValue(key1); DistributedDBToolsUnitTest::GetRandomKeyValue(value1); - TimeStamp timeBegin = 0; - TimeStamp timeMiddle = 0; - TimeStamp timeEnd = 0; + Timestamp timeBegin = 0; + Timestamp timeMiddle = 0; + Timestamp timeEnd = 0; /** * @tc.steps:step1/2. Insert a data record into the synchronization database. */ - store->GetMaxTimeStamp(timeBegin); + store->GetMaxTimestamp(timeBegin); IOption option; option.dataType = IOption::SYNC_DATA; EXPECT_EQ(connection->Put(option, key1, value1), E_OK); @@ -630,7 +630,7 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimeStamp00 /** * @tc.steps:step3. The current maximum timestamp is A. */ - store->GetMaxTimeStamp(timeMiddle); + store->GetMaxTimestamp(timeMiddle); EXPECT_GT(timeMiddle, timeBegin); /** @@ -642,25 +642,25 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimeStamp00 * @tc.steps:step5. Obtain the maximum timestamp B and check whether B>=A exists. * @tc.expected: step5. The obtained timestamp is B>=A. */ - store->GetMaxTimeStamp(timeEnd); + store->GetMaxTimestamp(timeEnd); EXPECT_GT(timeEnd, timeMiddle); } /** - * @tc.name: GetCurrentMaxTimeStamp002 + * @tc.name: GetCurrentMaxTimestamp002 * @tc.desc: Obtain the maximum timestamp when no record exists in the test record library. * @tc.type: FUNC * @tc.require: AR000CCPOM * @tc.author: wangbingquan */ -void DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimeStamp002(SQLiteSingleVerNaturalStore *&store) +void DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimestamp002(SQLiteSingleVerNaturalStore *&store) { /** * @tc.steps:step1. Obtains the maximum timestamp in the current database record. * @tc.expected: step1. Return timestamp is 0. */ - TimeStamp timestamp = 10; // non-zero - store->GetMaxTimeStamp(timestamp); + Timestamp timestamp = 10; // non-zero + store->GetMaxTimestamp(timestamp); EXPECT_EQ(timestamp, 0UL); } @@ -739,8 +739,8 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::SyncDatabaseOperate002(S DataItem dataItem1; DistributedDBToolsUnitTest::GetRandomKeyValue(dataItem1.key); DistributedDBToolsUnitTest::GetRandomKeyValue(dataItem1.value); - dataItem1.timeStamp = 1001; // 1001 as random timestamp - dataItem1.writeTimeStamp = dataItem1.timeStamp; + dataItem1.timestamp = 1001; // 1001 as random timestamp + dataItem1.writeTimestamp = dataItem1.timestamp; dataItem1.flag = 0; /** @@ -804,8 +804,8 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::SyncDatabaseOperate004(S DataItem dataItem1; DistributedDBToolsUnitTest::GetRandomKeyValue(dataItem1.key); DistributedDBToolsUnitTest::GetRandomKeyValue(dataItem1.value); - dataItem1.timeStamp = 1997; // 1997 as random timestamp - dataItem1.writeTimeStamp = dataItem1.timeStamp; + dataItem1.timestamp = 1997; // 1997 as random timestamp + dataItem1.writeTimestamp = dataItem1.timestamp; dataItem1.flag = 0; std::vector vect = {dataItem1}; @@ -924,15 +924,15 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::ClearRemoteData001(SQLit DataItem dataItem1; DistributedDBToolsUnitTest::GetRandomKeyValue(dataItem1.key); DistributedDBToolsUnitTest::GetRandomKeyValue(dataItem1.value); - dataItem1.timeStamp = 1997; // 1997 as random timestamp - dataItem1.writeTimeStamp = dataItem1.timeStamp; + dataItem1.timestamp = 1997; // 1997 as random timestamp + dataItem1.writeTimestamp = dataItem1.timestamp; dataItem1.flag = 0; DataItem dataItem2; DistributedDBToolsUnitTest::GetRandomKeyValue(dataItem2.key, dataItem1.key.size() + 1); DistributedDBToolsUnitTest::GetRandomKeyValue(dataItem2.value); - dataItem2.timeStamp = 2019; // 2019 as random timestamp - dataItem2.writeTimeStamp = dataItem2.timeStamp; + dataItem2.timestamp = 2019; // 2019 as random timestamp + dataItem2.writeTimestamp = dataItem2.timestamp; dataItem2.flag = 0; /** @@ -1140,21 +1140,21 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::DeleteUserKeyValue003(SQ Value valueRead; EXPECT_NE(connection->Get(option, KEY_1, valueRead), E_OK); - TimeStamp timeStamp = 0; - store->GetMaxTimeStamp(timeStamp); + Timestamp timestamp = 0; + store->GetMaxTimestamp(timestamp); DataItem dataItem1; dataItem1.key = KV_ENTRY_1.key; dataItem1.value = KV_ENTRY_3.value; - dataItem1.timeStamp = timeStamp - 100UL; // less than current timeStamp - dataItem1.writeTimeStamp = dataItem1.timeStamp; + dataItem1.timestamp = timestamp - 100UL; // less than current timestamp + dataItem1.writeTimestamp = dataItem1.timestamp; dataItem1.flag = 0; DataItem dataItem2; dataItem2.key = KV_ENTRY_1.key; dataItem2.value = KV_ENTRY_4.value; - dataItem2.timeStamp = timeStamp + 100UL; // bigger than current timeStamp - dataItem2.writeTimeStamp = dataItem2.timeStamp; + dataItem2.timestamp = timestamp + 100UL; // bigger than current timestamp + dataItem2.writeTimestamp = dataItem2.timestamp; dataItem2.flag = 0; std::vector vect = {dataItem1}; @@ -1212,10 +1212,10 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::DeleteUserKeyValue004(SQ DataItem dataItem1; dataItem1.key = KV_ENTRY_1.key; dataItem1.value = KV_ENTRY_1.value; - store->GetMaxTimeStamp(dataItem1.timeStamp); + store->GetMaxTimestamp(dataItem1.timestamp); dataItem1.flag = 1; - dataItem1.timeStamp += 1; - dataItem1.writeTimeStamp = dataItem1.timeStamp; + dataItem1.timestamp += 1; + dataItem1.writeTimestamp = dataItem1.timestamp; /** * @tc.steps: step1 2 3. Synchronize data to another device B; delete key1 data from device B; * pull the action of key1 to local. @@ -1261,10 +1261,10 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::MemoryDbDeleteUserKeyVal DataItem dataItem1; dataItem1.key = KV_ENTRY_1.key; dataItem1.value = KV_ENTRY_1.value; - store->GetMaxTimeStamp(dataItem1.timeStamp); + store->GetMaxTimestamp(dataItem1.timestamp); dataItem1.flag = 1; - dataItem1.timeStamp += 1; - dataItem1.writeTimeStamp = dataItem1.timeStamp; + dataItem1.timestamp += 1; + dataItem1.writeTimestamp = dataItem1.timestamp; /** * @tc.steps: step1 2 3. Synchronize data to another device B; delete key1 data from device B; * pull the action of key1 to local. @@ -1308,9 +1308,9 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::DeleteUserKeyValue005(SQ DataItem dataItem1; dataItem1.key = KV_ENTRY_1.key; dataItem1.value = KV_ENTRY_1.value; - store->GetMaxTimeStamp(dataItem1.timeStamp); - dataItem1.timeStamp = dataItem1.timeStamp + 10UL; - dataItem1.writeTimeStamp = dataItem1.timeStamp; + store->GetMaxTimestamp(dataItem1.timestamp); + dataItem1.timestamp = dataItem1.timestamp + 10UL; + dataItem1.writeTimestamp = dataItem1.timestamp; dataItem1.flag = 1; /** @@ -1365,9 +1365,9 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::MemoryDbDeleteUserKeyVal DataItem dataItem1; dataItem1.key = KV_ENTRY_1.key; dataItem1.value = KV_ENTRY_1.value; - store->GetMaxTimeStamp(dataItem1.timeStamp); - dataItem1.timeStamp = TimeHelper::GetSysCurrentTime(); - dataItem1.writeTimeStamp = dataItem1.timeStamp; + store->GetMaxTimestamp(dataItem1.timestamp); + dataItem1.timestamp = TimeHelper::GetSysCurrentTime(); + dataItem1.writeTimestamp = dataItem1.timestamp; dataItem1.flag = 1; /** @@ -1419,9 +1419,9 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::DeleteUserKeyValue006(SQ DataItem dataItem1; dataItem1.key = KV_ENTRY_1.key; dataItem1.value = KV_ENTRY_1.value; - store->GetMaxTimeStamp(dataItem1.timeStamp); - dataItem1.timeStamp = dataItem1.timeStamp + 10UL; - dataItem1.writeTimeStamp = dataItem1.timeStamp; + store->GetMaxTimestamp(dataItem1.timestamp); + dataItem1.timestamp = dataItem1.timestamp + 10UL; + dataItem1.writeTimestamp = dataItem1.timestamp; dataItem1.flag = 1; /** @@ -1441,8 +1441,8 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::DeleteUserKeyValue006(SQ dataItem1.key = KV_ENTRY_1.key; dataItem1.flag = 0; dataItem1.value = KV_ENTRY_2.value; - dataItem1.timeStamp = dataItem1.timeStamp - 100UL; // less than current timeStamp - dataItem1.writeTimeStamp = dataItem1.timeStamp; + dataItem1.timestamp = dataItem1.timestamp - 100UL; // less than current timestamp + dataItem1.writeTimestamp = dataItem1.timestamp; /** * @tc.steps: step3. Remote device C syncs new data (key1, value2), * timestamp is less than delete timestamp, to local. @@ -1457,8 +1457,8 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::DeleteUserKeyValue006(SQ EXPECT_NE(connection->Get(option, KEY_1, valueRead), E_OK); dataItem1.value = KV_ENTRY_3.value; - dataItem1.timeStamp = dataItem1.timeStamp + 200UL; // bigger than current timeStamp - dataItem1.writeTimeStamp = dataItem1.timeStamp; + dataItem1.timestamp = dataItem1.timestamp + 200UL; // bigger than current timestamp + dataItem1.writeTimestamp = dataItem1.timestamp; /** * @tc.steps: step5. Remote device C syncs new data (key1, value2), * timestamp is bigger than delete timestamp, to local. @@ -1559,7 +1559,7 @@ int DistributedDBStorageSingleVerNaturalStoreTestCase::GetRawSyncData(const std: stuSyncData.value.assign(blobValue, blobValue + valueLength); } - stuSyncData.timeStamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_TIME_INDEX)); + stuSyncData.timestamp = static_cast(sqlite3_column_int64(statement, SYNC_RES_TIME_INDEX)); stuSyncData.flag = sqlite3_column_int64(statement, SYNC_RES_FLAG_INDEX); vecSyncData.push_back(stuSyncData); } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.h b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.h index f5461f27d..148fd14dc 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.h +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.h @@ -29,7 +29,7 @@ struct SyncData { std::vector hashKey; std::vector key; std::vector value; - uint64_t timeStamp; + uint64_t timestamp; uint64_t flag; std::string deviceInfo; }; @@ -75,10 +75,10 @@ public: static void DeleteMetaData001(DistributedDB::SQLiteSingleVerNaturalStore *&store, DistributedDB::SQLiteSingleVerNaturalStoreConnection *&connection); - static void GetCurrentMaxTimeStamp001(DistributedDB::SQLiteSingleVerNaturalStore *&store, + static void GetCurrentMaxTimestamp001(DistributedDB::SQLiteSingleVerNaturalStore *&store, DistributedDB::SQLiteSingleVerNaturalStoreConnection *&connection); - static void GetCurrentMaxTimeStamp002(DistributedDB::SQLiteSingleVerNaturalStore *&store); + static void GetCurrentMaxTimestamp002(DistributedDB::SQLiteSingleVerNaturalStore *&store); static void LocalDatabaseOperate001(DistributedDB::SQLiteSingleVerNaturalStore *&store, DistributedDB::SQLiteSingleVerNaturalStoreConnection *&connection); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_upgrade_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_upgrade_test.cpp index 5d4e4c874..b5b311cef 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_upgrade_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_upgrade_test.cpp @@ -186,7 +186,7 @@ namespace { ASSERT_EQ(SQLiteUtils::GetStatement(db, CHECK_V1_LOCAL_UPGRADE, statement), E_OK); ASSERT_NE(statement, nullptr); ASSERT_EQ(SQLiteUtils::StepWithRetry(statement), SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)); - TimeStamp stamp = static_cast(sqlite3_column_int64(statement, 0)); + Timestamp stamp = static_cast(sqlite3_column_int64(statement, 0)); EXPECT_NE(stamp, 0UL); Value readHashValue; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_sqlite_single_ver_natural_store_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_sqlite_single_ver_natural_store_test.cpp index f941f0ef4..51150eab7 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_sqlite_single_ver_natural_store_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_sqlite_single_ver_natural_store_test.cpp @@ -215,9 +215,9 @@ HWTEST_F(DistributedDBStorageSQLiteSingleVerNaturalStoreTest, PutSyncData001, Te * @tc.steps:step1/2. Set Ioption to synchronous data and insert a (key1, value1) data record by put interface. */ /** - * @tc.steps:step3. Insert a (key1, value2!=value1, timeStamp, false) data record - * through the PutSyncData interface. The value of timeStamp is less than or equal - * to the value of timeStamp. For Compare the timestamp to determine whether to synchronization data. + * @tc.steps:step3. Insert a (key1, value2!=value1, timestamp, false) data record + * through the PutSyncData interface. The value of timestamp is less than or equal + * to the value of timestamp. For Compare the timestamp to determine whether to synchronization data. * @tc.expected: step3. Return OK. */ /** @@ -226,9 +226,9 @@ HWTEST_F(DistributedDBStorageSQLiteSingleVerNaturalStoreTest, PutSyncData001, Te * @tc.expected: step4. Return OK.The obtained value is value1. */ /** - * @tc.steps:step5. Insert a (key1, value3!=value1, timeStamp, false) data record - * through the PutSyncData interface of the NaturalStore. The value of timeStamp - * is greater than that of timeStamp inserted in 2. + * @tc.steps:step5. Insert a (key1, value3!=value1, timestamp, false) data record + * through the PutSyncData interface of the NaturalStore. The value of timestamp + * is greater than that of timestamp inserted in 2. * @tc.expected: step5. Return OK. */ /** @@ -262,9 +262,9 @@ HWTEST_F(DistributedDBStorageSQLiteSingleVerNaturalStoreTest, PutSyncData002, Te * @tc.steps:step1/2. Set Ioption to synchronous data and insert a (key1, value1) data record by put interface. */ /** - * @tc.steps:step3. Insert a (key1, value2!=value1, timeStamp, false) data record - * through the PutSyncData interface. The value of timeStamp is less than or equal - * to the value of timeStamp. For Compare the timestamp to determine whether delete data. + * @tc.steps:step3. Insert a (key1, value2!=value1, timestamp, false) data record + * through the PutSyncData interface. The value of timestamp is less than or equal + * to the value of timestamp. For Compare the timestamp to determine whether delete data. * @tc.expected: step3. Return OK. */ /** @@ -273,9 +273,9 @@ HWTEST_F(DistributedDBStorageSQLiteSingleVerNaturalStoreTest, PutSyncData002, Te * @tc.expected: step4. Return OK.The obtained value is value1. */ /** - * @tc.steps:step5. Insert a (key1, value3!=value1, timeStamp, false) data record - * through the PutSyncData interfac. The value of timeStamp - * is greater than that of timeStamp inserted in step2. + * @tc.steps:step5. Insert a (key1, value3!=value1, timestamp, false) data record + * through the PutSyncData interfac. The value of timestamp + * is greater than that of timestamp inserted in step2. * @tc.expected: step5. Return OK. */ /** @@ -451,13 +451,13 @@ HWTEST_F(DistributedDBStorageSQLiteSingleVerNaturalStoreTest, DeleteMetaData001, /** - * @tc.name: GetCurrentMaxTimeStamp001 + * @tc.name: GetCurrentMaxTimestamp001 * @tc.desc: To test the function of obtaining the maximum timestamp when a record exists in the database. * @tc.type: FUNC * @tc.require: AR000CCPOM * @tc.author: wangbingquan */ -HWTEST_F(DistributedDBStorageSQLiteSingleVerNaturalStoreTest, GetCurrentMaxTimeStamp001, TestSize.Level1) +HWTEST_F(DistributedDBStorageSQLiteSingleVerNaturalStoreTest, GetCurrentMaxTimestamp001, TestSize.Level1) { /** * @tc.steps:step1/2. Insert a data record into the synchronization database. @@ -472,23 +472,23 @@ HWTEST_F(DistributedDBStorageSQLiteSingleVerNaturalStoreTest, GetCurrentMaxTimeS * @tc.steps:step5. Obtain the maximum timestamp B and check whether B>=A exists. * @tc.expected: step5. The obtained timestamp is B>=A. */ - DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimeStamp001(g_store, g_connection); + DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimestamp001(g_store, g_connection); } /** - * @tc.name: GetCurrentMaxTimeStamp002 + * @tc.name: GetCurrentMaxTimestamp002 * @tc.desc: Obtain the maximum timestamp when no record exists in the test record library. * @tc.type: FUNC * @tc.require: AR000CCPOM * @tc.author: wangbingquan */ -HWTEST_F(DistributedDBStorageSQLiteSingleVerNaturalStoreTest, GetCurrentMaxTimeStamp002, TestSize.Level1) +HWTEST_F(DistributedDBStorageSQLiteSingleVerNaturalStoreTest, GetCurrentMaxTimestamp002, TestSize.Level1) { /** * @tc.steps:step1. Obtains the maximum timestamp in the current database record. * @tc.expected: step1. Return timestamp is 0. */ - DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimeStamp002(g_store); + DistributedDBStorageSingleVerNaturalStoreTestCase::GetCurrentMaxTimestamp002(g_store); } /** diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp index cb70d93b6..7d7fc9162 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp @@ -381,7 +381,7 @@ HWTEST_F(DistributedDBStorageSubscribeQueryTest, PutSyncDataTestWithQuery, TestS */ Key key; Value value; - TimeStamp now = store->GetCurrentTimeStamp(); + Timestamp now = store->GetCurrentTimestamp(); LOGD("now time is : %ld", now); std::vector data; for (uint8_t i = 0; i < PRESET_DATA_SIZE; i++) { @@ -431,7 +431,7 @@ HWTEST_F(DistributedDBStorageSubscribeQueryTest, PutSyncDataTestWithQuery002, Te Key key({'K', 'e', 'y'}); Value value; - TimeStamp now = store->GetCurrentTimeStamp(); + Timestamp now = store->GetCurrentTimestamp(); /** * @tc.steps:step2. put sync data * @tc.expected: OK @@ -489,7 +489,7 @@ HWTEST_F(DistributedDBStorageSubscribeQueryTest, PutSyncDataTestWithQuery003, Te Key key({'K', 'e', 'y'}); Value value; - TimeStamp now = store->GetCurrentTimeStamp(); + Timestamp now = store->GetCurrentTimestamp(); /** * @tc.steps:step2. put sync data * @tc.expected: OK @@ -545,7 +545,7 @@ HWTEST_F(DistributedDBStorageSubscribeQueryTest, PutSyncDataTestWithQuery004, Te Key key({'K', 'e', 'y'}); Value value; - TimeStamp now = store->GetCurrentTimeStamp(); + Timestamp now = store->GetCurrentTimestamp(); /** * @tc.steps:step2. put sync data * @tc.expected: OK diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp index 4c19de1d0..ff08d251b 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp @@ -128,7 +128,7 @@ static uint64_t GetCommitTimestamp(const CommitID& commitId) if (commitStorage == nullptr) { return 0; } - TimeStamp timestamp = INVALID_TIMESTAMP; + Timestamp timestamp = INVALID_TIMESTAMP; CommitID newCommitId; IKvDBCommit *commit = nullptr; IKvDBCommitStorage::Property property; @@ -1092,7 +1092,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, DefaultConflictResolution002, /** * @tc.steps: step2. Get latest timestamp */ - TimeStamp t1 = GetMaxTimestamp(); + Timestamp t1 = GetMaxTimestamp(); EXPECT_TRUE(t1 > 0); /** * @tc.steps: step3. Put the external entry[KEY_2,VALUE_4,T2] into the database. @@ -1188,8 +1188,8 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, DefaultConflictResolution003, /** * @tc.steps: step2. Get timestampV1 */ - TimeStamp timestampV1 = GetMaxTimestamp(); - TimeStamp timestampClear = timestampV1 + 1; + Timestamp timestampV1 = GetMaxTimestamp(); + Timestamp timestampClear = timestampV1 + 1; std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_TIME)); /** * @tc.steps: step3. Put the local data(KEY_2, VALUE_2) into the database. @@ -1199,7 +1199,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, DefaultConflictResolution003, /** * @tc.steps: step4. Get timestampV2 */ - TimeStamp timestampV2 = GetMaxTimestamp(); + Timestamp timestampV2 = GetMaxTimestamp(); /** * @tc.steps: step5. Put the external clear entry into the database. * @tc.expected: step5. Put returns E_OK @@ -1236,7 +1236,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, DefaultConflictResolution004, * @tc.expected: step1. Put returns E_OK. */ PutAndCommitEntry(KEY_1, VALUE_1); - TimeStamp t1 = GetMaxTimestamp(); + Timestamp t1 = GetMaxTimestamp(); EXPECT_TRUE(t1 > 0); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_TIME)); /** @@ -1244,13 +1244,13 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, DefaultConflictResolution004, * @tc.expected: step2. Put returns E_OK. */ PutAndCommitEntry(KEY_2, VALUE_2); - TimeStamp t2 = GetMaxTimestamp(); + Timestamp t2 = GetMaxTimestamp(); /** * @tc.steps: step3. Execute Clear() operation and get the latest timestamp. */ IOption option; g_naturalStoreConnection->Clear(option); - TimeStamp t3 = GetMaxTimestamp(); + Timestamp t3 = GetMaxTimestamp(); EXPECT_TRUE(t3 > 0); /** * @tc.steps: step4. Put the local data(KEY_3, VALUE_3) into the database and get the latest timestamp. @@ -1335,7 +1335,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp001, TestSize.L ASSERT_EQ(timeSet.size(), 1UL); // only one timestamp in one commit. // Tobe compare the timestamp. CommitID commitId; - TimeStamp commitTimestamp = GetCommitTimestamp(commitId); + Timestamp commitTimestamp = GetCommitTimestamp(commitId); LOGD("TimeRecord:%" PRIu64 ", TimeCommit:%" PRIu64, *(timeSet.begin()), commitTimestamp); ASSERT_EQ(*(timeSet.begin()), commitTimestamp); ASSERT_NE(commitTimestamp, 0UL); @@ -1434,7 +1434,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp002, TestSize.L EXPECT_EQ(g_naturalStoreConnection->Commit(), E_OK); CommitID commitId; - TimeStamp stampFirst = GetCommitTimestamp(commitId); + Timestamp stampFirst = GetCommitTimestamp(commitId); ASSERT_NE(stampFirst, 0UL); // non-zero /** @@ -1447,7 +1447,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp002, TestSize.L * @tc.steps: step3. Check the timestamp of the two commits. * @tc.expected: step3. the timestamp of the second commit is greater than the timestamp of the first commit. */ - TimeStamp stampSecond = GetCommitTimestamp(commitId); + Timestamp stampSecond = GetCommitTimestamp(commitId); ASSERT_NE(stampSecond, 0UL); // non-zero LOGD("TimeFirst:%" PRIu64 ", TimeSecond:%" PRIu64, stampFirst, stampSecond); ASSERT_GT(stampSecond, stampFirst); @@ -1501,7 +1501,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp003, TestSize.L * @tc.steps: step3. Check the timestamp of the commit and the data. * @tc.steps: expected. the timestamp of the sync commit is equal to the timestamp of the data record. */ - TimeStamp commitTimestamp = GetCommitTimestamp(commit.commitId); + Timestamp commitTimestamp = GetCommitTimestamp(commit.commitId); LOGD("TimeRecord:%" PRIu64 ", TimeCommit:%" PRIu64, timestamp, commitTimestamp); ASSERT_EQ(timestamp, commitTimestamp); ASSERT_NE(commitTimestamp, 0UL); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp index 60fe6e2bc..cacf939fe 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp @@ -290,8 +290,8 @@ HWTEST_F(DistributedDBMockSyncModuleTest, DataSyncCheck003, TestSize.Level1) EXPECT_CALL(*mockMetadata, GetLastQueryTime(_, _, _)).WillOnce(Return(E_OK)); EXPECT_CALL(*mockMetadata, SetLastQueryTime(_, _, _)).WillOnce([&dataTimeRange](const std::string &queryIdentify, - const std::string &deviceId, const TimeStamp &timeStamp) { - EXPECT_EQ(timeStamp, dataTimeRange.endTime); + const std::string &deviceId, const Timestamp ×tamp) { + EXPECT_EQ(timestamp, dataTimeRange.endTime); return E_OK; }); EXPECT_CALL(mockSyncTaskContext, SetOperationStatus(_)).WillOnce(Return()); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_multi_ver_p2p_sync_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_multi_ver_p2p_sync_test.cpp index 5b6605ab9..08ce2c0c6 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_multi_ver_p2p_sync_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_multi_ver_p2p_sync_test.cpp @@ -604,8 +604,8 @@ HWTEST_F(DistributedDBMultiVerP2PSyncTest, IsolationSync003, TestSize.Level2) EXPECT_EQ(value, DistributedDBUnitTest::VALUE_1); } -static void SetTimeSyncPacketField(TimeSyncPacket &inPacket, TimeStamp sourceBegin, TimeStamp sourceEnd, - TimeStamp targetBegin, TimeStamp targetEnd, SyncId theId) +static void SetTimeSyncPacketField(TimeSyncPacket &inPacket, Timestamp sourceBegin, Timestamp sourceEnd, + Timestamp targetBegin, Timestamp targetEnd, SyncId theId) { inPacket.SetSourceTimeBegin(sourceBegin); inPacket.SetSourceTimeEnd(sourceEnd); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_multi_user_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_multi_user_test.cpp index 8676fb61d..24f3b2163 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_multi_user_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_multi_user_test.cpp @@ -417,7 +417,7 @@ HWTEST_F(DistributedDBSingleVerMultiUserTest, MultiUser003, TestSize.Level3) */ Key key = {'1'}; Value value = {'1'}; - TimeStamp currentTime; + Timestamp currentTime; (void)OS::GetCurrentSysTimeInMicrosecond(currentTime); EXPECT_TRUE(g_deviceB->PutData(key, value, currentTime, 0) == OK); /** @@ -486,7 +486,7 @@ HWTEST_F(DistributedDBSingleVerMultiUserTest, MultiUser004, TestSize.Level0) */ Key key = {'1'}; Value value = {'1'}; - TimeStamp currentTime; + Timestamp currentTime; (void)OS::GetCurrentSysTimeInMicrosecond(currentTime); EXPECT_TRUE(g_deviceB->PutData(key, value, currentTime, 0) == OK); /** diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp index 199e27585..7fc131bef 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp @@ -634,7 +634,7 @@ HWTEST_F(DistributedDBSingleVerP2PSyncCheckTest, AckSessionCheck001, TestSize.Le Key key = {'1'}; Value value = {'1'}; - TimeStamp currentTime; + Timestamp currentTime; (void)OS::GetCurrentSysTimeInMicrosecond(currentTime); EXPECT_TRUE(g_deviceB->PutData(key, value, currentTime, 0) == OK); EXPECT_TRUE(g_deviceB->Sync(SYNC_MODE_PUSH_ONLY, true) == OK); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp index eef31ab39..1cfde89e9 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp @@ -38,7 +38,7 @@ int KvVirtualDevice::GetData(const Key &key, Value &value) return syncInterface->GetData(key, value); } -int KvVirtualDevice::PutData(const Key &key, const Value &value, const TimeStamp &time, int flag) +int KvVirtualDevice::PutData(const Key &key, const Value &value, const Timestamp &time, int flag) { VirtualSingleVerSyncDBInterface *syncAble = static_cast(storage_); LOGI("dev %s put data time %" PRIu64, deviceId_.c_str(), time); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.h b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.h index c9172d748..220aabc4b 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.h +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.h @@ -27,7 +27,7 @@ public: int GetData(const Key &key, VirtualDataItem &item); int GetData(const Key &key, Value &value); - int PutData(const Key &key, const Value &value, const TimeStamp &time, int flag); + int PutData(const Key &key, const Value &value, const Timestamp &time, int flag); int PutData(const Key &key, const Value &value); int DeleteData(const Key &key); int StartTransaction(); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/mock_meta_data.h b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/mock_meta_data.h index 4be11ce3d..c1e83d6e1 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/mock_meta_data.h +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/mock_meta_data.h @@ -21,9 +21,9 @@ namespace DistributedDB { class MockMetadata : public Metadata { public: - MOCK_METHOD3(SetLastQueryTime, int(const std::string &, const std::string &, const TimeStamp &)); + MOCK_METHOD3(SetLastQueryTime, int(const std::string &, const std::string &, const Timestamp &)); - MOCK_METHOD3(GetLastQueryTime, int(const std::string &, const std::string &, TimeStamp &)); + MOCK_METHOD3(GetLastQueryTime, int(const std::string &, const std::string &, Timestamp &)); }; } // namespace DistributedDB #endif // #define MOCK_META_DATA_H \ No newline at end of file diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_multi_ver_sync_db_interface.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_multi_ver_sync_db_interface.cpp index fff954696..fffec2abc 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_multi_ver_sync_db_interface.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_multi_ver_sync_db_interface.cpp @@ -49,9 +49,9 @@ std::vector VirtualMultiVerSyncDBInterface::GetIdentifier() const return kvStore_->GetIdentifier(); } -void VirtualMultiVerSyncDBInterface::GetMaxTimeStamp(TimeStamp &stamp) const +void VirtualMultiVerSyncDBInterface::GetMaxTimestamp(Timestamp &stamp) const { - return kvStore_->GetMaxTimeStamp(stamp); + return kvStore_->GetMaxTimestamp(stamp); } int VirtualMultiVerSyncDBInterface::GetMetaData(const Key &key, Value &value) const diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_multi_ver_sync_db_interface.h b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_multi_ver_sync_db_interface.h index 113684c2f..e9d985be9 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_multi_ver_sync_db_interface.h +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_multi_ver_sync_db_interface.h @@ -34,7 +34,7 @@ public: std::vector GetIdentifier() const override; - void GetMaxTimeStamp(TimeStamp &stamp) const override; + void GetMaxTimestamp(Timestamp &stamp) const override; int GetMetaData(const Key &key, Value &value) const override; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.cpp index db0cf78ed..6eb516a55 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.cpp @@ -34,8 +34,8 @@ namespace { storageItem.key = item.key; storageItem.value = item.value; storageItem.flag = item.flag; - storageItem.timeStamp = item.timeStamp; - storageItem.writeTimeStamp = item.writeTimeStamp; + storageItem.timestamp = item.timestamp; + storageItem.writeTimestamp = item.writeTimestamp; storageItem.hashKey = item.hashKey; entry->SetEntryData(std::move(storageItem)); entries.push_back(entry); @@ -71,8 +71,8 @@ int VirtualRelationalVerSyncDBInterface::PutSyncDataWithQuery(const QueryObject DataItem item; item.origDev = entry->GetOrigDevice(); item.flag = entry->GetFlag(); - item.timeStamp = entry->GetTimestamp(); - item.writeTimeStamp = entry->GetWriteTimestamp(); + item.timestamp = entry->GetTimestamp(); + item.writeTimestamp = entry->GetWriteTimestamp(); entry->GetKey(item.key); entry->GetValue(item.value); entry->GetHashKey(item.hashKey); @@ -153,7 +153,7 @@ RelationalSchemaObject VirtualRelationalVerSyncDBInterface::GetSchemaInfo() cons return schemaObj_; } -int VirtualRelationalVerSyncDBInterface::GetDatabaseCreateTimeStamp(TimeStamp &outTime) const +int VirtualRelationalVerSyncDBInterface::GetDatabaseCreateTimestamp(Timestamp &outTime) const { return E_OK; } @@ -214,7 +214,7 @@ std::vector VirtualRelationalVerSyncDBInterface::GetIdentifier() const return {}; } -void VirtualRelationalVerSyncDBInterface::GetMaxTimeStamp(TimeStamp &stamp) const +void VirtualRelationalVerSyncDBInterface::GetMaxTimestamp(Timestamp &stamp) const { for (const auto &item : syncData_) { for (const auto &entry : item.second) { @@ -223,7 +223,7 @@ void VirtualRelationalVerSyncDBInterface::GetMaxTimeStamp(TimeStamp &stamp) cons } } } - LOGD("VirtualSingleVerSyncDBInterface::GetMaxTimeStamp time = %" PRIu64, stamp); + LOGD("VirtualSingleVerSyncDBInterface::GetMaxTimestamp time = %" PRIu64, stamp); } int VirtualRelationalVerSyncDBInterface::GetMetaData(const Key &key, Value &value) const diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.h b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.h index 50ec7f444..f5207c7f5 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.h +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.h @@ -47,7 +47,7 @@ public: RelationalSchemaObject GetSchemaInfo() const override; - int GetDatabaseCreateTimeStamp(TimeStamp &outTime) const override; + int GetDatabaseCreateTimestamp(Timestamp &outTime) const override; int GetBatchMetaData(const std::vector &keys, std::vector &entries) const override; @@ -69,7 +69,7 @@ public: std::vector GetIdentifier() const override; - void GetMaxTimeStamp(TimeStamp &stamp) const override; + void GetMaxTimestamp(Timestamp &stamp) const override; int GetMetaData(const Key &key, Value &value) const override; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.cpp index 9c7139d9d..4e1de4bf0 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.cpp @@ -42,8 +42,8 @@ namespace { storageItem.key = item.key; storageItem.value = item.value; storageItem.flag = item.flag; - storageItem.timeStamp = item.timeStamp; - storageItem.writeTimeStamp = item.writeTimeStamp; + storageItem.timestamp = item.timestamp; + storageItem.writeTimestamp = item.writeTimestamp; entry->SetEntryData(std::move(storageItem)); entries.push_back(entry); } @@ -112,7 +112,7 @@ int VirtualSingleVerSyncDBInterface::GetAllMetaKeys(std::vector &keys) cons return E_OK; } -int VirtualSingleVerSyncDBInterface::GetSyncData(TimeStamp begin, TimeStamp end, std::vector &dataItems, +int VirtualSingleVerSyncDBInterface::GetSyncData(Timestamp begin, Timestamp end, std::vector &dataItems, ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const { return -E_NOT_SUPPORT; @@ -142,27 +142,27 @@ bool VirtualSingleVerSyncDBInterface::CheckCompatible(const std::string& schema, return (schemaObj_.CompareAgainstSchemaString(schema) == -E_SCHEMA_EQUAL_EXACTLY); } -int VirtualSingleVerSyncDBInterface::PutData(const Key &key, const Value &value, const TimeStamp &time, int flag) +int VirtualSingleVerSyncDBInterface::PutData(const Key &key, const Value &value, const Timestamp &time, int flag) { VirtualDataItem item; item.key = key; item.value = value; - item.timeStamp = time; - item.writeTimeStamp = time; + item.timestamp = time; + item.writeTimestamp = time; item.flag = flag; item.isLocal = true; dbData_.push_back(item); return E_OK; } -void VirtualSingleVerSyncDBInterface::GetMaxTimeStamp(TimeStamp& stamp) const +void VirtualSingleVerSyncDBInterface::GetMaxTimestamp(Timestamp& stamp) const { for (auto iter = dbData_.begin(); iter != dbData_.end(); ++iter) { - if (stamp < iter->writeTimeStamp) { - stamp = iter->writeTimeStamp; + if (stamp < iter->writeTimestamp) { + stamp = iter->writeTimestamp; } } - LOGD("VirtualSingleVerSyncDBInterface::GetMaxTimeStamp time = %" PRIu64, stamp); + LOGD("VirtualSingleVerSyncDBInterface::GetMaxTimestamp time = %" PRIu64, stamp); } int VirtualSingleVerSyncDBInterface::RemoveDeviceData(const std::string &deviceName, bool isNeedNotify) @@ -177,8 +177,8 @@ int VirtualSingleVerSyncDBInterface::GetSyncData(const Key &key, VirtualDataItem if (iter != dbData_.end()) { dataItem.key = iter->key; dataItem.value = iter->value; - dataItem.timeStamp = iter->timeStamp; - dataItem.writeTimeStamp = iter->writeTimeStamp; + dataItem.timestamp = iter->timestamp; + dataItem.writeTimestamp = iter->writeTimestamp; dataItem.flag = iter->flag; dataItem.isLocal = iter->isLocal; return E_OK; @@ -186,7 +186,7 @@ int VirtualSingleVerSyncDBInterface::GetSyncData(const Key &key, VirtualDataItem return -E_NOT_FOUND; } -int VirtualSingleVerSyncDBInterface::GetSyncData(TimeStamp begin, TimeStamp end, +int VirtualSingleVerSyncDBInterface::GetSyncData(Timestamp begin, Timestamp end, std::vector &entries, ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const { @@ -208,12 +208,12 @@ int VirtualSingleVerSyncDBInterface::GetSyncDataNext(std::vector &dataItems, ContinueToken &continueStmtToken) const { for (const auto &data : dbData_) { if (data.isLocal) { - if (data.writeTimeStamp >= begin && data.writeTimeStamp < end) { + if (data.writeTimestamp >= begin && data.writeTimestamp < end) { dataItems.push_back(data); } } @@ -244,23 +244,23 @@ int VirtualSingleVerSyncDBInterface::PutSyncData(std::vector& d LOGD("PutSyncData"); auto dbDataIter = std::find_if(dbData_.begin(), dbData_.end(), [iter](VirtualDataItem item) { return item.key == iter->key; }); - if ((dbDataIter != dbData_.end()) && (dbDataIter->writeTimeStamp < iter->writeTimeStamp)) { - // if has conflict, compare writeTimeStamp - LOGI("conflict data time local %" PRIu64 ", remote %" PRIu64, dbDataIter->writeTimeStamp, - iter->writeTimeStamp); + if ((dbDataIter != dbData_.end()) && (dbDataIter->writeTimestamp < iter->writeTimestamp)) { + // if has conflict, compare writeTimestamp + LOGI("conflict data time local %" PRIu64 ", remote %" PRIu64, dbDataIter->writeTimestamp, + iter->writeTimestamp); dbDataIter->key = iter->key; dbDataIter->value = iter->value; - dbDataIter->timeStamp = iter->timeStamp; - dbDataIter->writeTimeStamp = iter->writeTimeStamp; + dbDataIter->timestamp = iter->timestamp; + dbDataIter->writeTimestamp = iter->writeTimestamp; dbDataIter->flag = iter->flag; dbDataIter->isLocal = false; } else { - LOGI("PutSyncData, use remote data %" PRIu64, iter->timeStamp); + LOGI("PutSyncData, use remote data %" PRIu64, iter->timestamp); VirtualDataItem dataItem; dataItem.key = iter->key; dataItem.value = iter->value; - dataItem.timeStamp = iter->timeStamp; - dataItem.writeTimeStamp = iter->writeTimeStamp; + dataItem.timestamp = iter->timestamp; + dataItem.writeTimestamp = iter->writeTimestamp; dataItem.flag = iter->flag; dataItem.isLocal = false; dbData_.push_back(dataItem); @@ -302,7 +302,7 @@ void VirtualSingleVerSyncDBInterface::NotifyRemotePushFinished(const std::string { } -int VirtualSingleVerSyncDBInterface::GetDatabaseCreateTimeStamp(TimeStamp &outTime) const +int VirtualSingleVerSyncDBInterface::GetDatabaseCreateTimestamp(Timestamp &outTime) const { return E_OK; } @@ -323,11 +323,11 @@ int VirtualSingleVerSyncDBInterface::GetSyncData(QueryObject &query, const SyncT } if ((data.flag & VirtualDataItem::DELETE_FLAG) != 0) { - if (data.timeStamp >= timeRange.deleteBeginTime && data.timeStamp < timeRange.deleteEndTime) { + if (data.timestamp >= timeRange.deleteBeginTime && data.timestamp < timeRange.deleteEndTime) { dataItems.push_back(data); } } else { - if (data.timeStamp >= timeRange.beginTime && data.timeStamp < timeRange.endTime && + if (data.timestamp >= timeRange.beginTime && data.timestamp < timeRange.endTime && data.key >= startKey && data.key <= endKey) { dataItems.push_back(data); } @@ -388,8 +388,8 @@ int VirtualSingleVerSyncDBInterface::PutSyncDataWithQuery(const QueryObject &que VirtualDataItem item; genericKvEntry->GetKey(item.key); genericKvEntry->GetValue(item.value); - item.timeStamp = genericKvEntry->GetTimestamp(); - item.writeTimeStamp = genericKvEntry->GetWriteTimestamp(); + item.timestamp = genericKvEntry->GetTimestamp(); + item.writeTimestamp = genericKvEntry->GetWriteTimestamp(); item.flag = genericKvEntry->GetFlag(); item.isLocal = false; dataItems.push_back(item); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.h b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.h index 988553064..240159888 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.h +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.h @@ -27,8 +27,8 @@ namespace DistributedDB { struct VirtualDataItem { Key key; Value value; - TimeStamp timeStamp = 0; - TimeStamp writeTimeStamp = 0; + Timestamp timestamp = 0; + Timestamp writeTimestamp = 0; uint64_t flag = 0; bool isLocal = true; static const uint64_t DELETE_FLAG = 0x01; @@ -54,7 +54,7 @@ public: int GetAllMetaKeys(std::vector& keys) const override; - int GetSyncData(TimeStamp begin, TimeStamp end, std::vector &dataItems, + int GetSyncData(Timestamp begin, Timestamp end, std::vector &dataItems, ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const override; int GetSyncDataNext(std::vector &dataItems, ContinueToken &continueStmtToken, @@ -62,7 +62,7 @@ public: void ReleaseContinueToken(ContinueToken& continueStmtToken) const override; - void GetMaxTimeStamp(TimeStamp& stamp) const override; + void GetMaxTimestamp(Timestamp& stamp) const override; int RemoveDeviceData(const std::string &deviceName, bool isNeedNotify) override; @@ -70,9 +70,9 @@ public: int PutSyncData(const DataItem& item); - int PutData(const Key &key, const Value &value, const TimeStamp &time, int flag); + int PutData(const Key &key, const Value &value, const Timestamp &time, int flag); - int GetSyncData(TimeStamp begin, TimeStamp end, std::vector &entries, + int GetSyncData(Timestamp begin, Timestamp end, std::vector &entries, ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const override; int GetSyncData(QueryObject &query, const SyncTimeRange &timeRange, const DataSizeSpecInfo &dataSizeInfo, @@ -102,7 +102,7 @@ public: void NotifyRemotePushFinished(const std::string &targetId) const override; - int GetDatabaseCreateTimeStamp(TimeStamp &outTime) const override; + int GetDatabaseCreateTimestamp(Timestamp &outTime) const override; int GetCompressionOption(bool &needCompressOnSync, uint8_t &compressionRate) const override; int GetCompressionAlgo(std::set &algorithmSet) const override; @@ -121,7 +121,7 @@ public: void SetBusy(bool busy); private: - int GetSyncData(TimeStamp begin, TimeStamp end, uint32_t blockSize, std::vector& dataItems, + int GetSyncData(Timestamp begin, Timestamp end, uint32_t blockSize, std::vector& dataItems, ContinueToken& continueStmtToken) const; int GetSyncDataNext(std::vector& dataItems, -- Gitee From 32192d195a30a6db96d3d40a381ee6bee915f486 Mon Sep 17 00:00:00 2001 From: lianhuix Date: Fri, 25 Mar 2022 10:36:56 +0800 Subject: [PATCH 15/20] Remove STDC Format macros Signed-off-by: lianhuix --- .../libs/distributeddb/common/include/log_print.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/common/include/log_print.h b/services/distributeddataservice/libs/distributeddb/common/include/log_print.h index df545b16c..0c164d3ef 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/log_print.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/log_print.h @@ -16,9 +16,6 @@ #ifndef DISTRIBUTEDDB_LOG_PRINT_H #define DISTRIBUTEDDB_LOG_PRINT_H -#ifndef __STDC_FORMAT_MACROS -#define __STDC_FORMAT_MACROS -#endif #include #include #include -- Gitee From 9359c1105940c8e17eb271c6e7c8c96d76f94101 Mon Sep 17 00:00:00 2001 From: zqq Date: Fri, 25 Mar 2022 15:40:18 +0800 Subject: [PATCH 16/20] don't wait lock in timer thread Signed-off-by: zqq --- .../syncer/src/sync_state_machine.cpp | 79 +++++++++++-------- .../syncer/src/sync_state_machine.h | 4 + 2 files changed, 52 insertions(+), 31 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_state_machine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_state_machine.cpp index 5ab512fde..5fae36822 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_state_machine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_state_machine.cpp @@ -226,25 +226,18 @@ bool SyncStateMachine::StartSaveDataNotify(uint32_t sessionId, uint32_t sequence int errCode = RuntimeContext::GetInstance()->SetTimer( SAVE_DATA_NOTIFY_INTERVAL, [this, sessionId, sequenceId, inMsgId](TimerId timerId) { - { - std::lock_guard lock(stateMachineLock_); - (void)ResetWatchDog(); - } - std::lock_guard innerLock(saveDataNotifyLock_); - if (saveDataNotifyCount_ >= MAXT_SAVE_DATA_NOTIFY_COUNT) { - StopSaveDataNotifyNoLock(); - return E_OK; - } - SendSaveDataNotifyPacket(sessionId, sequenceId, inMsgId); - saveDataNotifyCount_++; - return E_OK; - }, - [this]() { - int ret = RuntimeContext::GetInstance()->ScheduleTask([this](){ RefObject::DecObjRef(syncContext_); }); + RefObject::IncObjRef(syncContext_); + int ret = RuntimeContext::GetInstance()->ScheduleTask([this, sessionId, sequenceId, inMsgId]() { + DoSaveDataNotify(sessionId, sequenceId, inMsgId); + RefObject::DecObjRef(syncContext_); + }); if (ret != E_OK) { - LOGE("[SyncStateMachine] [SaveDataNotify] timer finalizer ScheduleTask, errCode %d", ret); + LOGE("[SyncStateMachine] [DoSaveDataNotify] ScheduleTask failed errCode %d", ret); + RefObject::DecObjRef(syncContext_); } + return ret; }, + [this]() { RefObject::DecObjRef(syncContext_); }, saveDataNotifyTimerId_); if (errCode != E_OK) { LOGW("[SyncStateMachine][SaveDataNotify] start timer failed err %d !", errCode); @@ -301,24 +294,18 @@ bool SyncStateMachine::StartFeedDogForSync(uint32_t time, SyncDirectionFlag flag int errCode = RuntimeContext::GetInstance()->SetTimer( SAVE_DATA_NOTIFY_INTERVAL, [this, flag](TimerId timerId) { - { - std::lock_guard lock(stateMachineLock_); - (void)ResetWatchDog(); - } - std::lock_guard innerLock(feedDogLock_[flag]); - if (watchDogController_[flag].feedDogCnt >= watchDogController_[flag].feedDogUpperLimit) { - StopFeedDogForSyncNoLock(flag); - return E_OK; - } - watchDogController_[flag].feedDogCnt++; - return E_OK; - }, - [this]() { - int ret = RuntimeContext::GetInstance()->ScheduleTask([this](){ RefObject::DecObjRef(syncContext_); }); + RefObject::IncObjRef(syncContext_); + int ret = RuntimeContext::GetInstance()->ScheduleTask([this, flag]() { + DoFeedDogForSync(flag); + RefObject::DecObjRef(syncContext_); + }); if (ret != E_OK) { - LOGE("[SyncStateMachine] [feedDog] timer finalizer ScheduleTask, errCode %d", ret); + LOGE("[SyncStateMachine] [DoFeedDogForSync] ScheduleTask failed errCode %d", ret); + RefObject::DecObjRef(syncContext_); } + return ret; }, + [this]() { RefObject::DecObjRef(syncContext_); }, watchDogController_[flag].feedDogTimerId); if (errCode != E_OK) { LOGW("[SyncStateMachine][feedDog] start timer failed err %d !", errCode); @@ -377,4 +364,34 @@ void SyncStateMachine::DecRefCountOfFeedDogTimer(SyncDirectionFlag flag) } LOGD("af dec refcount = %d", watchDogController_[flag].refCount); } + +void SyncStateMachine::DoSaveDataNotify(uint32_t sessionId, uint32_t sequenceId, uint32_t inMsgId) +{ + { + std::lock_guard lock(stateMachineLock_); + (void)ResetWatchDog(); + } + std::lock_guard innerLock(saveDataNotifyLock_); + if (saveDataNotifyCount_ >= MAXT_SAVE_DATA_NOTIFY_COUNT) { + StopSaveDataNotifyNoLock(); + return; + } + SendSaveDataNotifyPacket(sessionId, sequenceId, inMsgId); + saveDataNotifyCount_++; + return; +} + +void SyncStateMachine::DoFeedDogForSync(SyncDirectionFlag flag) +{ + { + std::lock_guard lock(stateMachineLock_); + (void)ResetWatchDog(); + } + std::lock_guard innerLock(feedDogLock_[flag]); + if (watchDogController_[flag].feedDogCnt >= watchDogController_[flag].feedDogUpperLimit) { + StopFeedDogForSyncNoLock(flag); + return; + } + watchDogController_[flag].feedDogCnt++; +} } // namespace DistributedDB diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_state_machine.h b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_state_machine.h index 9560631ba..a5f8585a9 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_state_machine.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_state_machine.h @@ -129,6 +129,10 @@ protected: void DecRefCountOfFeedDogTimer(SyncDirectionFlag flag); + void DoSaveDataNotify(uint32_t sessionId, uint32_t sequenceId, uint32_t inMsgId); + + void DoFeedDogForSync(SyncDirectionFlag flag); + DISABLE_COPY_ASSIGN_MOVE(SyncStateMachine); ISyncTaskContext *syncContext_; -- Gitee From dd4b8bd7bcb2adc8d6d0f9ae74d1569dc48150ec Mon Sep 17 00:00:00 2001 From: zqq Date: Mon, 28 Mar 2022 09:47:03 +0800 Subject: [PATCH 17/20] add ut for statemachine Signed-off-by: zqq --- .../syncer/src/sync_state_machine.h | 2 +- .../distributeddb_mock_sync_module_test.cpp | 27 +++++++++++++++++++ .../syncer/mock_single_ver_state_machine.h | 12 +++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_state_machine.h b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_state_machine.h index a5f8585a9..1e633b9b6 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_state_machine.h +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_state_machine.h @@ -129,7 +129,7 @@ protected: void DecRefCountOfFeedDogTimer(SyncDirectionFlag flag); - void DoSaveDataNotify(uint32_t sessionId, uint32_t sequenceId, uint32_t inMsgId); + virtual void DoSaveDataNotify(uint32_t sessionId, uint32_t sequenceId, uint32_t inMsgId); void DoFeedDogForSync(SyncDirectionFlag flag); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp index cacf939fe..9080824ff 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp @@ -227,6 +227,33 @@ HWTEST_F(DistributedDBMockSyncModuleTest, StateMachineCheck006, TestSize.Level1) EXPECT_EQ(stateMachine.CallExecNextTask(), -E_NO_SYNC_TASK); } +/** + * @tc.name: StateMachineCheck007 + * @tc.desc: Test machine DoSaveDataNotify in another thread. + * @tc.type: FUNC + * @tc.require: AR000CCPOM + * @tc.author: zhangqiquan + */ +HWTEST_F(DistributedDBMockSyncModuleTest, StateMachineCheck007, TestSize.Level3) +{ + MockSingleVerStateMachine stateMachine; + uint8_t callCount = 0; + EXPECT_CALL(stateMachine, DoSaveDataNotify(_, _, _)) + .WillRepeatedly([&callCount](uint32_t sessionId, uint32_t sequenceId, uint32_t inMsgId) { + (void) sessionId; + (void) sequenceId; + (void) inMsgId; + callCount++; + std::this_thread::sleep_for(std::chrono::seconds(4)); // sleep 4s + }); + stateMachine.CallStartSaveDataNotify(0, 0, 0); + std::this_thread::sleep_for(std::chrono::seconds(5)); // sleep 5s + stateMachine.CallStopSaveDataNotify(); + // timer is called once in 2s, we sleep 5s timer call twice + EXPECT_EQ(callCount, 2); + std::this_thread::sleep_for(std::chrono::seconds(10)); // sleep 10s to wait all thread exit +} + /** * @tc.name: DataSyncCheck001 * @tc.desc: Test dataSync recv error ack. diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/mock_single_ver_state_machine.h b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/mock_single_ver_state_machine.h index b8dc940cc..878dd420c 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/mock_single_ver_state_machine.h +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/mock_single_ver_state_machine.h @@ -42,9 +42,21 @@ public: SingleVerSyncStateMachine::DataAckRecvErrCodeHandle(errCode, handleError); } + bool CallStartSaveDataNotify(uint32_t sessionId, uint32_t sequenceId, uint32_t inMsgId) + { + return SingleVerSyncStateMachine::StartSaveDataNotify(sessionId, sequenceId, inMsgId); + } + + void CallStopSaveDataNotify() + { + SingleVerSyncStateMachine::StopSaveDataNotify(); + } + MOCK_METHOD1(SwitchStateAndStep, void(uint8_t)); MOCK_METHOD0(PrepareNextSyncTask, int(void)); + + MOCK_METHOD3(DoSaveDataNotify, void(uint32_t, uint32_t, uint32_t)); }; } // namespace DistributedDB #endif // #define MOCK_SINGLE_VER_STATE_MACHINE_H \ No newline at end of file -- Gitee From 7b281da0c759ab3c2591c2f1325eaa9eec93f676 Mon Sep 17 00:00:00 2001 From: lianhuix Date: Mon, 28 Mar 2022 14:13:38 +0800 Subject: [PATCH 18/20] Fix reviewBot. over 50 lines Signed-off-by: lianhuix --- .../distributeddb/common/src/auto_launch.cpp | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp b/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp index 6085a9d98..717e3c8a3 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp @@ -206,7 +206,6 @@ int AutoLaunch::GetKVConnectionInEnable(AutoLaunchItem &autoLaunchItem, const st return E_OK; } if (autoLaunchItem.conn == nullptr) { - std::lock_guard autoLock(dataLock_); EraseAutoLauchItem(identifier, userId); return errCode; } @@ -221,7 +220,6 @@ int AutoLaunch::GetKVConnectionInEnable(AutoLaunchItem &autoLaunchItem, const st errCode = KvDBManager::ReleaseDatabaseConnection(kvConn); if (errCode != E_OK) { LOGE("[AutoLaunch] GetKVConnectionInEnable ReleaseDatabaseConnection failed errCode:%d", errCode); - std::lock_guard autoLock(dataLock_); EraseAutoLauchItem(identifier, userId); return errCode; } @@ -238,7 +236,6 @@ int AutoLaunch::GetKVConnectionInEnable(AutoLaunchItem &autoLaunchItem, const st } else { LOGE("[AutoLaunch] GetKVConnectionInEnable RegisterObserverAndLifeCycleCallback err, do CloseConnection"); TryCloseConnection(autoLaunchItem); // do nothing if failed - std::lock_guard autoLock(dataLock_); EraseAutoLauchItem(identifier, userId); } return errCode; @@ -428,7 +425,7 @@ int AutoLaunch::DisableKvStoreAutoLaunch(const std::string &normalIdentifier, co LOGE("[AutoLaunch] DisableKvStoreAutoLaunch identifier is not exist!"); return -E_NOT_FOUND; } - if (autoLaunchItemMap_[identifier][userId].isDisable == true) { + if (autoLaunchItemMap_[identifier][userId].isDisable) { LOGI("[AutoLaunch] DisableKvStoreAutoLaunch already disabling in another thread, do nothing here"); return -E_BUSY; } @@ -449,19 +446,17 @@ int AutoLaunch::DisableKvStoreAutoLaunch(const std::string &normalIdentifier, co } int errCode = CloseConnectionStrict(autoLaunchItem); - if (errCode == E_OK) { - std::unique_lock autoLock(dataLock_); - EraseAutoLauchItem(identifier, userId); - cv_.notify_all(); - LOGI("[AutoLaunch] DisableKvStoreAutoLaunch CloseConnection ok"); - } else { + if (errCode != E_OK) { LOGE("[AutoLaunch] DisableKvStoreAutoLaunch CloseConnection failed errCode:%d", errCode); - std::unique_lock autoLock(dataLock_); + std::lock_guard autoLock(dataLock_); autoLaunchItemMap_[identifier][userId].isDisable = false; autoLaunchItemMap_[identifier][userId].observerHandle = autoLaunchItem.observerHandle; cv_.notify_all(); return errCode; } + + EraseAutoLauchItem(identifier, userId); + cv_.notify_all(); if (autoLaunchItem.isWriteOpenNotified && autoLaunchItem.notifier) { RuntimeContext::GetInstance()->ScheduleTask([autoLaunchItem] { CloseNotifier(autoLaunchItem); }); } @@ -1202,8 +1197,9 @@ void AutoLaunch::TryCloseRelationConnection(AutoLaunchItem &autoLaunchItem) void AutoLaunch::EraseAutoLauchItem(const std::string &identifier, const std::string &userId) { + std::lock_guard autoLock(dataLock_); autoLaunchItemMap_[identifier].erase(userId); - if (autoLaunchItemMap_[identifier].size() == 0) { + if (autoLaunchItemMap_[identifier].empty()) { autoLaunchItemMap_.erase(identifier); } } -- Gitee From 61173d93139fae7f8a1305c414130acd831dc680 Mon Sep 17 00:00:00 2001 From: lianhuix Date: Fri, 25 Mar 2022 18:07:47 +0800 Subject: [PATCH 19/20] Change unsigned long to uint64_t Signed-off-by: lianhuix --- .../libs/distributeddb/common/include/data_compression.h | 2 +- .../libs/distributeddb/common/include/zlib_compression.h | 2 +- .../common/src/relational/relational_schema_object.cpp | 4 ---- .../libs/distributeddb/common/src/zlib_compression.cpp | 2 +- .../distributeddb/interfaces/src/kv_store_result_set_impl.cpp | 4 ++-- .../distributeddb/storage/src/generic_single_ver_kv_entry.cpp | 2 +- .../distributeddb/storage/src/generic_single_ver_kv_entry.h | 2 +- 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/common/include/data_compression.h b/services/distributeddataservice/libs/distributeddb/common/include/data_compression.h index 6b39d2ea2..75c59e4b1 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/data_compression.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/data_compression.h @@ -29,7 +29,7 @@ public: static int TransferCompressionAlgo(uint32_t compressAlgoType, CompressAlgorithm &algoType); virtual int Compress(const std::vector &srcData, std::vector &destData) const = 0; - virtual int Uncompress(const std::vector &srcData, std::vector &destData, unsigned long destLen) + virtual int Uncompress(const std::vector &srcData, std::vector &destData, uint64_t destLen) const = 0; protected: diff --git a/services/distributeddataservice/libs/distributeddb/common/include/zlib_compression.h b/services/distributeddataservice/libs/distributeddb/common/include/zlib_compression.h index 3ddccd3f9..845fa002a 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/zlib_compression.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/zlib_compression.h @@ -25,7 +25,7 @@ public: ~ZlibCompression() = default; int Compress(const std::vector &srcData, std::vector &destData) const override; - int Uncompress(const std::vector &srcData, std::vector &destData, unsigned long destLen) const + int Uncompress(const std::vector &srcData, std::vector &destData, uint64_t destLen) const override; protected: diff --git a/services/distributeddataservice/libs/distributeddb/common/src/relational/relational_schema_object.cpp b/services/distributeddataservice/libs/distributeddb/common/src/relational/relational_schema_object.cpp index 3642c7fb2..75e565da7 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/relational/relational_schema_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/relational/relational_schema_object.cpp @@ -376,10 +376,6 @@ std::map TableInfo::GetSchemaDefine() const return schemaDefine; } -namespace { - const std::string MAGIC = "relational_opinion"; -} - bool RelationalSchemaObject::IsSchemaValid() const { return isValid_; diff --git a/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp b/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp index 045fc6d2d..fee9ed372 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp @@ -55,7 +55,7 @@ int ZlibCompression::Compress(const std::vector &srcData, std::vector &srcData, std::vector &destData, - unsigned long destLen) const + uint64_t destLen) const { auto srcLen = srcData.size(); if (srcLen > DBConstant::MAX_SYNC_BLOCK_SIZE || destLen > DBConstant::MAX_SYNC_BLOCK_SIZE) { diff --git a/services/distributeddataservice/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp b/services/distributeddataservice/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp index 968284da0..18f8b6624 100644 --- a/services/distributeddataservice/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp +++ b/services/distributeddataservice/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp @@ -43,8 +43,8 @@ int KvStoreResultSetImpl::GetPosition() const bool KvStoreResultSetImpl::Move(int offset) { - long long position = GetPosition(); - long long aimPos = position + offset; + int64_t position = GetPosition(); + int64_t aimPos = position + offset; if (aimPos > INT_MAX) { return MoveToPosition(INT_MAX); } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp index 54f5003e6..2b7e02c15 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp @@ -403,7 +403,7 @@ int GenericSingleVerKvEntry::Compress(const std::vector &kvE } int GenericSingleVerKvEntry::Uncompress(const std::vector &srcData, std::vector &kvEntries, - unsigned long destLen, CompressAlgorithm algo) + uint64_t destLen, CompressAlgorithm algo) { // Uncompress data. std::vector destData(destLen, 0); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.h b/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.h index 32a59696b..ec4fc2081 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.h @@ -78,7 +78,7 @@ public: static int Compress(const std::vector &kvEntries, std::vector &destData, const CompressInfo &compressInfo); static int Uncompress(const std::vector &srcData, std::vector &kvEntries, - unsigned long destLen, CompressAlgorithm algo); + uint64_t destLen, CompressAlgorithm algo); static int SerializeCompressedDatas(const std::vector &kvEntries, const std::vector &compressedEntries, Parcel &parcel, uint32_t targetVersion, CompressAlgorithm algo); static int DeSerializeCompressedDatas(std::vector &kvEntries, Parcel &parcel); -- Gitee From 09d59ade4f36b2bfe355234a6dd216e716050fc3 Mon Sep 17 00:00:00 2001 From: lianhuix Date: Tue, 29 Mar 2022 09:44:03 +0800 Subject: [PATCH 20/20] Fix compile issue Signed-off-by: lianhuix --- .../libs/distributeddb/common/include/data_compression.h | 2 +- .../libs/distributeddb/common/include/zlib_compression.h | 2 +- .../libs/distributeddb/common/src/zlib_compression.cpp | 7 ++++--- .../storage/src/generic_single_ver_kv_entry.cpp | 2 +- .../storage/src/generic_single_ver_kv_entry.h | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/services/distributeddataservice/libs/distributeddb/common/include/data_compression.h b/services/distributeddataservice/libs/distributeddb/common/include/data_compression.h index 75c59e4b1..449fe7a37 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/data_compression.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/data_compression.h @@ -29,7 +29,7 @@ public: static int TransferCompressionAlgo(uint32_t compressAlgoType, CompressAlgorithm &algoType); virtual int Compress(const std::vector &srcData, std::vector &destData) const = 0; - virtual int Uncompress(const std::vector &srcData, std::vector &destData, uint64_t destLen) + virtual int Uncompress(const std::vector &srcData, std::vector &destData, uint32_t destLen) const = 0; protected: diff --git a/services/distributeddataservice/libs/distributeddb/common/include/zlib_compression.h b/services/distributeddataservice/libs/distributeddb/common/include/zlib_compression.h index 845fa002a..4f14b2c7d 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/zlib_compression.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/zlib_compression.h @@ -25,7 +25,7 @@ public: ~ZlibCompression() = default; int Compress(const std::vector &srcData, std::vector &destData) const override; - int Uncompress(const std::vector &srcData, std::vector &destData, uint64_t destLen) const + int Uncompress(const std::vector &srcData, std::vector &destData, uint32_t destLen) const override; protected: diff --git a/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp b/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp index fee9ed372..28a24db40 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp @@ -55,7 +55,7 @@ int ZlibCompression::Compress(const std::vector &srcData, std::vector &srcData, std::vector &destData, - uint64_t destLen) const + uint32_t destLen) const { auto srcLen = srcData.size(); if (srcLen > DBConstant::MAX_SYNC_BLOCK_SIZE || destLen > DBConstant::MAX_SYNC_BLOCK_SIZE) { @@ -67,13 +67,14 @@ int ZlibCompression::Uncompress(const std::vector &srcData, std::vector destData.resize(destLen); // Uncompress. - int errCode = uncompress(destData.data(), &destLen, srcData.data(), srcData.size()); + uLongf destDataLen = destLen; + int errCode = uncompress(destData.data(), &destDataLen, srcData.data(), srcData.size()); if (errCode != Z_OK) { LOGE("Uncompress failed, errCode = %d", errCode); return -E_SYSTEM_API_FAIL; } - destData.resize(destLen); + destData.resize(destDataLen); destData.shrink_to_fit(); return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp index 2b7e02c15..c0963616f 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp @@ -403,7 +403,7 @@ int GenericSingleVerKvEntry::Compress(const std::vector &kvE } int GenericSingleVerKvEntry::Uncompress(const std::vector &srcData, std::vector &kvEntries, - uint64_t destLen, CompressAlgorithm algo) + uint32_t destLen, CompressAlgorithm algo) { // Uncompress data. std::vector destData(destLen, 0); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.h b/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.h index ec4fc2081..8fa82b006 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.h +++ b/services/distributeddataservice/libs/distributeddb/storage/src/generic_single_ver_kv_entry.h @@ -78,7 +78,7 @@ public: static int Compress(const std::vector &kvEntries, std::vector &destData, const CompressInfo &compressInfo); static int Uncompress(const std::vector &srcData, std::vector &kvEntries, - uint64_t destLen, CompressAlgorithm algo); + uint32_t destLen, CompressAlgorithm algo); static int SerializeCompressedDatas(const std::vector &kvEntries, const std::vector &compressedEntries, Parcel &parcel, uint32_t targetVersion, CompressAlgorithm algo); static int DeSerializeCompressedDatas(std::vector &kvEntries, Parcel &parcel); -- Gitee