From eded2d8fa5ba1e7c037be21f0508f6fa843006a8 Mon Sep 17 00:00:00 2001 From: zuojiangjiang Date: Mon, 5 Jun 2023 11:39:03 +0800 Subject: [PATCH] update Signed-off-by: zuojiangjiang --- .../distributeddataservice/framework/include/store/cursor.h | 2 ++ .../distributeddataservice/service/rdb/rdb_cloud.cpp | 6 +++++- .../distributeddataservice/service/rdb/rdb_cursor.cpp | 5 +++++ .../distributeddataservice/service/rdb/rdb_cursor.h | 1 + .../service/rdb/rdb_general_store.cpp | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/datamgr_service/services/distributeddataservice/framework/include/store/cursor.h b/datamgr_service/services/distributeddataservice/framework/include/store/cursor.h index e588c5fd..a631122e 100644 --- a/datamgr_service/services/distributeddataservice/framework/include/store/cursor.h +++ b/datamgr_service/services/distributeddataservice/framework/include/store/cursor.h @@ -46,6 +46,8 @@ public: virtual int32_t Get(const std::string &col, Value &value) = 0; virtual int32_t Close() = 0; + + virtual bool IsEnd() = 0; }; } // namespace OHOS::DistributedData #endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_STORE_CURSOR_H diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_cloud.cpp b/datamgr_service/services/distributeddataservice/service/rdb/rdb_cloud.cpp index e0ee3e9f..8929f73f 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_cloud.cpp +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_cloud.cpp @@ -71,13 +71,17 @@ DBStatus RdbCloud::Query(const std::string &tableName, DBVBucket &extend, std::v err = cursor->MoveToNext(); count--; } + if (cursor->IsEnd()) { + ZLOGD("query end, table:%{public}s", tableName.c_str()); + return DBStatus::QUERY_END; + } return ConvertStatus(static_cast(err)); } std::pair RdbCloud::Lock() { auto error = cloudDB_->Lock(); - return std::make_pair(ConvertStatus(static_cast(error)), 0); + return std::make_pair(ConvertStatus(static_cast(error)), cloudDB_->AliveTime() * 1000); // int64_t <-> uint32_t, s <-> ms } DBStatus RdbCloud::UnLock() diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.cpp b/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.cpp index c0baf75e..619e7d3a 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.cpp +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.cpp @@ -102,4 +102,9 @@ int32_t RdbCursor::Close() { return resultSet_->Close(); } + +bool RdbCursor::IsEnd() +{ + return false; +} } // namespace OHOS::DistributedRdb diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.h b/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.h index f51a4492..dd184d49 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.h +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.h @@ -33,6 +33,7 @@ public: int32_t Get(int32_t col, DistributedData::Value &value) override; int32_t Get(const std::string &col, DistributedData::Value &value) override; int32_t Close() override; + bool IsEnd() override; private: std::shared_ptr resultSet_; diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp b/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp index c69cb9f7..87049d11 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp @@ -140,6 +140,7 @@ int32_t RdbGeneralStore::Close() bindInfo_.loader_ = nullptr; bindInfo_.db_->Close(); bindInfo_.db_ = nullptr; + rdbCloud_ = nullptr; return 0; } -- Gitee