From 44e763e5b2670cb8d76b9a592a4bad83286fb342 Mon Sep 17 00:00:00 2001 From: bluhuang Date: Sat, 9 Nov 2024 16:42:23 +0800 Subject: [PATCH 01/21] change document store manager to grd store manager Signed-off-by: bluhuang --- .../gaussdb_rd/src/executor/base/grd_db_api_inner.cpp | 6 +++--- .../src/interface/include/document_store_manager.h | 2 +- .../src/interface/src/document_store_manager.cpp | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp index fcf84320102..dc24d43b83c 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp @@ -30,14 +30,14 @@ int32_t GRD_DBOpenInner(const char *dbPath, const char *configStr, uint32_t flag std::string path = (dbPath == nullptr ? "" : dbPath); std::string config = (configStr == nullptr ? "" : configStr); DocumentStore *store = nullptr; - int ret = DocumentStoreManager::GetDocumentStore(path, config, flags, store); + int ret = GRDStoreManager::GetDocumentStore(path, config, flags, store); if (ret != E_OK || store == nullptr) { return TransferDocErr(ret); } *db = new (std::nothrow) GRD_DB(); if (*db == nullptr) { - (void)DocumentStoreManager::CloseDocumentStore(store, GRD_DB_CLOSE_IGNORE_ERROR); + (void)GRDStoreManager::CloseDocumentStore(store, GRD_DB_CLOSE_IGNORE_ERROR); store = nullptr; return GRD_FAILED_MEMORY_ALLOCATE; } @@ -52,7 +52,7 @@ int32_t GRD_DBCloseInner(GRD_DB *db, uint32_t flags) return GRD_INVALID_ARGS; } - int ret = DocumentStoreManager::CloseDocumentStore(db->store_, flags); + int ret = GRDStoreManager::CloseDocumentStore(db->store_, flags); if (ret != E_OK) { return TransferDocErr(ret); } diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h index f9745fae8f5..a1824bf5ba4 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h @@ -22,7 +22,7 @@ #include "document_store.h" namespace DocumentDB { -class DocumentStoreManager { +class GRDStoreManager { public: static int GetDocumentStore(const std::string &path, const std::string &config, uint32_t flags, DocumentStore *&store); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp index 00a6a294f89..4d9a3143592 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp @@ -46,10 +46,10 @@ bool CheckDBCreate(uint32_t flags, const std::string &path) } } // namespace -std::mutex DocumentStoreManager::openCloseMutex_; -std::map DocumentStoreManager::dbConnCount_; +std::mutex GRDStoreManager::openCloseMutex_; +std::map GRDStoreManager::dbConnCount_; -int DocumentStoreManager::GetDocumentStore(const std::string &path, const std::string &config, uint32_t flags, +int GRDStoreManager::GetDocumentStore(const std::string &path, const std::string &config, uint32_t flags, DocumentStore *&store) { std::string canonicalPath; @@ -107,7 +107,7 @@ int DocumentStoreManager::GetDocumentStore(const std::string &path, const std::s return errCode; } -int DocumentStoreManager::CloseDocumentStore(DocumentStore *store, uint32_t flags) +int GRDStoreManager::CloseDocumentStore(DocumentStore *store, uint32_t flags) { if (!CheckDBCloseFlag(flags)) { GLOGE("Check document db close flags failed."); @@ -125,7 +125,7 @@ int DocumentStoreManager::CloseDocumentStore(DocumentStore *store, uint32_t flag return E_OK; } -int DocumentStoreManager::CheckDBPath(const std::string &path, std::string &canonicalPath, std::string &dbName) +int GRDStoreManager::CheckDBPath(const std::string &path, std::string &canonicalPath, std::string &dbName) { if (path.empty()) { GLOGE("Invalid path empty"); -- Gitee From 2ab19cdd12449f4b637f6a9f5cc2aad9b7e863d7 Mon Sep 17 00:00:00 2001 From: bluhuang Date: Sat, 9 Nov 2024 16:44:07 +0800 Subject: [PATCH 02/21] change documentDB namespace to GRDDB Signed-off-by: bluhuang --- .../gaussdb_rd/src/common/include/collection_option.h | 4 ++-- .../gaussdb_rd/src/common/include/db_config.h | 4 ++-- .../gaussdb_rd/src/common/include/doc_limit.h | 4 ++-- .../gaussdb_rd/src/common/include/document_type.h | 4 ++-- .../gaussdb_rd/src/common/include/grd_api_manager.h | 4 ++-- .../gaussdb_rd/src/common/include/json_common.h | 4 ++-- .../distributeddb/gaussdb_rd/src/common/include/os_api.h | 4 ++-- .../gaussdb_rd/src/common/include/rd_db_constant.h | 4 ++-- .../gaussdb_rd/src/common/include/rd_log_print.h | 4 ++-- .../gaussdb_rd/src/common/src/collection_option.cpp | 4 ++-- .../distributeddb/gaussdb_rd/src/common/src/db_config.cpp | 4 ++-- .../gaussdb_rd/src/common/src/grd_api_manager.cpp | 4 ++-- .../gaussdb_rd/src/common/src/json_common.cpp | 4 ++-- .../distributeddb/gaussdb_rd/src/common/src/os_api.cpp | 4 ++-- .../gaussdb_rd/src/common/src/rd_log_print.cpp | 4 ++-- .../gaussdb_rd/src/executor/base/grd_db_api.cpp | 2 +- .../gaussdb_rd/src/executor/base/grd_db_api_inner.cpp | 4 ++-- .../gaussdb_rd/src/executor/document/check_common.cpp | 6 +++--- .../gaussdb_rd/src/executor/document/check_common.h | 4 ++-- .../gaussdb_rd/src/executor/document/grd_document_api.cpp | 2 +- .../src/executor/document/grd_document_api_inner.cpp | 4 ++-- .../src/executor/document/grd_resultset_api.cpp | 2 +- .../src/executor/document/grd_resultset_api_inner.cpp | 4 ++-- .../gaussdb_rd/src/executor/include/grd_db_api_inner.h | 4 ++-- .../src/executor/include/grd_document_api_inner.h | 4 ++-- .../gaussdb_rd/src/executor/include/grd_kv_api_inner.h | 4 ++-- .../src/executor/include/grd_resultset_api_inner.h | 4 ++-- .../gaussdb_rd/src/executor/include/grd_resultset_inner.h | 2 +- .../src/executor/include/grd_sequence_api_inner.h | 4 ++-- .../gaussdb_rd/src/executor/include/grd_type_inner.h | 2 +- .../gaussdb_rd/src/executor/kv/grd_kv_api.cpp | 2 +- .../gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp | 4 ++-- .../gaussdb_rd/src/interface/include/collection.h | 4 ++-- .../gaussdb_rd/src/interface/include/doc_errno.h | 4 ++-- .../gaussdb_rd/src/interface/include/document_key.h | 4 ++-- .../gaussdb_rd/src/interface/include/document_store.h | 4 ++-- .../src/interface/include/document_store_manager.h | 4 ++-- .../gaussdb_rd/src/interface/include/projection_tree.h | 4 ++-- .../gaussdb_rd/src/interface/include/result_set.h | 4 ++-- .../gaussdb_rd/src/interface/include/result_set_common.h | 4 ++-- .../gaussdb_rd/src/interface/src/collection.cpp | 4 ++-- .../gaussdb_rd/src/interface/src/doc_errno.cpp | 4 ++-- .../gaussdb_rd/src/interface/src/document_key.cpp | 4 ++-- .../gaussdb_rd/src/interface/src/document_store.cpp | 4 ++-- .../src/interface/src/document_store_manager.cpp | 4 ++-- .../gaussdb_rd/src/interface/src/projection_tree.cpp | 4 ++-- .../gaussdb_rd/src/interface/src/result_set.cpp | 4 ++-- .../gaussdb_rd/src/interface/src/result_set_common.cpp | 4 ++-- .../gaussdb_rd/src/oh_adapter/include/kv_store_executor.h | 4 ++-- .../gaussdb_rd/src/oh_adapter/include/kv_store_manager.h | 4 ++-- .../gaussdb_rd/src/oh_adapter/include/rd_json_object.h | 4 ++-- .../gaussdb_rd/src/oh_adapter/src/kv_store_manager.cpp | 4 ++-- .../gaussdb_rd/src/oh_adapter/src/rd_json_object.cpp | 4 ++-- .../gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp | 4 ++-- .../gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.h | 4 ++-- .../src/oh_adapter/src/sqlite_store_executor_impl.cpp | 4 ++-- .../src/oh_adapter/src/sqlite_store_executor_impl.h | 4 ++-- .../gaussdb_rd/test/unittest/api/documentdb_api_test.cpp | 2 +- .../test/unittest/api/documentdb_collection_test.cpp | 2 +- .../gaussdb_rd/test/unittest/api/documentdb_data_test.cpp | 2 +- .../gaussdb_rd/test/unittest/api/documentdb_find_test.cpp | 8 ++++---- .../unittest/oh_adapter/documentdb_json_common_test.cpp | 2 +- .../unittest/oh_adapter/documentdb_jsonobject_test.cpp | 2 +- .../test/fuzztest/json_fuzzer/json_fuzzer.cpp | 2 +- .../test/fuzztest/jsoninner_fuzzer/jsoninner_fuzzer.cpp | 4 ++-- 65 files changed, 121 insertions(+), 121 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/collection_option.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/collection_option.h index ddb4cf3cdfd..05ab014e449 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/collection_option.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/collection_option.h @@ -18,7 +18,7 @@ #include -namespace DocumentDB { +namespace GRDDB { class CollectionOption final { public: static CollectionOption ReadOption(const std::string &optStr, int &errCode); @@ -31,5 +31,5 @@ private: std::string option_ = "{}"; uint32_t maxDoc_ = UINT32_MAX; }; -} // namespace DocumentDB +} // namespace GRDDB #endif // COLLECTION_OPTION_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/db_config.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/db_config.h index cf74b253e51..ddf79d7ad34 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/db_config.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/db_config.h @@ -18,7 +18,7 @@ #include -namespace DocumentDB { +namespace GRDDB { class DBConfig final { public: static DBConfig ReadConfig(const std::string &confStr, int &errCode); @@ -47,5 +47,5 @@ private: uint32_t crcCheckEnable_ = 1; uint32_t shareModeEnable_ = 0; }; -} // namespace DocumentDB +} // namespace GRDDB #endif // DB_CONFIG_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/doc_limit.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/doc_limit.h index fc2515f323e..849129ef998 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/doc_limit.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/doc_limit.h @@ -16,7 +16,7 @@ #ifndef DOC_LIMIT_H #define DOC_LIMIT_H -namespace DocumentDB { +namespace GRDDB { constexpr int MAX_DB_CONFIG_LEN = 1024 * 1024; // 1024 * 1024: 1024k length -} // namespace DocumentDB +} // namespace GRDDB #endif // DOC_LIMIT_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/document_type.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/document_type.h index 0c767b9aed7..a48a15ad09f 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/document_type.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/document_type.h @@ -20,7 +20,7 @@ #include "projection_tree.h" -namespace DocumentDB { +namespace GRDDB { struct QueryContext { std::string collectionName; std::string filter; @@ -30,5 +30,5 @@ struct QueryContext { bool viewType = false; bool isIdExist = false; }; -} // namespace DocumentDB +} // namespace GRDDB #endif // DOCUMENT_TYPE_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/grd_api_manager.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/grd_api_manager.h index 7acb79c248f..44cda4c6725 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/grd_api_manager.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/grd_api_manager.h @@ -18,7 +18,7 @@ #include "grd_base/grd_type_export.h" -namespace DocumentDB { +namespace GRDDB { typedef int32_t (*DBOpen)(const char *dbPath, const char *configStr, uint32_t flags, GRD_DB **db); typedef int32_t (*DBClose)(GRD_DB *db, uint32_t flags); typedef int32_t (*DBBackup)(GRD_DB *db, const char *backupDbFile, GRD_CipherInfoT *cipherInfo); @@ -93,5 +93,5 @@ struct GRD_APIInfo { }; GRD_APIInfo GetApiInfoInstance(); void InitApiInfo(const char *configStr); -} // namespace DocumentDB +} // namespace GRDDB #endif // __cplusplus diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/json_common.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/json_common.h index b02231e7ea7..66a68a36378 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/json_common.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/json_common.h @@ -23,7 +23,7 @@ #include "rd_json_object.h" -namespace DocumentDB { +namespace GRDDB { class JsonCommon { public: static ValueObject GetValueInSameLevel(JsonObject &node, const std::string &field); @@ -49,5 +49,5 @@ private: static bool IsObjectItemMatch(const JsonObject &srcItem, const JsonObject &item, int &isAlreadyMatched, bool &isCollapse, int &isMatchFlag); }; -} // namespace DocumentDB +} // namespace GRDDB #endif // JSON_COMMON_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/os_api.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/os_api.h index 01f661c1b1a..b05e45e344d 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/os_api.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/os_api.h @@ -17,7 +17,7 @@ #include -namespace DocumentDB { +namespace GRDDB { namespace OSAPI { bool CheckPathPermission(const std::string &filePath); @@ -27,5 +27,5 @@ int GetRealPath(const std::string &inOriPath, std::string &outRealPath); void SplitFilePath(const std::string &filePath, std::string &fieldir, std::string &fileName); } // namespace OSAPI -} // namespace DocumentDB +} // namespace GRDDB #endif // OS_API_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/rd_db_constant.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/rd_db_constant.h index f2c1972d688..9fd36af09cb 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/rd_db_constant.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/rd_db_constant.h @@ -18,10 +18,10 @@ #include -namespace DocumentDB { +namespace GRDDB { class RdDBConstant final { public: static constexpr const char *COLL_PREFIX = "GRD_COLL_"; }; -} // namespace DocumentDB +} // namespace GRDDB #endif // DB_CONSTANT_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/rd_log_print.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/rd_log_print.h index 3e092f7ee06..8eae62e55c0 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/rd_log_print.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/rd_log_print.h @@ -18,7 +18,7 @@ #include -namespace DocumentDB { +namespace GRDDB { constexpr const char *LOG_TAG_DOC = "GAUSSDB_RD"; class RdLogPrint { @@ -33,7 +33,7 @@ public: static void Log(Level level, const char *tag, const char *format, ...); }; -} // namespace DocumentDB +} // namespace GRDDB #define NO_LOG(...) // No log in normal and release. Used for the convenience when deep debugging #define GLOGD(...) RdLogPrint::Log(RdLogPrint::Level::LEVEL_DEBUG, LOG_TAG_DOC, __VA_ARGS__) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp index 851b3f20e08..cdcde7874b3 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp @@ -22,7 +22,7 @@ #include "rd_json_object.h" #include "rd_log_print.h" -namespace DocumentDB { +namespace GRDDB { namespace { constexpr const char *OPT_MAX_DOC = "maxdoc"; constexpr const char *OPT_COLLECTION_MODE = "mode"; @@ -102,4 +102,4 @@ CollectionOption CollectionOption::ReadOption(const std::string &optStr, int &er option.option_ = optStr; return option; } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/db_config.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/db_config.cpp index 8055d2856f5..75d40938a26 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/db_config.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/db_config.cpp @@ -25,7 +25,7 @@ #include "rd_json_object.h" #include "rd_log_print.h" -namespace DocumentDB { +namespace GRDDB { namespace { constexpr int MIN_REDO_BUFFER_SIZE = 256; constexpr int MAX_REDO_BUFFER_SIZE = 16384; @@ -266,4 +266,4 @@ bool DBConfig::CheckPersistenceEqual(const DBConfig &targetConfig) const { return pageSize_ == targetConfig.pageSize_ && crcCheckEnable_ == targetConfig.crcCheckEnable_; } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp index 4352bf1072d..4676a939a77 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp @@ -37,7 +37,7 @@ static void *g_library = nullptr; static bool g_isGmdbLib = false; -namespace DocumentDB { +namespace GRDDB { void GRD_DBApiInitCommon(GRD_APIInfo &GRD_DBApiInfo) { GRD_DBApiInfo.DBOpenApi = GRD_DBOpenInner; @@ -129,4 +129,4 @@ GRD_APIInfo GetApiInfoInstance() #endif return GRD_TempApiStruct; } -} // namespace DocumentDB +} // namespace GRDDB diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/json_common.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/json_common.cpp index 40b92e3fe6d..79930d6aa59 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/json_common.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/json_common.cpp @@ -20,7 +20,7 @@ #include "doc_errno.h" #include "rd_log_print.h" -namespace DocumentDB { +namespace GRDDB { ValueObject JsonCommon::GetValueInSameLevel(JsonObject &node, const std::string &field) { while (!node.IsNull()) { @@ -731,4 +731,4 @@ bool JsonCommon::IsJsonNodeMatch(const JsonObject &src, const JsonObject &target }); return isMatchFlag; } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/os_api.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/os_api.cpp index d642f8b1109..7bbc4c68d9f 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/os_api.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/os_api.cpp @@ -23,7 +23,7 @@ #include "rd_log_print.h" #include "securec.h" -namespace DocumentDB { +namespace GRDDB { namespace { const int ACCESS_MODE_EXISTENCE = 0; } @@ -89,4 +89,4 @@ void SplitFilePath(const std::string &filePath, std::string &fieldir, std::strin fileName = filePath.substr(slashPos + 1); } } // namespace OSAPI -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/rd_log_print.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/rd_log_print.cpp index 993880acdac..e59c094c3bc 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/rd_log_print.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/rd_log_print.cpp @@ -18,7 +18,7 @@ #include "hilog/log.h" #include "securec.h" -namespace DocumentDB { +namespace GRDDB { namespace { void PrintLog(RdLogPrint::Level level, const char *tag, const std::string &msg) { @@ -79,4 +79,4 @@ void RdLogPrint::Log(Level level, const char *tag, const char *format, ...) PrintLog(level, tag, msg); } -} // namespace DocumentDB +} // namespace GRDDB diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp index 07e5a1e8622..b3d5881aa89 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp @@ -22,7 +22,7 @@ #include "grd_type_inner.h" #include "rd_log_print.h" -using namespace DocumentDB; +using namespace GRDDB; static GRD_APIInfo GRD_DBApiInfo; GRD_API int32_t GRD_DBOpen(const char *dbPath, const char *configStr, uint32_t flags, GRD_DB **db) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp index dc24d43b83c..9aaeb6f45e2 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp @@ -21,7 +21,7 @@ #include "grd_type_inner.h" #include "rd_log_print.h" -namespace DocumentDB { +namespace GRDDB { int32_t GRD_DBOpenInner(const char *dbPath, const char *configStr, uint32_t flags, GRD_DB **db) { if (db == nullptr) { @@ -77,4 +77,4 @@ int32_t GRD_IndexPreloadInner(GRD_DB *db, const char *collectionName) { return GRD_OK; } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/check_common.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/check_common.cpp index d545c0e44de..b5f46800ab8 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/check_common.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/check_common.cpp @@ -22,8 +22,8 @@ #include "rd_log_print.h" #include "securec.h" -using namespace DocumentDB; -namespace DocumentDB { +using namespace GRDDB; +namespace GRDDB { namespace { constexpr const char *KEY_ID = "_id"; constexpr const char *COLLECTION_PREFIX_GRD = "GRD_"; @@ -260,4 +260,4 @@ int CheckCommon::CheckProjection(JsonObject &projectionObj, std::vector; using Value = std::vector; -} // namespace DocumentDB +} // namespace GRDDB #endif // CHECK_COMMON_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api.cpp index accc95d7bde..bdb2a17d768 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api.cpp @@ -21,7 +21,7 @@ #include "grd_resultset_inner.h" #include "grd_type_inner.h" #include "rd_log_print.h" -using namespace DocumentDB; +using namespace GRDDB; static GRD_APIInfo GRD_DocApiInfo; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp index fe4663b3d0e..500f4c311ae 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp @@ -21,7 +21,7 @@ #include "grd_resultset_inner.h" #include "grd_type_inner.h" #include "rd_log_print.h" -namespace DocumentDB { +namespace GRDDB { int32_t GRD_CreateCollectionInner(GRD_DB *db, const char *collectionName, const char *optionStr, uint32_t flags) { if (db == nullptr || db->store_ == nullptr) { @@ -117,4 +117,4 @@ int32_t GRD_FindDocInner(GRD_DB *db, const char *collectionName, Query query, ui *resultSet = grdResultSet; return TransferDocErr(ret); } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api.cpp index 5e905677522..8c3c1a9587f 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api.cpp @@ -20,7 +20,7 @@ #include "grd_resultset_inner.h" #include "rd_log_print.h" -using namespace DocumentDB; +using namespace GRDDB; static GRD_APIInfo GRD_ResultSetApiInfo; GRD_API int32_t GRD_Next(GRD_ResultSet *resultSet) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api_inner.cpp index 5b098603742..fbec6008271 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api_inner.cpp @@ -20,7 +20,7 @@ #include "grd_resultset_inner.h" #include "rd_log_print.h" -namespace DocumentDB { +namespace GRDDB { int32_t GRD_NextInner(GRD_ResultSet *resultSet) { if (resultSet == nullptr) { @@ -75,4 +75,4 @@ int32_t GRD_FetchInner(GRD_ResultSet *resultSet, GRD_KVItemT *key, GRD_KVItemT * { return GRD_NOT_SUPPORT; } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_db_api_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_db_api_inner.h index 0aafa77506d..d747bef090e 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_db_api_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_db_api_inner.h @@ -17,7 +17,7 @@ #define GRD_DB_API_INNER_H #include #include "grd_base/grd_type_export.h" -namespace DocumentDB { +namespace GRDDB { int32_t GRD_DBOpenInner(const char *dbPath, const char *configStr, uint32_t flags, GRD_DB **db); int32_t GRD_DBCloseInner(GRD_DB *db, uint32_t flags); @@ -25,5 +25,5 @@ int32_t GRD_DBCloseInner(GRD_DB *db, uint32_t flags); int32_t GRD_IndexPreloadInner(GRD_DB *db, const char *collectionName); int32_t GRD_FlushInner(GRD_DB *db, uint32_t flags); -} // namespace DocumentDB +} // namespace GRDDB #endif // GRD_DB_API_INNER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_document_api_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_document_api_inner.h index 4011ede6107..d9034b50940 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_document_api_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_document_api_inner.h @@ -21,7 +21,7 @@ #include "grd_base/grd_resultset_api.h" #include "grd_base/grd_type_export.h" -namespace DocumentDB { +namespace GRDDB { int32_t GRD_CreateCollectionInner(GRD_DB *db, const char *collectionName, const char *optionStr, uint32_t flags); int32_t GRD_DropCollectionInner(GRD_DB *db, const char *collectionName, uint32_t flags); @@ -38,5 +38,5 @@ int32_t GRD_UpsertDocInner(GRD_DB *db, const char *collectionName, const char *f uint32_t flags); int32_t GRD_DeleteDocInner(GRD_DB *db, const char *collectionName, const char *filter, uint32_t flags); -} // namespace DocumentDB +} // namespace GRDDB #endif // GRD_DOCUMENT_API_INNER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_kv_api_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_kv_api_inner.h index f4e7a83e130..40907f58e6c 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_kv_api_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_kv_api_inner.h @@ -21,7 +21,7 @@ #include "grd_base/grd_resultset_api.h" #include "grd_base/grd_type_export.h" -namespace DocumentDB { +namespace GRDDB { int32_t GRD_KVPutInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT *key, const GRD_KVItemT *value); int32_t GRD_KVGetInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT *key, const GRD_KVItemT *value); @@ -50,5 +50,5 @@ int32_t GRD_KVBatchPutInner(GRD_DB *db, const char *collectionName, GRD_KVBatchT int32_t GRD_KVBatchDelInner(GRD_DB *db, const char *collectionName, GRD_KVBatchT *batch); int32_t GRD_KVBatchDestroyInner(GRD_KVBatchT *batch); -} // namespace DocumentDB +} // namespace GRDDB #endif // GRD_KV_API_INNER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_resultset_api_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_resultset_api_inner.h index 6c4ca6811b5..48fe1f2e70a 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_resultset_api_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_resultset_api_inner.h @@ -20,7 +20,7 @@ #include "grd_base/grd_type_export.h" -namespace DocumentDB { +namespace GRDDB { typedef struct GRD_ResultSet GRD_ResultSet; int32_t GRD_NextInner(GRD_ResultSet *resultSet); @@ -33,5 +33,5 @@ int32_t GRD_FetchInner(GRD_ResultSet *resultSet, GRD_KVItemT *key, GRD_KVItemT * int32_t GRD_FreeValueInner(char *value); int32_t GRD_FreeResultSetInner(GRD_ResultSet *resultSet); -} // namespace DocumentDB +} // namespace GRDDB #endif // GRD_RESULTSET_API_INNER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_resultset_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_resultset_inner.h index d840ad79370..54e625ac9eb 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_resultset_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_resultset_inner.h @@ -21,6 +21,6 @@ #include "result_set.h" typedef struct GRD_ResultSet { - DocumentDB::ResultSet resultSet_; + GRDDB::ResultSet resultSet_; } GRD_ResultSet; #endif // GRD_RESULTSET_INNER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_sequence_api_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_sequence_api_inner.h index 072f55e238b..5d43a0eb7f5 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_sequence_api_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_sequence_api_inner.h @@ -21,9 +21,9 @@ #include "grd_base/grd_resultset_api.h" #include "grd_base/grd_type_export.h" -namespace DocumentDB { +namespace GRDDB { int32_t GRD_CreateSeqInner(GRD_DB *db, const char *sequenceName, uint32_t flags); int32_t GRD_DropSeqInner(GRD_DB *db, const char *sequenceName, uint32_t flags); -} // namespace DocumentDB +} // namespace GRDDB #endif // GRD_SEQUENCE_API_INNER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h index f26f6ac4897..b1a567c5f6c 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h @@ -21,7 +21,7 @@ #include "grd_base/grd_error.h" typedef struct GRD_DB { - DocumentDB::DocumentStore *store_ = nullptr; + GRDDB::DocumentStore *store_ = nullptr; } GRD_DB; #endif // GRD_TYPE_INNER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api.cpp index 7f441a65f69..f3f52aa8daa 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api.cpp @@ -19,7 +19,7 @@ #include "grd_resultset_inner.h" #include "grd_type_inner.h" #include "rd_log_print.h" -using namespace DocumentDB; +using namespace GRDDB; static GRD_APIInfo GRD_KVApiInfo; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp index d491f828f7a..7b6deb495de 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp @@ -19,7 +19,7 @@ #include "grd_base/grd_error.h" #include "grd_type_inner.h" #include "rd_log_print.h" -namespace DocumentDB { +namespace GRDDB { int32_t GRD_KVPutInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT *key, const GRD_KVItemT *value) { return GRD_NOT_SUPPORT; @@ -87,4 +87,4 @@ int32_t GRD_KVBatchDestroyInner(GRD_KVBatchT *batch) { return GRD_NOT_SUPPORT; } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/collection.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/collection.h index 30d109eda40..d576194bcf4 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/collection.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/collection.h @@ -21,7 +21,7 @@ #include "check_common.h" #include "kv_store_executor.h" -namespace DocumentDB { +namespace GRDDB { class Collection { public: Collection(const std::string &name, KvStoreExecutor *executor); @@ -41,5 +41,5 @@ private: std::string name_; KvStoreExecutor *executor_ = nullptr; }; -} // namespace DocumentDB +} // namespace GRDDB #endif // COLLECTION_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/doc_errno.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/doc_errno.h index 4f8d1fe7e3c..7b1be9f81ef 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/doc_errno.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/doc_errno.h @@ -16,7 +16,7 @@ #ifndef DOC_ERRNO_H #define DOC_ERRNO_H -namespace DocumentDB { +namespace GRDDB { constexpr int E_OK = 0; constexpr int E_BASE = 1000; constexpr int E_ERROR = E_BASE + 1; @@ -44,5 +44,5 @@ constexpr int E_FAILED_FILE_OPERATION = E_BASE + 54; constexpr int E_NOT_SUPPORT = E_BASE + 55; int TransferDocErr(int err); -} // namespace DocumentDB +} // namespace GRDDB #endif // DOC_ERRNO_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_key.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_key.h index dc20f5fc846..89292025f97 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_key.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_key.h @@ -27,7 +27,7 @@ #define GRD_DOC_OID_HEX_SIZE (GRD_DOC_OID_SIZE * 2) #define GRD_DOC_ID_TYPE_SIZE 1 -namespace DocumentDB { +namespace GRDDB { enum class DocIdType { INT = 1, STRING, @@ -44,5 +44,5 @@ class DocumentKey { public: static int GetOidDocKey(DocKey &key); }; -} // namespace DocumentDB +} // namespace GRDDB #endif // DOCUMENT_KEY_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store.h index 3f1deacb927..d4266f23ccd 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store.h @@ -25,7 +25,7 @@ #include "kv_store_executor.h" struct GRD_ResultSet; -namespace DocumentDB { +namespace GRDDB { class DocumentStore { public: DocumentStore(KvStoreExecutor *); @@ -79,5 +79,5 @@ private: std::map collections_; std::function closeNotifier_; }; -} // namespace DocumentDB +} // namespace GRDDB #endif // DOCUMENT_STORE_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h index a1824bf5ba4..b01bf392010 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h @@ -21,7 +21,7 @@ #include "document_store.h" -namespace DocumentDB { +namespace GRDDB { class GRDStoreManager { public: static int GetDocumentStore(const std::string &path, const std::string &config, uint32_t flags, @@ -35,5 +35,5 @@ private: static std::mutex openCloseMutex_; static std::map dbConnCount_; }; -} // namespace DocumentDB +} // namespace GRDDB #endif // DOCUMENT_STORE_MANAGER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/projection_tree.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/projection_tree.h index 7d3b080b40c..bc110e82f16 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/projection_tree.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/projection_tree.h @@ -23,7 +23,7 @@ #include "json_common.h" #include "rd_log_print.h" -namespace DocumentDB { +namespace GRDDB { struct ProjectionNode { std::unordered_map sonNode; bool isDeepest; @@ -47,5 +47,5 @@ public: private: ProjectionNode node_; }; -} // namespace DocumentDB +} // namespace GRDDB #endif // PROJECTION_TREE_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h index a8a7e14cf7f..e7f9812fbb5 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h @@ -26,7 +26,7 @@ #include "grd_base/grd_type_export.h" #include "rd_json_object.h" -namespace DocumentDB { +namespace GRDDB { class ResultSet { public: ResultSet(); @@ -55,5 +55,5 @@ private: std::pair matchData_; std::string lastKeyIndex_; }; -} // namespace DocumentDB +} // namespace GRDDB #endif // RESULTSET_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h index abdf5c9b3ce..347ec10dd24 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h @@ -23,8 +23,8 @@ #include "result_set.h" #include "vector" -namespace DocumentDB { +namespace GRDDB { class ValueObject; int InitResultSet(std::shared_ptr &context, DocumentStore *store, ResultSet &resultSet, bool isCutBranch); -} // namespace DocumentDB +} // namespace GRDDB #endif // RESULTSET_COMMON_H diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp index 89f76030fff..6ccfc973cdc 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp @@ -21,7 +21,7 @@ #include "document_key.h" #include "rd_log_print.h" -namespace DocumentDB { +namespace GRDDB { Collection::Collection(const std::string &name, KvStoreExecutor *executor) : executor_(executor) { std::string lowerCaseName = name; @@ -151,4 +151,4 @@ int Collection::UpdateDocument(const std::string &id, const std::string &newDocu Value valSet(newDocument.begin(), newDocument.end()); return executor_->PutData(name_, keyId, valSet); } -} // namespace DocumentDB +} // namespace GRDDB diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/doc_errno.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/doc_errno.cpp index 3fe46256ee9..84f2638b5ff 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/doc_errno.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/doc_errno.cpp @@ -17,7 +17,7 @@ #include "grd_base/grd_error.h" -namespace DocumentDB { +namespace GRDDB { int GetErrorCategory(int errCode) { int categoryCode = errCode % 1000000; // 1000000: mod to get last 6 digits @@ -72,4 +72,4 @@ int TransferDocErr(int err) return GetErrorCategory(GRD_INNER_ERR); } } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_key.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_key.cpp index 1666428a466..cfbb276e9b3 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_key.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_key.cpp @@ -21,7 +21,7 @@ #include "rd_log_print.h" #include "securec.h" -namespace DocumentDB { +namespace GRDDB { static uint16_t g_oIdIncNum = 0; constexpr uint16_t MAX_NUMBER_OF_AUTOINCREMENTS = 65535; constexpr uint16_t UINT_ZERO = 0; @@ -53,4 +53,4 @@ int DocumentKey::GetOidDocKey(DocKey &key) int ret = InitDocIdFromOid(key); return ret; } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp index 9f4f9abbf16..2f42c165c2a 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp @@ -25,7 +25,7 @@ #include "result_set.h" #include "result_set_common.h" -namespace DocumentDB { +namespace GRDDB { constexpr int JSON_LENS_MAX = 1024 * 1024; constexpr const char *KEY_ID = "_id"; @@ -903,4 +903,4 @@ bool DocumentStore::IsCollectionExists(const std::string &collectionName, int &e } return executor_->IsCollectionExists(collectionName, errCode); } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp index 4d9a3143592..c8c648973ba 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp @@ -22,7 +22,7 @@ #include "os_api.h" #include "rd_log_print.h" -namespace DocumentDB { +namespace GRDDB { namespace { bool CheckDBOpenFlag(unsigned int flag) { @@ -153,4 +153,4 @@ int GRDStoreManager::CheckDBPath(const std::string &path, std::string &canonical return E_OK; } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/projection_tree.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/projection_tree.cpp index f33d694f32c..042981ca18a 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/projection_tree.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/projection_tree.cpp @@ -14,7 +14,7 @@ */ #include "projection_tree.h" -namespace DocumentDB { +namespace GRDDB { constexpr int JSON_DEEP_MAX = 4; static int ParseSinglePathToTree(ProjectionNode *node, std::vector &singlePath) @@ -89,4 +89,4 @@ int ProjectionNode::DeleteProjectionNode() } return E_OK; } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp index 439a5485682..b5866feb011 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp @@ -19,7 +19,7 @@ #include "rd_log_print.h" #include "securec.h" -namespace DocumentDB { +namespace GRDDB { constexpr const char *KEY_ID = "_id"; ResultSet::ResultSet() {} @@ -296,4 +296,4 @@ int ResultSet::CutJsonBranch(std::string &jsonKey, std::string &jsonData) jsonData = cjsonObj.Print(); return E_OK; } -} // namespace DocumentDB +} // namespace GRDDB diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp index dd9acaeb265..060784e4d6a 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp @@ -18,7 +18,7 @@ #include "doc_errno.h" #include "grd_base/grd_error.h" -namespace DocumentDB { +namespace GRDDB { class ValueObject; int InitResultSet(std::shared_ptr &context, DocumentStore *store, ResultSet &resultSet, bool isCutBranch) { @@ -36,4 +36,4 @@ int InitResultSet(std::shared_ptr &context, DocumentStore *store, } return resultSet.Init(context, store, isCutBranch); } -} // namespace DocumentDB +} // namespace GRDDB diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/kv_store_executor.h b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/kv_store_executor.h index a12bda14fae..8d48c3bf710 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/kv_store_executor.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/kv_store_executor.h @@ -20,7 +20,7 @@ #include "check_common.h" -namespace DocumentDB { +namespace GRDDB { class KvStoreExecutor { public: virtual ~KvStoreExecutor() = default; @@ -44,5 +44,5 @@ public: virtual int SetCollectionOption(const std::string &name, const std::string &option) = 0; virtual int CleanCollectionOption(const std::string &name) = 0; }; -} // namespace DocumentDB +} // namespace GRDDB #endif // KV_STORE_EXECUTOR_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/kv_store_manager.h b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/kv_store_manager.h index 5589c20aa18..f6e7567bb8a 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/kv_store_manager.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/kv_store_manager.h @@ -21,11 +21,11 @@ #include "db_config.h" #include "kv_store_executor.h" -namespace DocumentDB { +namespace GRDDB { class KvStoreManager { public: static int GetKvStore(const std::string &path, const DBConfig &config, bool isFirstOpen, KvStoreExecutor *&executor); }; -} // namespace DocumentDB +} // namespace GRDDB #endif // KV_STORE_MANAGER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/rd_json_object.h b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/rd_json_object.h index dad46abc339..d925e7e3e9d 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/rd_json_object.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/rd_json_object.h @@ -30,7 +30,7 @@ typedef void cJSON; #endif -namespace DocumentDB { +namespace GRDDB { class ValueObject { public: enum class ValueType { @@ -116,5 +116,5 @@ private: bool isOwner_ = false; bool caseSensitive_ = false; }; -} // namespace DocumentDB +} // namespace GRDDB #endif // JSON_OBJECT_H diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/kv_store_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/kv_store_manager.cpp index 26fb8421780..255377d3433 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/kv_store_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/kv_store_manager.cpp @@ -20,7 +20,7 @@ #include "rd_sqlite_utils.h" #include "sqlite_store_executor_impl.h" -namespace DocumentDB { +namespace GRDDB { int KvStoreManager::GetKvStore(const std::string &path, const DBConfig &config, bool isFirstOpen, KvStoreExecutor *&executor) { @@ -70,4 +70,4 @@ END: delete sqliteExecutor; return errCode; } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_json_object.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_json_object.cpp index 1b469f2c410..6edbf715b52 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_json_object.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_json_object.cpp @@ -23,7 +23,7 @@ #include "json_common.h" #include "rd_log_print.h" -namespace DocumentDB { +namespace GRDDB { #ifndef OMIT_cJSON ValueObject::ValueObject(bool val) { @@ -940,4 +940,4 @@ int JsonObject::DeleteItemDeeplyOnTarget(const JsonFieldPath &path) return E_OK; } #endif -} // namespace DocumentDB +} // namespace GRDDB diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp index 27bef4c14ad..6f115738562 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp @@ -19,7 +19,7 @@ #include "doc_errno.h" #include "rd_log_print.h" -namespace DocumentDB { +namespace GRDDB { const int MAX_BLOB_READ_SIZE = 5 * 1024 * 1024; // 5M limit const int BUSY_TIMEOUT_MS = 3000; // 3000ms for sqlite busy timeout. const std::string BEGIN_SQL = "BEGIN TRANSACTION"; @@ -282,4 +282,4 @@ END: (void)RDSQLiteUtils::ResetStatement(stmt, true); return MapSqliteError(errCode); } -} // namespace DocumentDB +} // namespace GRDDB diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.h b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.h index 32e422c3847..4c82c7211d9 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.h @@ -22,7 +22,7 @@ #include "sqlite3sym.h" -namespace DocumentDB { +namespace GRDDB { enum class TransactType { DEFERRED, IMMEDIATE, @@ -52,5 +52,5 @@ public: private: static void SqliteLogCallback(void *data, int err, const char *msg); }; -} // namespace DocumentDB +} // namespace GRDDB #endif // SQLITE_UTILS_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp index 5360652478c..5bc30b4bcc0 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp @@ -22,7 +22,7 @@ #include "rd_log_print.h" #include "rd_sqlite_utils.h" -namespace DocumentDB { +namespace GRDDB { constexpr const uint8_t KEY_TYPE = uint8_t(DocIdType::STRING); int SqliteStoreExecutorImpl::CreateDatabase(const std::string &path, const DBConfig &config, sqlite3 *&db) { @@ -409,4 +409,4 @@ int SqliteStoreExecutorImpl::CleanCollectionOption(const std::string &name) Key collOptKey = { collOptKeyStr.begin(), collOptKeyStr.end() }; return DelData("grd_meta", collOptKey); } -} // namespace DocumentDB \ No newline at end of file +} // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.h b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.h index 8da9ed30f3d..e71ca8e3f51 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.h @@ -21,7 +21,7 @@ #include "kv_store_executor.h" #include "sqlite3.h" -namespace DocumentDB { +namespace GRDDB { class SqliteStoreExecutorImpl : public KvStoreExecutor { public: static int CreateDatabase(const std::string &path, const DBConfig &config, sqlite3 *&db); @@ -55,5 +55,5 @@ public: private: sqlite3 *dbHandle_ = nullptr; }; -} // namespace DocumentDB +} // namespace GRDDB #endif // SQLITE_STORE_EXECUTOR_IMPL_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp index 7232eab6d8b..5a2e8eba22f 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp @@ -24,7 +24,7 @@ #include "rd_log_print.h" #include "rd_sqlite_utils.h" -using namespace DocumentDB; +using namespace GRDDB; using namespace testing::ext; using namespace DocumentDBUnitTest; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_collection_test.cpp b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_collection_test.cpp index 1f9c8a67f46..fae995e4374 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_collection_test.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_collection_test.cpp @@ -23,7 +23,7 @@ #include "rd_log_print.h" #include "rd_sqlite_utils.h" -using namespace DocumentDB; +using namespace GRDDB; using namespace testing::ext; using namespace DocumentDBUnitTest; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_data_test.cpp b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_data_test.cpp index d2f49d31fa7..9955b787a74 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_data_test.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_data_test.cpp @@ -24,7 +24,7 @@ #include "rd_log_print.h" #include "rd_sqlite_utils.h" -using namespace DocumentDB; +using namespace GRDDB; using namespace testing::ext; using namespace DocumentDBUnitTest; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_find_test.cpp b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_find_test.cpp index 44515ca6b43..7d44b2e1a7f 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_find_test.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_find_test.cpp @@ -93,10 +93,10 @@ static void InsertData(GRD_DB *g_db, const char *collectionName) static void CompareValue(const char *value, const char *targetValue) { int errCode; - DocumentDB::JsonObject valueObj = DocumentDB::JsonObject::Parse(value, errCode); - EXPECT_EQ(errCode, DocumentDB::E_OK); - DocumentDB::JsonObject targetValueObj = DocumentDB::JsonObject::Parse(targetValue, errCode); - EXPECT_EQ(errCode, DocumentDB::E_OK); + GRDDB::JsonObject valueObj = GRDDB::JsonObject::Parse(value, errCode); + EXPECT_EQ(errCode, GRDDB::E_OK); + GRDDB::JsonObject targetValueObj = GRDDB::JsonObject::Parse(targetValue, errCode); + EXPECT_EQ(errCode, GRDDB::E_OK); EXPECT_EQ(valueObj.Print(), targetValueObj.Print()); } diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_json_common_test.cpp b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_json_common_test.cpp index 4ad61a33080..0902e60e43a 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_json_common_test.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_json_common_test.cpp @@ -21,7 +21,7 @@ #include "json_common.h" #include "rd_log_print.h" -using namespace DocumentDB; +using namespace GRDDB; using namespace testing::ext; using namespace DocumentDBUnitTest; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_jsonobject_test.cpp b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_jsonobject_test.cpp index 45e79c8dc12..cb2eda80617 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_jsonobject_test.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_jsonobject_test.cpp @@ -19,7 +19,7 @@ #include "documentdb_test_utils.h" #include "rd_json_object.h" -using namespace DocumentDB; +using namespace GRDDB; using namespace testing::ext; using namespace DocumentDBUnitTest; diff --git a/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/json_fuzzer.cpp b/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/json_fuzzer.cpp index 8b4ff2d79c1..df00e982c35 100644 --- a/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/json_fuzzer.cpp +++ b/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/json_fuzzer.cpp @@ -1407,7 +1407,7 @@ void FreeResultSetFuzz() GRD_ResultSet *resultSet = nullptr; GRD_FreeResultSet(resultSet); resultSet = new GRD_ResultSet; - resultSet->resultSet_ = DocumentDB::ResultSet(); + resultSet->resultSet_ = GRDDB::ResultSet(); GRD_FreeResultSet(resultSet); GRD_DropCollection(g_db, COLLECTION_NAME, 0); } diff --git a/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/jsoninner_fuzzer.cpp b/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/jsoninner_fuzzer.cpp index d619d966027..f9f42aba449 100644 --- a/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/jsoninner_fuzzer.cpp +++ b/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/jsoninner_fuzzer.cpp @@ -43,7 +43,7 @@ #include "grd_type_inner.h" #include "securec.h" -using namespace DocumentDB; +using namespace GRDDB; const char *TEST_DB = "./data"; const char *TEST_DB_FILE = "./data/testfile"; @@ -1416,7 +1416,7 @@ void FreeResultSetFuzz() GRD_ResultSet *resultSet = nullptr; GRD_FreeResultSetInner(resultSet); resultSet = new GRD_ResultSet; - resultSet->resultSet_ = DocumentDB::ResultSet(); + resultSet->resultSet_ = GRDDB::ResultSet(); GRD_FreeResultSetInner(resultSet); GRD_DropCollectionInner(g_db, COLLECTION_NAME, 0); } -- Gitee From efad0690cfa54f1d206c910fb2555a8e74bd8c9a Mon Sep 17 00:00:00 2001 From: bluhuang Date: Sat, 9 Nov 2024 16:45:45 +0800 Subject: [PATCH 03/21] change store manager api name Signed-off-by: bluhuang --- .../gaussdb_rd/src/executor/base/grd_db_api_inner.cpp | 6 +++--- .../src/interface/include/document_store_manager.h | 4 ++-- .../gaussdb_rd/src/interface/src/document_store_manager.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp index 9aaeb6f45e2..9f140e05f66 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp @@ -30,14 +30,14 @@ int32_t GRD_DBOpenInner(const char *dbPath, const char *configStr, uint32_t flag std::string path = (dbPath == nullptr ? "" : dbPath); std::string config = (configStr == nullptr ? "" : configStr); DocumentStore *store = nullptr; - int ret = GRDStoreManager::GetDocumentStore(path, config, flags, store); + int ret = GRDStoreManager::GetGRDStore(path, config, flags, store); if (ret != E_OK || store == nullptr) { return TransferDocErr(ret); } *db = new (std::nothrow) GRD_DB(); if (*db == nullptr) { - (void)GRDStoreManager::CloseDocumentStore(store, GRD_DB_CLOSE_IGNORE_ERROR); + (void)GRDStoreManager::CloseGRDStore(store, GRD_DB_CLOSE_IGNORE_ERROR); store = nullptr; return GRD_FAILED_MEMORY_ALLOCATE; } @@ -52,7 +52,7 @@ int32_t GRD_DBCloseInner(GRD_DB *db, uint32_t flags) return GRD_INVALID_ARGS; } - int ret = GRDStoreManager::CloseDocumentStore(db->store_, flags); + int ret = GRDStoreManager::CloseGRDStore(db->store_, flags); if (ret != E_OK) { return TransferDocErr(ret); } diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h index b01bf392010..5f72de5e5ec 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h @@ -24,10 +24,10 @@ namespace GRDDB { class GRDStoreManager { public: - static int GetDocumentStore(const std::string &path, const std::string &config, uint32_t flags, + static int GetGRDStore(const std::string &path, const std::string &config, uint32_t flags, DocumentStore *&store); - static int CloseDocumentStore(DocumentStore *store, uint32_t flags); + static int CloseGRDStore(DocumentStore *store, uint32_t flags); private: static int CheckDBPath(const std::string &path, std::string &canonicalPath, std::string &dbName); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp index c8c648973ba..12aa0f1b158 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp @@ -49,7 +49,7 @@ bool CheckDBCreate(uint32_t flags, const std::string &path) std::mutex GRDStoreManager::openCloseMutex_; std::map GRDStoreManager::dbConnCount_; -int GRDStoreManager::GetDocumentStore(const std::string &path, const std::string &config, uint32_t flags, +int GRDStoreManager::GetGRDStore(const std::string &path, const std::string &config, uint32_t flags, DocumentStore *&store) { std::string canonicalPath; @@ -107,7 +107,7 @@ int GRDStoreManager::GetDocumentStore(const std::string &path, const std::string return errCode; } -int GRDStoreManager::CloseDocumentStore(DocumentStore *store, uint32_t flags) +int GRDStoreManager::CloseGRDStore(DocumentStore *store, uint32_t flags) { if (!CheckDBCloseFlag(flags)) { GLOGE("Check document db close flags failed."); -- Gitee From ab199e4f13751666cd5818b35fba1c9bae07acf3 Mon Sep 17 00:00:00 2001 From: bluhuang Date: Sat, 9 Nov 2024 16:48:39 +0800 Subject: [PATCH 04/21] change documentStore to GRDDocumentStore Signed-off-by: bluhuang --- .../src/executor/base/grd_db_api_inner.cpp | 2 +- .../src/executor/include/grd_type_inner.h | 2 +- .../src/interface/include/document_store.h | 6 +-- .../include/document_store_manager.h | 4 +- .../src/interface/include/result_set.h | 4 +- .../src/interface/include/result_set_common.h | 2 +- .../src/interface/src/document_store.cpp | 46 +++++++++---------- .../interface/src/document_store_manager.cpp | 6 +-- .../src/interface/src/result_set.cpp | 2 +- .../src/interface/src/result_set_common.cpp | 2 +- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp index 9f140e05f66..d2c2a31fab0 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp @@ -29,7 +29,7 @@ int32_t GRD_DBOpenInner(const char *dbPath, const char *configStr, uint32_t flag } std::string path = (dbPath == nullptr ? "" : dbPath); std::string config = (configStr == nullptr ? "" : configStr); - DocumentStore *store = nullptr; + GRDDocumentStore *store = nullptr; int ret = GRDStoreManager::GetGRDStore(path, config, flags, store); if (ret != E_OK || store == nullptr) { return TransferDocErr(ret); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h index b1a567c5f6c..8595f57347b 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h @@ -21,7 +21,7 @@ #include "grd_base/grd_error.h" typedef struct GRD_DB { - GRDDB::DocumentStore *store_ = nullptr; + GRDDB::GRDDocumentStore *store_ = nullptr; } GRD_DB; #endif // GRD_TYPE_INNER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store.h index d4266f23ccd..9377fefc7bb 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store.h @@ -26,10 +26,10 @@ struct GRD_ResultSet; namespace GRDDB { -class DocumentStore { +class GRDDocumentStore { public: - DocumentStore(KvStoreExecutor *); - ~DocumentStore(); + GRDDocumentStore(KvStoreExecutor *); + ~GRDDocumentStore(); int CreateCollection(const std::string &name, const std::string &option, uint32_t flags); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h index 5f72de5e5ec..4ddc75b542f 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h @@ -25,9 +25,9 @@ namespace GRDDB { class GRDStoreManager { public: static int GetGRDStore(const std::string &path, const std::string &config, uint32_t flags, - DocumentStore *&store); + GRDDocumentStore *&store); - static int CloseGRDStore(DocumentStore *store, uint32_t flags); + static int CloseGRDStore(GRDDocumentStore *store, uint32_t flags); private: static int CheckDBPath(const std::string &path, std::string &canonicalPath, std::string &dbName); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h index e7f9812fbb5..a8876ddb2f4 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h @@ -31,7 +31,7 @@ class ResultSet { public: ResultSet(); ~ResultSet(); - int Init(std::shared_ptr &context, DocumentStore *store, bool isCutBranch); + int Init(std::shared_ptr &context, GRDDocumentStore *store, bool isCutBranch); int GetNext(bool isNeedTransaction = false, bool isNeedCheckTable = false); int GetValue(char **value); int GetValue(std::string &value); @@ -48,7 +48,7 @@ private: int CutJsonBranchInner(JsonObject &cjsonObj, bool viewType, bool isIdExistInValue, bool &isInsertIdflag); - DocumentStore *store_ = nullptr; + GRDDocumentStore *store_ = nullptr; bool isCutBranch_ = false; size_t index_ = 0; std::shared_ptr context_; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h index 347ec10dd24..5704c5b3230 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h @@ -25,6 +25,6 @@ namespace GRDDB { class ValueObject; -int InitResultSet(std::shared_ptr &context, DocumentStore *store, ResultSet &resultSet, bool isCutBranch); +int InitResultSet(std::shared_ptr &context, GRDDocumentStore *store, ResultSet &resultSet, bool isCutBranch); } // namespace GRDDB #endif // RESULTSET_COMMON_H diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp index 2f42c165c2a..125b19f77c0 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp @@ -29,14 +29,14 @@ namespace GRDDB { constexpr int JSON_LENS_MAX = 1024 * 1024; constexpr const char *KEY_ID = "_id"; -DocumentStore::DocumentStore(KvStoreExecutor *executor) : executor_(executor) {} +GRDDocumentStore::GRDDocumentStore(KvStoreExecutor *executor) : executor_(executor) {} -DocumentStore::~DocumentStore() +GRDDocumentStore::~GRDDocumentStore() { delete executor_; } -int DocumentStore::CreateCollection(const std::string &name, const std::string &option, uint32_t flags) +int GRDDocumentStore::CreateCollection(const std::string &name, const std::string &option, uint32_t flags) { std::string lowerCaseName; int errCode = E_OK; @@ -82,7 +82,7 @@ END: return errCode; } -int DocumentStore::DropCollection(const std::string &name, uint32_t flags) +int GRDDocumentStore::DropCollection(const std::string &name, uint32_t flags) { std::string lowerCaseName; int errCode = E_OK; @@ -205,7 +205,7 @@ int GetUpDataRePlaceData(ResultSet &resultSet, const std::string &id, const std: return errCode; } -int DocumentStore::UpdateDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, +int GRDDocumentStore::UpdateDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, const std::string &update, bool &isReplace) { std::lock_guard lock(dbMutex_); @@ -254,7 +254,7 @@ END: return (errCode == E_OK) ? count : errCode; } -int DocumentStore::UpdateDocument(const std::string &collection, const std::string &filter, const std::string &update, +int GRDDocumentStore::UpdateDocument(const std::string &collection, const std::string &filter, const std::string &update, uint32_t flags) { int errCode = UpdateArgsCheck(collection, filter, update, flags); @@ -379,7 +379,7 @@ int InsertIdToDocument(ResultSet &resultSet, JsonObject &filterObj, JsonObject & return errCode; } -int DocumentStore::UpsertDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, +int GRDDocumentStore::UpsertDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, const std::string &document, JsonObject &documentObj, bool &isReplace) { std::lock_guard lock(dbMutex_); @@ -442,7 +442,7 @@ int UpsertDocumentFormatCheck(const std::string &document, JsonObject &documentO return errCode; } -int DocumentStore::UpsertDocument(const std::string &collection, const std::string &filter, +int GRDDocumentStore::UpsertDocument(const std::string &collection, const std::string &filter, const std::string &document, uint32_t flags) { int errCode = UpsertArgsCheck(collection, filter, document, flags); @@ -499,7 +499,7 @@ int InsertArgsCheck(const std::string &collection, const std::string &document, return errCode; } -int DocumentStore::InsertDataIntoDB(const std::string &collection, const std::string &document, +int GRDDocumentStore::InsertDataIntoDB(const std::string &collection, const std::string &document, JsonObject &documentObj, bool &isIdExist) { std::lock_guard lock(dbMutex_); @@ -517,7 +517,7 @@ int DocumentStore::InsertDataIntoDB(const std::string &collection, const std::st return coll.InsertDocument(id, document, isIdExist); } -int DocumentStore::InsertDocument(const std::string &collection, const std::string &document, uint32_t flags) +int GRDDocumentStore::InsertDocument(const std::string &collection, const std::string &document, uint32_t flags) { int errCode = InsertArgsCheck(collection, document, flags); if (errCode != E_OK) { @@ -559,7 +559,7 @@ int DeleteArgsCheck(const std::string &collection, const std::string &filter, ui return errCode; } -int DocumentStore::DeleteDataFromDB(std::shared_ptr &context, JsonObject &filterObj) +int GRDDocumentStore::DeleteDataFromDB(std::shared_ptr &context, JsonObject &filterObj) { std::lock_guard lock(dbMutex_); if (executor_ == nullptr) { @@ -593,7 +593,7 @@ END: } return errCode; } -int DocumentStore::DeleteDocument(const std::string &collection, const std::string &filter, uint32_t flags) +int GRDDocumentStore::DeleteDocument(const std::string &collection, const std::string &filter, uint32_t flags) { int errCode = DeleteArgsCheck(collection, filter, flags); if (errCode != E_OK) { @@ -615,7 +615,7 @@ int DocumentStore::DeleteDocument(const std::string &collection, const std::stri context->collectionName = collection; return DeleteDataFromDB(context, filterObj); } -Collection DocumentStore::GetCollection(std::string &collectionName) +Collection GRDDocumentStore::GetCollection(std::string &collectionName) { return Collection(collectionName, executor_); } @@ -763,7 +763,7 @@ int FindProjectionInit(const std::string &projection, const std::shared_ptr &context) +int GRDDocumentStore::InitFindResultSet(GRD_ResultSet *grdResultSet, std::shared_ptr &context) { std::lock_guard lock(dbMutex_); int errCode = E_OK; @@ -798,7 +798,7 @@ END: return errCode; } -int DocumentStore::FindDocument(const std::string &collection, const std::string &filter, +int GRDDocumentStore::FindDocument(const std::string &collection, const std::string &filter, const std::string &projection, uint32_t flags, GRD_ResultSet *grdResultSet) { int errCode = FindArgsCheck(collection, filter, projection, flags); @@ -834,7 +834,7 @@ int DocumentStore::FindDocument(const std::string &collection, const std::string return InitFindResultSet(grdResultSet, context); } -bool DocumentStore::IsExistResultSet(const std::string &collection) +bool GRDDocumentStore::IsExistResultSet(const std::string &collection) { if (collections_.find(collection) != collections_.end()) { GLOGE("DB is resource busy"); @@ -843,7 +843,7 @@ bool DocumentStore::IsExistResultSet(const std::string &collection) return false; } -int DocumentStore::EraseCollection(const std::string &collectionName) +int GRDDocumentStore::EraseCollection(const std::string &collectionName) { std::lock_guard lock(dbMutex_); if (collections_.find(collectionName) != collections_.end()) { @@ -854,12 +854,12 @@ int DocumentStore::EraseCollection(const std::string &collectionName) return E_INVALID_ARGS; } -void DocumentStore::OnClose(const std::function ¬ifier) +void GRDDocumentStore::OnClose(const std::function ¬ifier) { closeNotifier_ = notifier; } -int DocumentStore::Close(uint32_t flags) +int GRDDocumentStore::Close(uint32_t flags) { std::lock_guard lock(dbMutex_); if (flags == GRD_DB_CLOSE && !collections_.empty()) { @@ -873,21 +873,21 @@ int DocumentStore::Close(uint32_t flags) return E_OK; } -int DocumentStore::StartTransaction() +int GRDDocumentStore::StartTransaction() { if (executor_ == nullptr) { return -E_INNER_ERROR; } return executor_->StartTransaction(); } -int DocumentStore::Commit() +int GRDDocumentStore::Commit() { if (executor_ == nullptr) { return -E_INNER_ERROR; } return executor_->Commit(); } -int DocumentStore::Rollback() +int GRDDocumentStore::Rollback() { if (executor_ == nullptr) { return -E_INNER_ERROR; @@ -895,7 +895,7 @@ int DocumentStore::Rollback() return executor_->Rollback(); } -bool DocumentStore::IsCollectionExists(const std::string &collectionName, int &errCode) +bool GRDDocumentStore::IsCollectionExists(const std::string &collectionName, int &errCode) { if (executor_ == nullptr) { errCode = -E_INNER_ERROR; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp index 12aa0f1b158..a668c5c14de 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp @@ -50,7 +50,7 @@ std::mutex GRDStoreManager::openCloseMutex_; std::map GRDStoreManager::dbConnCount_; int GRDStoreManager::GetGRDStore(const std::string &path, const std::string &config, uint32_t flags, - DocumentStore *&store) + GRDDocumentStore *&store) { std::string canonicalPath; std::string dbName; @@ -88,7 +88,7 @@ int GRDStoreManager::GetGRDStore(const std::string &path, const std::string &con return errCode; } - store = new (std::nothrow) DocumentStore(executor); + store = new (std::nothrow) GRDDocumentStore(executor); if (store == nullptr) { delete executor; GLOGE("Memory allocation failed!"); @@ -107,7 +107,7 @@ int GRDStoreManager::GetGRDStore(const std::string &path, const std::string &con return errCode; } -int GRDStoreManager::CloseGRDStore(DocumentStore *store, uint32_t flags) +int GRDStoreManager::CloseGRDStore(GRDDocumentStore *store, uint32_t flags) { if (!CheckDBCloseFlag(flags)) { GLOGE("Check document db close flags failed."); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp index b5866feb011..9f1d1045be0 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp @@ -34,7 +34,7 @@ int ResultSet::EraseCollection() } return E_OK; } -int ResultSet::Init(std::shared_ptr &context, DocumentStore *store, bool isCutBranch) +int ResultSet::Init(std::shared_ptr &context, GRDDocumentStore *store, bool isCutBranch) { isCutBranch_ = isCutBranch; context_ = context; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp index 060784e4d6a..0ec84e92523 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp @@ -20,7 +20,7 @@ namespace GRDDB { class ValueObject; -int InitResultSet(std::shared_ptr &context, DocumentStore *store, ResultSet &resultSet, bool isCutBranch) +int InitResultSet(std::shared_ptr &context, GRDDocumentStore *store, ResultSet &resultSet, bool isCutBranch) { if (isCutBranch) { for (const auto &singlePath : context->projectionPath) { -- Gitee From cea642d29446095117ca2e06ca9272c102ed4d1f Mon Sep 17 00:00:00 2001 From: bluhuang Date: Sat, 9 Nov 2024 16:53:33 +0800 Subject: [PATCH 05/21] change file name Signed-off-by: bluhuang --- frameworks/libs/distributeddb/distributeddb.gni | 4 ++-- frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn | 4 ++-- .../gaussdb_rd/src/common/src/grd_api_manager.cpp | 2 +- .../gaussdb_rd/src/executor/base/grd_db_api.cpp | 2 +- .../gaussdb_rd/src/executor/base/grd_db_api_inner.cpp | 2 +- .../gaussdb_rd/src/executor/include/grd_type_inner.h | 2 +- .../include/{document_store.h => grd_document_store.h} | 0 .../{document_store_manager.h => grd_store_manager.h} | 8 ++++---- .../gaussdb_rd/src/interface/include/result_set.h | 2 +- .../gaussdb_rd/src/interface/src/document_store.cpp | 2 +- .../src/interface/src/document_store_manager.cpp | 2 +- .../libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn | 4 ++-- frameworks/libs/distributeddb/test/BUILD.gn | 4 ++-- .../libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn | 4 ++-- .../distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn | 4 ++-- 15 files changed, 23 insertions(+), 23 deletions(-) rename frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/{document_store.h => grd_document_store.h} (100%) rename frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/{document_store_manager.h => grd_store_manager.h} (89%) diff --git a/frameworks/libs/distributeddb/distributeddb.gni b/frameworks/libs/distributeddb/distributeddb.gni index 620289b4b69..36865498e07 100755 --- a/frameworks/libs/distributeddb/distributeddb.gni +++ b/frameworks/libs/distributeddb/distributeddb.gni @@ -280,8 +280,8 @@ distributeddb_src_rd = [ "${distributeddb_path}/gaussdb_rd/src/interface/src/collection.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/doc_errno.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/document_key.cpp", - "${distributeddb_path}/gaussdb_rd/src/interface/src/document_store.cpp", - "${distributeddb_path}/gaussdb_rd/src/interface/src/document_store_manager.cpp", + "${distributeddb_path}/gaussdb_rd/src/interface/src/grd_document_store.cpp", + "${distributeddb_path}/gaussdb_rd/src/interface/src/grd_store_manager.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/projection_tree.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/result_set.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/result_set_common.cpp", diff --git a/frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn b/frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn index 96499b75b06..8687f34cf83 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn +++ b/frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn @@ -78,8 +78,8 @@ ohos_static_library("gaussdb_rd") { "src/interface/src/collection.cpp", "src/interface/src/doc_errno.cpp", "src/interface/src/document_key.cpp", - "src/interface/src/document_store.cpp", - "src/interface/src/document_store_manager.cpp", + "src/interface/src/grd_document_store.cpp", + "src/interface/src/grd_store_manager.cpp", "src/interface/src/projection_tree.cpp", "src/interface/src/result_set.cpp", "src/interface/src/result_set_common.cpp", diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp index 4676a939a77..d96c0b90d5a 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp @@ -21,7 +21,7 @@ #include "check_common.h" #include "doc_errno.h" -#include "document_store_manager.h" +#include "grd_store_manager.h" #include "grd_base/grd_error.h" #include "grd_db_api_inner.h" #include "grd_document_api_inner.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp index b3d5881aa89..112291ddfd7 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp @@ -16,7 +16,7 @@ #include "check_common.h" #include "doc_errno.h" -#include "document_store_manager.h" +#include "grd_store_manager.h" #include "grd_api_manager.h" #include "grd_base/grd_error.h" #include "grd_type_inner.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp index d2c2a31fab0..f64f4ebb993 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp @@ -15,7 +15,7 @@ #include "grd_db_api_inner.h" #include "check_common.h" #include "doc_errno.h" -#include "document_store_manager.h" +#include "grd_store_manager.h" #include "grd_api_manager.h" #include "grd_base/grd_error.h" #include "grd_type_inner.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h index 8595f57347b..d833e6a40a4 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h @@ -17,7 +17,7 @@ #define GRD_TYPE_INNER_H #include "doc_errno.h" -#include "document_store.h" +#include "grd_document_store.h" #include "grd_base/grd_error.h" typedef struct GRD_DB { diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_document_store.h similarity index 100% rename from frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store.h rename to frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_document_store.h diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_manager.h similarity index 89% rename from frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h rename to frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_manager.h index 4ddc75b542f..c964819c99a 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/document_store_manager.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_manager.h @@ -13,13 +13,13 @@ * limitations under the License. */ -#ifndef DOCUMENT_STORE_MANAGER_H -#define DOCUMENT_STORE_MANAGER_H +#ifndef GRD_STORE_MANAGER_H +#define GRD_STORE_MANAGER_H #include #include -#include "document_store.h" +#include "grd_document_store.h" namespace GRDDB { class GRDStoreManager { @@ -36,4 +36,4 @@ private: static std::map dbConnCount_; }; } // namespace GRDDB -#endif // DOCUMENT_STORE_MANAGER_H \ No newline at end of file +#endif // GRD_STORE_MANAGER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h index a8876ddb2f4..ed09f094c3c 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h @@ -22,7 +22,7 @@ #include "check_common.h" #include "doc_errno.h" -#include "document_store.h" +#include "grd_document_store.h" #include "grd_base/grd_type_export.h" #include "rd_json_object.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp index 125b19f77c0..63be4c93cb3 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "document_store.h" +#include "grd_document_store.h" #include "check_common.h" #include "collection_option.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp index a668c5c14de..bf8b7a665f3 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "document_store_manager.h" +#include "grd_store_manager.h" #include "db_config.h" #include "doc_errno.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn index a23631f3df2..7b4b8ddcf4a 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn @@ -63,8 +63,8 @@ ohos_source_set("src_file") { "../../src/interface/src/collection.cpp", "../../src/interface/src/doc_errno.cpp", "../../src/interface/src/document_key.cpp", - "../../src/interface/src/document_store.cpp", - "../../src/interface/src/document_store_manager.cpp", + "../../src/interface/src/grd_document_store.cpp", + "../../src/interface/src/grd_store_manager.cpp", "../../src/interface/src/projection_tree.cpp", "../../src/interface/src/result_set.cpp", "../../src/interface/src/result_set_common.cpp", diff --git a/frameworks/libs/distributeddb/test/BUILD.gn b/frameworks/libs/distributeddb/test/BUILD.gn index d564778816d..858e03f8c56 100644 --- a/frameworks/libs/distributeddb/test/BUILD.gn +++ b/frameworks/libs/distributeddb/test/BUILD.gn @@ -144,8 +144,8 @@ ohos_source_set("src_file") { "../gaussdb_rd/src/interface/src/collection.cpp", "../gaussdb_rd/src/interface/src/doc_errno.cpp", "../gaussdb_rd/src/interface/src/document_key.cpp", - "../gaussdb_rd/src/interface/src/document_store.cpp", - "../gaussdb_rd/src/interface/src/document_store_manager.cpp", + "../gaussdb_rd/src/interface/src/grd_document_store.cpp", + "../gaussdb_rd/src/interface/src/grd_store_manager.cpp", "../gaussdb_rd/src/interface/src/projection_tree.cpp", "../gaussdb_rd/src/interface/src/result_set.cpp", "../gaussdb_rd/src/interface/src/result_set_common.cpp", diff --git a/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn b/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn index 48bf2bc8c10..f008495a9af 100644 --- a/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn +++ b/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn @@ -63,8 +63,8 @@ ohos_source_set("src_file") { "../../../gaussdb_rd/src/interface/src/collection.cpp", "../../../gaussdb_rd/src/interface/src/doc_errno.cpp", "../../../gaussdb_rd/src/interface/src/document_key.cpp", - "../../../gaussdb_rd/src/interface/src/document_store.cpp", - "../../../gaussdb_rd/src/interface/src/document_store_manager.cpp", + "../../../gaussdb_rd/src/interface/src/grd_document_store.cpp", + "../../../gaussdb_rd/src/interface/src/grd_store_manager.cpp", "../../../gaussdb_rd/src/interface/src/projection_tree.cpp", "../../../gaussdb_rd/src/interface/src/result_set.cpp", "../../../gaussdb_rd/src/interface/src/result_set_common.cpp", diff --git a/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn b/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn index d3823c7e39a..eea027df99f 100644 --- a/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn +++ b/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn @@ -63,8 +63,8 @@ ohos_source_set("src_file") { "../../../gaussdb_rd/src/interface/src/collection.cpp", "../../../gaussdb_rd/src/interface/src/doc_errno.cpp", "../../../gaussdb_rd/src/interface/src/document_key.cpp", - "../../../gaussdb_rd/src/interface/src/document_store.cpp", - "../../../gaussdb_rd/src/interface/src/document_store_manager.cpp", + "../../../gaussdb_rd/src/interface/src/grd_document_store.cpp", + "../../../gaussdb_rd/src/interface/src/grd_store_manager.cpp", "../../../gaussdb_rd/src/interface/src/projection_tree.cpp", "../../../gaussdb_rd/src/interface/src/result_set.cpp", "../../../gaussdb_rd/src/interface/src/result_set_common.cpp", -- Gitee From fc13b7ec9ed45a46e2c8a5e4584b8449cddc528a Mon Sep 17 00:00:00 2001 From: bluhuang Date: Mon, 11 Nov 2024 11:51:06 +0800 Subject: [PATCH 06/21] change grd_document_store to grd_stroe Signed-off-by: bluhuang --- .../libs/distributeddb/distributeddb.gni | 2 +- .../libs/distributeddb/gaussdb_rd/BUILD.gn | 2 +- .../src/executor/base/grd_db_api_inner.cpp | 2 +- .../src/executor/include/grd_type_inner.h | 4 +- .../{grd_document_store.h => grd_store.h} | 6 +-- .../src/interface/include/grd_store_manager.h | 6 +-- .../src/interface/include/result_set.h | 6 +-- .../src/interface/include/result_set_common.h | 2 +- .../interface/src/document_store_manager.cpp | 6 +-- .../src/{document_store.cpp => grd_store.cpp} | 48 +++++++++---------- .../src/interface/src/result_set.cpp | 2 +- .../src/interface/src/result_set_common.cpp | 2 +- .../gaussdb_rd/test/unittest/BUILD.gn | 2 +- frameworks/libs/distributeddb/test/BUILD.gn | 2 +- .../test/fuzztest/json_fuzzer/BUILD.gn | 2 +- .../test/fuzztest/jsoninner_fuzzer/BUILD.gn | 2 +- 16 files changed, 48 insertions(+), 48 deletions(-) rename frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/{grd_document_store.h => grd_store.h} (96%) rename frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/{document_store.cpp => grd_store.cpp} (93%) diff --git a/frameworks/libs/distributeddb/distributeddb.gni b/frameworks/libs/distributeddb/distributeddb.gni index 36865498e07..632907aaca9 100755 --- a/frameworks/libs/distributeddb/distributeddb.gni +++ b/frameworks/libs/distributeddb/distributeddb.gni @@ -280,7 +280,7 @@ distributeddb_src_rd = [ "${distributeddb_path}/gaussdb_rd/src/interface/src/collection.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/doc_errno.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/document_key.cpp", - "${distributeddb_path}/gaussdb_rd/src/interface/src/grd_document_store.cpp", + "${distributeddb_path}/gaussdb_rd/src/interface/src/grd_store.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/grd_store_manager.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/projection_tree.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/result_set.cpp", diff --git a/frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn b/frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn index 8687f34cf83..67159dbb97b 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn +++ b/frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn @@ -78,7 +78,7 @@ ohos_static_library("gaussdb_rd") { "src/interface/src/collection.cpp", "src/interface/src/doc_errno.cpp", "src/interface/src/document_key.cpp", - "src/interface/src/grd_document_store.cpp", + "src/interface/src/grd_store.cpp", "src/interface/src/grd_store_manager.cpp", "src/interface/src/projection_tree.cpp", "src/interface/src/result_set.cpp", diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp index f64f4ebb993..d823a0bd16a 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp @@ -29,7 +29,7 @@ int32_t GRD_DBOpenInner(const char *dbPath, const char *configStr, uint32_t flag } std::string path = (dbPath == nullptr ? "" : dbPath); std::string config = (configStr == nullptr ? "" : configStr); - GRDDocumentStore *store = nullptr; + GRDStore *store = nullptr; int ret = GRDStoreManager::GetGRDStore(path, config, flags, store); if (ret != E_OK || store == nullptr) { return TransferDocErr(ret); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h index d833e6a40a4..b38542368ab 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h @@ -17,11 +17,11 @@ #define GRD_TYPE_INNER_H #include "doc_errno.h" -#include "grd_document_store.h" +#include "grd_store.h" #include "grd_base/grd_error.h" typedef struct GRD_DB { - GRDDB::GRDDocumentStore *store_ = nullptr; + GRDDB::GRDStore *store_ = nullptr; } GRD_DB; #endif // GRD_TYPE_INNER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_document_store.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h similarity index 96% rename from frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_document_store.h rename to frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h index 9377fefc7bb..d91daf30705 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_document_store.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h @@ -26,10 +26,10 @@ struct GRD_ResultSet; namespace GRDDB { -class GRDDocumentStore { +class GRDStore { public: - GRDDocumentStore(KvStoreExecutor *); - ~GRDDocumentStore(); + GRDStore(KvStoreExecutor *); + ~GRDStore(); int CreateCollection(const std::string &name, const std::string &option, uint32_t flags); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_manager.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_manager.h index c964819c99a..9d66b2bdefc 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_manager.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_manager.h @@ -19,15 +19,15 @@ #include #include -#include "grd_document_store.h" +#include "grd_store.h" namespace GRDDB { class GRDStoreManager { public: static int GetGRDStore(const std::string &path, const std::string &config, uint32_t flags, - GRDDocumentStore *&store); + GRDStore *&store); - static int CloseGRDStore(GRDDocumentStore *store, uint32_t flags); + static int CloseGRDStore(GRDStore *store, uint32_t flags); private: static int CheckDBPath(const std::string &path, std::string &canonicalPath, std::string &dbName); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h index ed09f094c3c..c7e9a7eaf27 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h @@ -22,7 +22,7 @@ #include "check_common.h" #include "doc_errno.h" -#include "grd_document_store.h" +#include "grd_store.h" #include "grd_base/grd_type_export.h" #include "rd_json_object.h" @@ -31,7 +31,7 @@ class ResultSet { public: ResultSet(); ~ResultSet(); - int Init(std::shared_ptr &context, GRDDocumentStore *store, bool isCutBranch); + int Init(std::shared_ptr &context, GRDStore *store, bool isCutBranch); int GetNext(bool isNeedTransaction = false, bool isNeedCheckTable = false); int GetValue(char **value); int GetValue(std::string &value); @@ -48,7 +48,7 @@ private: int CutJsonBranchInner(JsonObject &cjsonObj, bool viewType, bool isIdExistInValue, bool &isInsertIdflag); - GRDDocumentStore *store_ = nullptr; + GRDStore *store_ = nullptr; bool isCutBranch_ = false; size_t index_ = 0; std::shared_ptr context_; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h index 5704c5b3230..7cc4c4c6464 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h @@ -25,6 +25,6 @@ namespace GRDDB { class ValueObject; -int InitResultSet(std::shared_ptr &context, GRDDocumentStore *store, ResultSet &resultSet, bool isCutBranch); +int InitResultSet(std::shared_ptr &context, GRDStore *store, ResultSet &resultSet, bool isCutBranch); } // namespace GRDDB #endif // RESULTSET_COMMON_H diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp index bf8b7a665f3..a537d8b125e 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp @@ -50,7 +50,7 @@ std::mutex GRDStoreManager::openCloseMutex_; std::map GRDStoreManager::dbConnCount_; int GRDStoreManager::GetGRDStore(const std::string &path, const std::string &config, uint32_t flags, - GRDDocumentStore *&store) + GRDStore *&store) { std::string canonicalPath; std::string dbName; @@ -88,7 +88,7 @@ int GRDStoreManager::GetGRDStore(const std::string &path, const std::string &con return errCode; } - store = new (std::nothrow) GRDDocumentStore(executor); + store = new (std::nothrow) GRDStore(executor); if (store == nullptr) { delete executor; GLOGE("Memory allocation failed!"); @@ -107,7 +107,7 @@ int GRDStoreManager::GetGRDStore(const std::string &path, const std::string &con return errCode; } -int GRDStoreManager::CloseGRDStore(GRDDocumentStore *store, uint32_t flags) +int GRDStoreManager::CloseGRDStore(GRDStore *store, uint32_t flags) { if (!CheckDBCloseFlag(flags)) { GLOGE("Check document db close flags failed."); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp similarity index 93% rename from frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp rename to frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp index 63be4c93cb3..22bb0384587 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "grd_document_store.h" +#include "grd_store.h" #include "check_common.h" #include "collection_option.h" @@ -29,14 +29,14 @@ namespace GRDDB { constexpr int JSON_LENS_MAX = 1024 * 1024; constexpr const char *KEY_ID = "_id"; -GRDDocumentStore::GRDDocumentStore(KvStoreExecutor *executor) : executor_(executor) {} +GRDStore::GRDStore(KvStoreExecutor *executor) : executor_(executor) {} -GRDDocumentStore::~GRDDocumentStore() +GRDStore::~GRDStore() { delete executor_; } -int GRDDocumentStore::CreateCollection(const std::string &name, const std::string &option, uint32_t flags) +int GRDStore::CreateCollection(const std::string &name, const std::string &option, uint32_t flags) { std::string lowerCaseName; int errCode = E_OK; @@ -82,7 +82,7 @@ END: return errCode; } -int GRDDocumentStore::DropCollection(const std::string &name, uint32_t flags) +int GRDStore::DropCollection(const std::string &name, uint32_t flags) { std::string lowerCaseName; int errCode = E_OK; @@ -205,7 +205,7 @@ int GetUpDataRePlaceData(ResultSet &resultSet, const std::string &id, const std: return errCode; } -int GRDDocumentStore::UpdateDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, +int GRDStore::UpdateDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, const std::string &update, bool &isReplace) { std::lock_guard lock(dbMutex_); @@ -254,7 +254,7 @@ END: return (errCode == E_OK) ? count : errCode; } -int GRDDocumentStore::UpdateDocument(const std::string &collection, const std::string &filter, const std::string &update, +int GRDStore::UpdateDocument(const std::string &collection, const std::string &filter, const std::string &update, uint32_t flags) { int errCode = UpdateArgsCheck(collection, filter, update, flags); @@ -379,7 +379,7 @@ int InsertIdToDocument(ResultSet &resultSet, JsonObject &filterObj, JsonObject & return errCode; } -int GRDDocumentStore::UpsertDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, +int GRDStore::UpsertDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, const std::string &document, JsonObject &documentObj, bool &isReplace) { std::lock_guard lock(dbMutex_); @@ -442,7 +442,7 @@ int UpsertDocumentFormatCheck(const std::string &document, JsonObject &documentO return errCode; } -int GRDDocumentStore::UpsertDocument(const std::string &collection, const std::string &filter, +int GRDStore::UpsertDocument(const std::string &collection, const std::string &filter, const std::string &document, uint32_t flags) { int errCode = UpsertArgsCheck(collection, filter, document, flags); @@ -499,7 +499,7 @@ int InsertArgsCheck(const std::string &collection, const std::string &document, return errCode; } -int GRDDocumentStore::InsertDataIntoDB(const std::string &collection, const std::string &document, +int GRDStore::InsertDataIntoDB(const std::string &collection, const std::string &document, JsonObject &documentObj, bool &isIdExist) { std::lock_guard lock(dbMutex_); @@ -517,7 +517,7 @@ int GRDDocumentStore::InsertDataIntoDB(const std::string &collection, const std: return coll.InsertDocument(id, document, isIdExist); } -int GRDDocumentStore::InsertDocument(const std::string &collection, const std::string &document, uint32_t flags) +int GRDStore::InsertDocument(const std::string &collection, const std::string &document, uint32_t flags) { int errCode = InsertArgsCheck(collection, document, flags); if (errCode != E_OK) { @@ -559,7 +559,7 @@ int DeleteArgsCheck(const std::string &collection, const std::string &filter, ui return errCode; } -int GRDDocumentStore::DeleteDataFromDB(std::shared_ptr &context, JsonObject &filterObj) +int GRDStore::DeleteDataFromDB(std::shared_ptr &context, JsonObject &filterObj) { std::lock_guard lock(dbMutex_); if (executor_ == nullptr) { @@ -593,7 +593,7 @@ END: } return errCode; } -int GRDDocumentStore::DeleteDocument(const std::string &collection, const std::string &filter, uint32_t flags) +int GRDStore::DeleteDocument(const std::string &collection, const std::string &filter, uint32_t flags) { int errCode = DeleteArgsCheck(collection, filter, flags); if (errCode != E_OK) { @@ -615,7 +615,7 @@ int GRDDocumentStore::DeleteDocument(const std::string &collection, const std::s context->collectionName = collection; return DeleteDataFromDB(context, filterObj); } -Collection GRDDocumentStore::GetCollection(std::string &collectionName) +Collection GRDStore::GetCollection(std::string &collectionName) { return Collection(collectionName, executor_); } @@ -763,7 +763,7 @@ int FindProjectionInit(const std::string &projection, const std::shared_ptr &context) +int GRDStore::InitFindResultSet(GRD_ResultSet *grdResultSet, std::shared_ptr &context) { std::lock_guard lock(dbMutex_); int errCode = E_OK; @@ -798,7 +798,7 @@ END: return errCode; } -int GRDDocumentStore::FindDocument(const std::string &collection, const std::string &filter, +int GRDStore::FindDocument(const std::string &collection, const std::string &filter, const std::string &projection, uint32_t flags, GRD_ResultSet *grdResultSet) { int errCode = FindArgsCheck(collection, filter, projection, flags); @@ -834,7 +834,7 @@ int GRDDocumentStore::FindDocument(const std::string &collection, const std::str return InitFindResultSet(grdResultSet, context); } -bool GRDDocumentStore::IsExistResultSet(const std::string &collection) +bool GRDStore::IsExistResultSet(const std::string &collection) { if (collections_.find(collection) != collections_.end()) { GLOGE("DB is resource busy"); @@ -843,7 +843,7 @@ bool GRDDocumentStore::IsExistResultSet(const std::string &collection) return false; } -int GRDDocumentStore::EraseCollection(const std::string &collectionName) +int GRDStore::EraseCollection(const std::string &collectionName) { std::lock_guard lock(dbMutex_); if (collections_.find(collectionName) != collections_.end()) { @@ -854,12 +854,12 @@ int GRDDocumentStore::EraseCollection(const std::string &collectionName) return E_INVALID_ARGS; } -void GRDDocumentStore::OnClose(const std::function ¬ifier) +void GRDStore::OnClose(const std::function ¬ifier) { closeNotifier_ = notifier; } -int GRDDocumentStore::Close(uint32_t flags) +int GRDStore::Close(uint32_t flags) { std::lock_guard lock(dbMutex_); if (flags == GRD_DB_CLOSE && !collections_.empty()) { @@ -873,21 +873,21 @@ int GRDDocumentStore::Close(uint32_t flags) return E_OK; } -int GRDDocumentStore::StartTransaction() +int GRDStore::StartTransaction() { if (executor_ == nullptr) { return -E_INNER_ERROR; } return executor_->StartTransaction(); } -int GRDDocumentStore::Commit() +int GRDStore::Commit() { if (executor_ == nullptr) { return -E_INNER_ERROR; } return executor_->Commit(); } -int GRDDocumentStore::Rollback() +int GRDStore::Rollback() { if (executor_ == nullptr) { return -E_INNER_ERROR; @@ -895,7 +895,7 @@ int GRDDocumentStore::Rollback() return executor_->Rollback(); } -bool GRDDocumentStore::IsCollectionExists(const std::string &collectionName, int &errCode) +bool GRDStore::IsCollectionExists(const std::string &collectionName, int &errCode) { if (executor_ == nullptr) { errCode = -E_INNER_ERROR; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp index 9f1d1045be0..93d826bf573 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp @@ -34,7 +34,7 @@ int ResultSet::EraseCollection() } return E_OK; } -int ResultSet::Init(std::shared_ptr &context, GRDDocumentStore *store, bool isCutBranch) +int ResultSet::Init(std::shared_ptr &context, GRDStore *store, bool isCutBranch) { isCutBranch_ = isCutBranch; context_ = context; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp index 0ec84e92523..acf3080abf3 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp @@ -20,7 +20,7 @@ namespace GRDDB { class ValueObject; -int InitResultSet(std::shared_ptr &context, GRDDocumentStore *store, ResultSet &resultSet, bool isCutBranch) +int InitResultSet(std::shared_ptr &context, GRDStore *store, ResultSet &resultSet, bool isCutBranch) { if (isCutBranch) { for (const auto &singlePath : context->projectionPath) { diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn index 7b4b8ddcf4a..98800453ffd 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn @@ -63,7 +63,7 @@ ohos_source_set("src_file") { "../../src/interface/src/collection.cpp", "../../src/interface/src/doc_errno.cpp", "../../src/interface/src/document_key.cpp", - "../../src/interface/src/grd_document_store.cpp", + "../../src/interface/src/grd_store.cpp", "../../src/interface/src/grd_store_manager.cpp", "../../src/interface/src/projection_tree.cpp", "../../src/interface/src/result_set.cpp", diff --git a/frameworks/libs/distributeddb/test/BUILD.gn b/frameworks/libs/distributeddb/test/BUILD.gn index 858e03f8c56..d83b7def48b 100644 --- a/frameworks/libs/distributeddb/test/BUILD.gn +++ b/frameworks/libs/distributeddb/test/BUILD.gn @@ -144,7 +144,7 @@ ohos_source_set("src_file") { "../gaussdb_rd/src/interface/src/collection.cpp", "../gaussdb_rd/src/interface/src/doc_errno.cpp", "../gaussdb_rd/src/interface/src/document_key.cpp", - "../gaussdb_rd/src/interface/src/grd_document_store.cpp", + "../gaussdb_rd/src/interface/src/grd_store.cpp", "../gaussdb_rd/src/interface/src/grd_store_manager.cpp", "../gaussdb_rd/src/interface/src/projection_tree.cpp", "../gaussdb_rd/src/interface/src/result_set.cpp", diff --git a/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn b/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn index f008495a9af..a21e5a1b7e1 100644 --- a/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn +++ b/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn @@ -63,7 +63,7 @@ ohos_source_set("src_file") { "../../../gaussdb_rd/src/interface/src/collection.cpp", "../../../gaussdb_rd/src/interface/src/doc_errno.cpp", "../../../gaussdb_rd/src/interface/src/document_key.cpp", - "../../../gaussdb_rd/src/interface/src/grd_document_store.cpp", + "../../../gaussdb_rd/src/interface/src/grd_store.cpp", "../../../gaussdb_rd/src/interface/src/grd_store_manager.cpp", "../../../gaussdb_rd/src/interface/src/projection_tree.cpp", "../../../gaussdb_rd/src/interface/src/result_set.cpp", diff --git a/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn b/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn index eea027df99f..69ea72e02d4 100644 --- a/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn +++ b/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn @@ -63,7 +63,7 @@ ohos_source_set("src_file") { "../../../gaussdb_rd/src/interface/src/collection.cpp", "../../../gaussdb_rd/src/interface/src/doc_errno.cpp", "../../../gaussdb_rd/src/interface/src/document_key.cpp", - "../../../gaussdb_rd/src/interface/src/grd_document_store.cpp", + "../../../gaussdb_rd/src/interface/src/grd_store.cpp", "../../../gaussdb_rd/src/interface/src/grd_store_manager.cpp", "../../../gaussdb_rd/src/interface/src/projection_tree.cpp", "../../../gaussdb_rd/src/interface/src/result_set.cpp", -- Gitee From 4241ff386032fc45ace15e5c0f2d9b8639bc4f2e Mon Sep 17 00:00:00 2001 From: bluhuang Date: Mon, 11 Nov 2024 11:52:15 +0800 Subject: [PATCH 07/21] change document store manager.cpp to grd store manager.cpp Signed-off-by: bluhuang --- .../src/{document_store_manager.cpp => grd_store_manager.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/{document_store_manager.cpp => grd_store_manager.cpp} (100%) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_manager.cpp similarity index 100% rename from frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_store_manager.cpp rename to frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_manager.cpp -- Gitee From 48086680c638dcd4e731ecc5a3f2e55d6b8a0791 Mon Sep 17 00:00:00 2001 From: bluhuang Date: Mon, 11 Nov 2024 14:33:07 +0800 Subject: [PATCH 08/21] change grd open config, and move some api to grd_db Signed-off-by: bluhuang --- .../gaussdb_rd/include/grd_base/grd_db_api.h | 5 ++++ .../include/grd_document/grd_document_api.h | 4 ---- .../gaussdb_rd/src/common/include/db_config.h | 1 + .../gaussdb_rd/src/common/src/db_config.cpp | 19 ++++++++++++++- .../src/executor/base/grd_db_api.cpp | 24 +++++++++++++++++++ .../executor/document/grd_document_api.cpp | 24 ------------------- 6 files changed, 48 insertions(+), 29 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/include/grd_base/grd_db_api.h b/frameworks/libs/distributeddb/gaussdb_rd/include/grd_base/grd_db_api.h index 066581ef753..0f8af90f39c 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/include/grd_base/grd_db_api.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/include/grd_base/grd_db_api.h @@ -34,6 +34,11 @@ GRD_API int32_t GRD_DBRestore(const char *dbFile, const char *backupDbFile, uint GRD_API int32_t GRD_IndexPreload(GRD_DB *db, const char *collectionName); GRD_API int32_t GRD_Flush(GRD_DB *db, uint32_t flags); + +GRD_API int32_t GRD_CreateCollection(GRD_DB *db, const char *collectionName, const char *optionStr, uint32_t flags); + +GRD_API int32_t GRD_DropCollection(GRD_DB *db, const char *collectionName, uint32_t flags); + #ifdef __cplusplus } #endif // __cplusplus diff --git a/frameworks/libs/distributeddb/gaussdb_rd/include/grd_document/grd_document_api.h b/frameworks/libs/distributeddb/gaussdb_rd/include/grd_document/grd_document_api.h index d01d54e5679..68b807e0bf6 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/include/grd_document/grd_document_api.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/include/grd_document/grd_document_api.h @@ -25,10 +25,6 @@ extern "C" { #endif -GRD_API int32_t GRD_CreateCollection(GRD_DB *db, const char *collectionName, const char *optionStr, uint32_t flags); - -GRD_API int32_t GRD_DropCollection(GRD_DB *db, const char *collectionName, uint32_t flags); - GRD_API int32_t GRD_InsertDoc(GRD_DB *db, const char *collectionName, const char *document, uint32_t flags); GRD_API int32_t GRD_FindDoc(GRD_DB *db, const char *collectionName, Query query, uint32_t flags, diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/db_config.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/db_config.h index ddf79d7ad34..3e88b329177 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/db_config.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/db_config.h @@ -46,6 +46,7 @@ private: uint32_t bufferPoolSize_ = 1024; // 100: default 1024k pool size uint32_t crcCheckEnable_ = 1; uint32_t shareModeEnable_ = 0; + uint32_t metaInfoBak_ = 0; }; } // namespace GRDDB #endif // DB_CONFIG_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/db_config.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/db_config.cpp index 75d40938a26..47a9882a40d 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/db_config.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/db_config.cpp @@ -42,6 +42,7 @@ constexpr const char *DB_CONFIG_BUFFER_POOL_SIZE = "bufferpoolsize"; constexpr const char *DB_CONFIG_CRC_CHECK_ENABLE = "crccheckenable"; constexpr const char *DB_CONFIG_BUFFPOOL_POLICY = "bufferpoolpolicy"; constexpr const char *DB_CONFIG_SHARED_MODE = "sharedmodeenable"; +constexpr const char *DB_CONFIG_META_INFO_BAK = "metainfobak"; constexpr const char *DB_CONFIG[] = { DB_CONFIG_PAGESIZE, DB_CONFIG_REDO_FLUSH_BY_TRX, DB_CONFIG_REDO_PUB_BUFF_SIZE, DB_CONFIG_MAX_CONN_NUM, DB_CONFIG_BUFFER_POOL_SIZE, DB_CONFIG_CRC_CHECK_ENABLE, @@ -135,6 +136,14 @@ bool CheckShareModeConfig(const JsonObject &config, uint32_t &shareModeCheckEnab return CheckAndGetDBConfig(config, DB_CONFIG_SHARED_MODE, checkFunction, shareModeCheckEnable); } +bool CheckMetaInfoBakConfig(const JsonObject &config, uint32_t &metaInfoBak) +{ + std::function checkFunction = [](uint32_t val) { + return val == 0 || val == 1; + }; + return CheckAndGetDBConfig(config, DB_CONFIG_META_INFO_BAK, checkFunction, metaInfoBak); +} + int IsDbconfigValid(const JsonObject &config) { JsonObject child = config.GetChild(); @@ -216,6 +225,13 @@ DBConfig DBConfig::GetDBConfigFromJsonStr(const std::string &confStr, int &errCo return {}; } + if (!CheckMetaInfoBakConfig(dbConfig, conf.metaInfoBak_)) { + GLOGE("Check DB config 'MetaInfoBak' failed."); + errCode = -E_INVALID_CONFIG_VALUE; + return {}; + } + + conf.configStr_ = confStr; return conf; } @@ -254,7 +270,8 @@ bool DBConfig::operator==(const DBConfig &targetConfig) const { return pageSize_ == targetConfig.pageSize_ && redoFlushByTrx_ == targetConfig.redoFlushByTrx_ && redoPubBufSize_ == targetConfig.redoPubBufSize_ && maxConnNum_ == targetConfig.maxConnNum_ && - bufferPoolSize_ == targetConfig.bufferPoolSize_ && crcCheckEnable_ == targetConfig.crcCheckEnable_; + bufferPoolSize_ == targetConfig.bufferPoolSize_ && crcCheckEnable_ == targetConfig.crcCheckEnable_ && + metaInfoBak_ == targetConfig.metaInfoBak_; } bool DBConfig::operator!=(const DBConfig &targetConfig) const diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp index 112291ddfd7..271e3727056 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp @@ -100,3 +100,27 @@ GRD_API int32_t GRD_IndexPreload(GRD_DB *db, const char *collectionName) } return GRD_DBApiInfo.IndexPreloadApi(db, collectionName); } + +GRD_API int32_t GRD_CreateCollection(GRD_DB *db, const char *collectionName, const char *optionStr, uint32_t flags) +{ + if (GRD_DBApiInfo.CreateCollectionApi == nullptr) { + GRD_DBApiInfo = GetApiInfoInstance(); + } + if (GRD_DBApiInfo.CreateCollectionApi == nullptr) { + GLOGE("Fail to dlysm RD api symbol"); + return GRD_INNER_ERR; + } + return GRD_DBApiInfo.CreateCollectionApi(db, collectionName, optionStr, flags); +} + +GRD_API int32_t GRD_DropCollection(GRD_DB *db, const char *collectionName, uint32_t flags) +{ + if (GRD_DBApiInfo.DropCollectionApi == nullptr) { + GRD_DBApiInfo = GetApiInfoInstance(); + } + if (GRD_DBApiInfo.DropCollectionApi == nullptr) { + GLOGE("Fail to dlysm RD api symbol"); + return GRD_INNER_ERR; + } + return GRD_DBApiInfo.DropCollectionApi(db, collectionName, flags); +} \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api.cpp index bdb2a17d768..38b40d8e208 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api.cpp @@ -25,30 +25,6 @@ using namespace GRDDB; static GRD_APIInfo GRD_DocApiInfo; -GRD_API int32_t GRD_CreateCollection(GRD_DB *db, const char *collectionName, const char *optionStr, uint32_t flags) -{ - if (GRD_DocApiInfo.CreateCollectionApi == nullptr) { - GRD_DocApiInfo = GetApiInfoInstance(); - } - if (GRD_DocApiInfo.CreateCollectionApi == nullptr) { - GLOGE("Fail to dlysm RD api symbol"); - return GRD_INNER_ERR; - } - return GRD_DocApiInfo.CreateCollectionApi(db, collectionName, optionStr, flags); -} - -GRD_API int32_t GRD_DropCollection(GRD_DB *db, const char *collectionName, uint32_t flags) -{ - if (GRD_DocApiInfo.DropCollectionApi == nullptr) { - GRD_DocApiInfo = GetApiInfoInstance(); - } - if (GRD_DocApiInfo.DropCollectionApi == nullptr) { - GLOGE("Fail to dlysm RD api symbol"); - return GRD_INNER_ERR; - } - return GRD_DocApiInfo.DropCollectionApi(db, collectionName, flags); -} - GRD_API int32_t GRD_UpdateDoc(GRD_DB *db, const char *collectionName, const char *filter, const char *update, uint32_t flags) { -- Gitee From b3c4a982b54fce83caef44554e4cdea37b45052b Mon Sep 17 00:00:00 2001 From: bluhuang Date: Mon, 11 Nov 2024 17:33:39 +0800 Subject: [PATCH 09/21] collection support kv Signed-off-by: bluhuang --- .../src/common/include/collection_option.h | 16 +++ .../src/common/src/collection_option.cpp | 110 +++++++++++++----- 2 files changed, 97 insertions(+), 29 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/collection_option.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/collection_option.h index 05ab014e449..a985f1ad994 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/collection_option.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/collection_option.h @@ -19,6 +19,17 @@ #include namespace GRDDB { +enum CollectionType { + GRD_COLLECTION_DOCUMENT, + GRD_COLLECTION_KV, + GRD_COLLECTION_UNDEFINED +}; + +enum IndexType { + GRD_INDEX_BTREE, + GRD_INDEX_HASH +}; + class CollectionOption final { public: static CollectionOption ReadOption(const std::string &optStr, int &errCode); @@ -28,8 +39,13 @@ private: CollectionOption(const CollectionOption &collectionOption) = default; bool operator==(const CollectionOption &targetOption) const; bool operator!=(const CollectionOption &targetOption) const; + static CollectionOption CollectionOption::GetValidOption(JsonObject collOpt, int &errCode); + static int GetValidOptionInner(JsonObject collOpt, const std::string &field, ValueObject value, + CollectionOption &option); std::string option_ = "{}"; uint32_t maxDoc_ = UINT32_MAX; + uint32_t collectionType_ = GRD_COLLECTION_DOCUMENT; + uint32_t indexType_ = GRD_INDEX_BTREE; }; } // namespace GRDDB #endif // COLLECTION_OPTION_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp index cdcde7874b3..63a7da121c1 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp @@ -27,6 +27,10 @@ namespace { constexpr const char *OPT_MAX_DOC = "maxdoc"; constexpr const char *OPT_COLLECTION_MODE = "mode"; constexpr const char *KV_COLLECTION_MODE = "kv"; +constexpr const char *DOC_COLLECTION_MODE = "document"; +constexpr const char *OPT_INDEX_TYPE = "indextype"; +constexpr const char *INDEX_TYPE_HASH = "hash"; +constexpr const char *INDEX_TYPE_BTREE = "btree"; int CFG_IsValid(const JsonObject &config) { @@ -34,23 +38,96 @@ int CFG_IsValid(const JsonObject &config) while (!child.IsNull()) { std::string fieldName = child.GetItemField(); if (strcmp(OPT_COLLECTION_MODE, fieldName.c_str()) == 0) { - if (strcmp(child.GetItemValue().GetStringValue().c_str(), KV_COLLECTION_MODE) == 0) { // The value of mode - return -E_NOT_SUPPORT; - } else { + if (strcmp(child.GetItemValue().GetStringValue().c_str(), KV_COLLECTION_MODE) == 0 || + strcmp(child.GetItemValue().GetStringValue().c_str(), DOC_COLLECTION_MODE) == 0) { child = child.GetNext(); continue; + } else { + GLOGE("Create collection failed, config err, mode: %s", child.GetItemValue().GetStringValue().c_str()); + return -E_NOT_SUPPORT; } } if (strcmp(OPT_MAX_DOC, fieldName.c_str()) != 0) { GLOGE("Invalid collection config."); return -E_INVALID_CONFIG_VALUE; } + if (strcmp(OPT_INDEX_TYPE, fieldName.c_str()) == 0) { + if (strcmp(child.GetItemValue().GetStringValue().c_str(), INDEX_TYPE_BTREE) == 0 || + strcmp(child.GetItemValue().GetStringValue().c_str(), INDEX_TYPE_HASH) == 0) { + child = child.GetNext(); + continue; + } else { + GLOGE("Create collection failed, config err, idx: %s", child.GetItemValue().GetStringValue().c_str()); + return -E_NOT_SUPPORT; + } + } child = child.GetNext(); } return E_OK; } } // namespace +int CollectionOption::GetValidOptionInner(JsonObject collOpt, const std::string &field, ValueObject value, + CollectionOption &option) +{ + if (field == OPT_MAX_DOC) { + if (value.GetValueType() != ValueObject::ValueType::VALUE_NUMBER) { + GLOGE("Check collection option failed, the field type of maxDoc is not NUMBER."); + return -E_INVALID_CONFIG_VALUE; + } + if (value.GetIntValue() <= 0 || static_cast(value.GetIntValue()) > UINT32_MAX) { + GLOGE("Check collection option failed, invalid maxDoc value."); + return -E_INVALID_CONFIG_VALUE; + } + option.maxDoc_ = static_cast(value.GetIntValue()); + } + + if (field == OPT_COLLECTION_MODE) { + if (value.GetValueType() != ValueObject::ValueType::VALUE_STRING) { + GLOGE("Check collection option failed, the field type of mode is not STRING."); + return -E_INVALID_CONFIG_VALUE; + } + if (value.GetStringValue() != "document" || value.GetStringValue() != "kv") { + GLOGE("Check collection option failed, invalid mode value."); + return -E_INVALID_CONFIG_VALUE; + } + option.collectionType_ = value.GetStringValue() == "document" ? GRD_COLLECTION_DOCUMENT : GRD_COLLECTION_KV; + } + + if (field == OPT_INDEX_TYPE) { + if (value.GetValueType() != ValueObject::ValueType::VALUE_STRING) { + GLOGE("Check collection option failed, the field type of idx is not STRING."); + return -E_INVALID_CONFIG_VALUE; + } + if (value.GetStringValue() != "btree" || value.GetStringValue() != "hash") { + GLOGE("Check collection option failed, invalid mode value."); + return -E_INVALID_CONFIG_VALUE; + } + option.indexType_ = value.GetStringValue() == "btree" ? GRD_INDEX_BTREE : GRD_INDEX_HASH; + } +} + +CollectionOption CollectionOption::GetValidOption(JsonObject collOpt, int &errCode) +{ + CollectionOption option; + static const JsonFieldPath collCigFields = { OPT_MAX_DOC, OPT_COLLECTION_MODE, OPT_INDEX_TYPE}; + for(const auto &field : collCigFields) { + const JsonFieldPath singleField = { field }; + if (collOpt.IsFieldExists(singleField)) { + ValueObject value = collOpt.GetObjectByPath(singleField, errCode); + if (errCode != E_OK) { + GLOGE("Read collection option %s failed. %d", field.c_str(), errCode); + return {}; + } + int errCode = GetValidOptionInner(collOpt, field, value, option); + if (errCode != E_OK) { + return {}; + } + } + } + return option; +} + CollectionOption CollectionOption::ReadOption(const std::string &optStr, int &errCode) { if (optStr.empty()) { @@ -73,32 +150,7 @@ CollectionOption CollectionOption::ReadOption(const std::string &optStr, int &er GLOGE("Check collection option, not support config item. %d", errCode); return {}; } - - static const JsonFieldPath maxDocField = { OPT_MAX_DOC }; - if (!collOpt.IsFieldExists(maxDocField)) { - return {}; - } - - ValueObject maxDocValue = collOpt.GetObjectByPath(maxDocField, errCode); - if (errCode != E_OK) { - GLOGE("Read collection option failed. %d", errCode); - return {}; - } - - if (maxDocValue.GetValueType() != ValueObject::ValueType::VALUE_NUMBER) { - GLOGE("Check collection option failed, the field type of maxDoc is not NUMBER."); - errCode = -E_INVALID_CONFIG_VALUE; - return {}; - } - - if (maxDocValue.GetIntValue() <= 0 || static_cast(maxDocValue.GetIntValue()) > UINT32_MAX) { - GLOGE("Check collection option failed, invalid maxDoc value."); - errCode = -E_INVALID_CONFIG_VALUE; - return {}; - } - - CollectionOption option; - option.maxDoc_ = static_cast(maxDocValue.GetIntValue()); + CollectionOption option = GetValidOption(collOpt, errCode); option.option_ = optStr; return option; } -- Gitee From 6d887cc27bdccddb57d2a6946b2ae2a5805d8a2d Mon Sep 17 00:00:00 2001 From: bluhuang Date: Mon, 11 Nov 2024 17:44:12 +0800 Subject: [PATCH 10/21] comment --- .../distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp index 22bb0384587..dba45508255 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp @@ -45,6 +45,7 @@ int GRDStore::CreateCollection(const std::string &name, const std::string &optio return errCode; } errCode = E_OK; + // todohbx: 这里拿到option其实没什么用,只是检查 CollectionOption collOption = CollectionOption::ReadOption(option, errCode); if (errCode != E_OK) { GLOGE("Read collection option str failed. %d", errCode); @@ -67,6 +68,7 @@ int GRDStore::CreateCollection(const std::string &name, const std::string &optio std::string oriOptStr; bool ignoreExists = (flags != CHK_EXIST_COLLECTION); + // todohbx:这里实际上没有保存option,当前先做简单点,先实现,只有卡片和preferences用 errCode = executor_->CreateCollection(lowerCaseName, oriOptStr, ignoreExists); if (errCode != E_OK) { GLOGE("Create collection failed. %d", errCode); -- Gitee From 81bfd31c62fe1693c2c5498302e9d9885a2442c7 Mon Sep 17 00:00:00 2001 From: bluhuang Date: Mon, 11 Nov 2024 17:46:33 +0800 Subject: [PATCH 11/21] fix compile Signed-off-by: bluhuang --- .../gaussdb_rd/src/common/include/collection_option.h | 3 ++- .../gaussdb_rd/src/common/src/collection_option.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/collection_option.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/collection_option.h index a985f1ad994..fa0360cd748 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/collection_option.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/collection_option.h @@ -17,6 +17,7 @@ #define COLLECTION_OPTION_H #include +#include "rd_json_object.h" namespace GRDDB { enum CollectionType { @@ -39,7 +40,7 @@ private: CollectionOption(const CollectionOption &collectionOption) = default; bool operator==(const CollectionOption &targetOption) const; bool operator!=(const CollectionOption &targetOption) const; - static CollectionOption CollectionOption::GetValidOption(JsonObject collOpt, int &errCode); + static CollectionOption GetValidOption(JsonObject collOpt, int &errCode); static int GetValidOptionInner(JsonObject collOpt, const std::string &field, ValueObject value, CollectionOption &option); std::string option_ = "{}"; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp index 63a7da121c1..41bccf6f969 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp @@ -105,6 +105,7 @@ int CollectionOption::GetValidOptionInner(JsonObject collOpt, const std::string } option.indexType_ = value.GetStringValue() == "btree" ? GRD_INDEX_BTREE : GRD_INDEX_HASH; } + return E_OK; } CollectionOption CollectionOption::GetValidOption(JsonObject collOpt, int &errCode) -- Gitee From 316fba1ddbd5dc650d227097f3c998c976e9ca50 Mon Sep 17 00:00:00 2001 From: bluhuang Date: Mon, 11 Nov 2024 22:40:43 +0800 Subject: [PATCH 12/21] grd kv api outter Signed-off-by: bluhuang --- .../document/grd_document_api_inner.cpp | 2 +- .../src/executor/kv/grd_kv_api_inner.cpp | 63 ++++++++++++++++--- .../src/interface/src/grd_store.cpp | 2 - 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp index 500f4c311ae..f50016026a1 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp @@ -107,7 +107,7 @@ int32_t GRD_FindDocInner(GRD_DB *db, const char *collectionName, Query query, ui GRD_ResultSet *grdResultSet = new (std::nothrow) GRD_ResultSet(); if (grdResultSet == nullptr) { GLOGE("Memory allocation failed!"); - return -E_FAILED_MEMORY_ALLOCATE; + return GRD_FAILED_MEMORY_ALLOCATE; } int ret = db->store_->FindDocument(collectionName, query.filter, query.projection, flags, grdResultSet); if (ret != E_OK) { diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp index 7b6deb495de..0fce7bfe82b 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp @@ -22,17 +22,29 @@ namespace GRDDB { int32_t GRD_KVPutInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT *key, const GRD_KVItemT *value) { - return GRD_NOT_SUPPORT; + if (db == nullptr || db->store_ == nullptr || collectionName == nullptr || key == nullptr || value == nullptr) { + return GRD_INVALID_ARGS; + } + int ret = db->store_->KVInsert(collectionName, key, value); + return TransferDocErr(ret); } int32_t GRD_KVGetInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT *key, const GRD_KVItemT *value) { - return GRD_NOT_SUPPORT; + if (db == nullptr || db->store_ == nullptr || collectionName == nullptr || key == nullptr || value == nullptr) { + return GRD_INVALID_ARGS; + } + int ret = db->store_->KVGet(collectionName, key, value); + return TransferDocErr(ret); } int32_t GRD_KVDelInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT *key) { - return GRD_NOT_SUPPORT; + if (db == nullptr || db->store_ == nullptr || collectionName == nullptr || key == nullptr || value == nullptr) { + return GRD_INVALID_ARGS; + } + int ret = db->store_->KVDelete(collectionName, key); + return TransferDocErr(ret); } int32_t GRD_KVScanInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT *key, GRD_KvScanModeE mode, @@ -44,22 +56,59 @@ int32_t GRD_KVScanInner(GRD_DB *db, const char *collectionName, const GRD_KVItem int32_t GRD_KVFilterInner(GRD_DB *db, const char *collectionName, const GRD_FilterOptionT *scanParams, GRD_ResultSet **resultSet) { - return GRD_NOT_SUPPORT; + if (db == nullptr || db->store_ == nullptr || collectionName == nullptr || scanParams == nullptr || resultSet == nullptr) { + return GRD_INVALID_ARGS; + } + GRD_ResultSet *grdResultSet = new (std::nothrow) GRD_ResultSet(); + if (grdResultSet == nullptr) { + GLOGE("Memory allocation failed when kv filter!"); + return GRD_FAILED_MEMORY_ALLOCATE; + } + + int errCode = db->store_->KVFilter(collectionName, scanParams, grdResultSet); + if (errCode != E_OK) { + delete grdResultSet; + return TransferDocErr(errCode); + } + *resultSet = grdResultSet; + return TransferDocErr(errCode); } int32_t GRD_KVGetSizeInner(GRD_ResultSet *resultSet, uint32_t *keyLen, uint32_t *valueLen) { - return GRD_NOT_SUPPORT; + if (resultSet == nullptr || keyLen == nullptr || valueLen == nullptr) { + return GRD_INVALID_ARGS; + } + int errCode = resultSet->GetSize(keyLen, valueLen); + if (errCode != GRD_OK) { + GLOGE("failed to get size"); + return TransferDocErr(errCode); + } + return TransferDocErr(errCode); +} } int32_t GRD_GetItemInner(GRD_ResultSet *resultSet, void *key, void *value) { - return GRD_NOT_SUPPORT; + if (resultSet == nullptr || keyLen == nullptr || valueLen == nullptr) { + return GRD_INVALID_ARGS; + } + int errCode = resultSet->GetItem(key, value); + if (errCode != GRD_OK) { + GLOGE("failed to get size"); + return TransferDocErr(errCode); + } + return TransferDocErr(errCode); } int32_t GRD_KVFreeItemInner(GRD_KVItemT *item) { - return GRD_NOT_SUPPORT; + if (item == nullptr) { + return GRD_INVALID_ARGS; + } + // todohbx: make sure + free(item); + return GRD_OK; } int32_t GRD_KVBatchPrepareInner(uint16_t itemNum, GRD_KVBatchT **batch) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp index dba45508255..22bb0384587 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp @@ -45,7 +45,6 @@ int GRDStore::CreateCollection(const std::string &name, const std::string &optio return errCode; } errCode = E_OK; - // todohbx: 这里拿到option其实没什么用,只是检查 CollectionOption collOption = CollectionOption::ReadOption(option, errCode); if (errCode != E_OK) { GLOGE("Read collection option str failed. %d", errCode); @@ -68,7 +67,6 @@ int GRDStore::CreateCollection(const std::string &name, const std::string &optio std::string oriOptStr; bool ignoreExists = (flags != CHK_EXIST_COLLECTION); - // todohbx:这里实际上没有保存option,当前先做简单点,先实现,只有卡片和preferences用 errCode = executor_->CreateCollection(lowerCaseName, oriOptStr, ignoreExists); if (errCode != E_OK) { GLOGE("Create collection failed. %d", errCode); -- Gitee From 081da092a4b249ccd8eac58d167acaf829cef5d9 Mon Sep 17 00:00:00 2001 From: bluhuang Date: Tue, 12 Nov 2024 10:20:29 +0800 Subject: [PATCH 13/21] change doc errno to grd store errno Signed-off-by: bluhuang --- frameworks/libs/distributeddb/distributeddb.gni | 2 +- frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn | 2 +- .../gaussdb_rd/src/common/src/collection_option.cpp | 2 +- .../distributeddb/gaussdb_rd/src/common/src/db_config.cpp | 2 +- .../gaussdb_rd/src/common/src/grd_api_manager.cpp | 2 +- .../distributeddb/gaussdb_rd/src/common/src/json_common.cpp | 2 +- .../libs/distributeddb/gaussdb_rd/src/common/src/os_api.cpp | 2 +- .../gaussdb_rd/src/executor/base/grd_db_api.cpp | 2 +- .../gaussdb_rd/src/executor/base/grd_db_api_inner.cpp | 2 +- .../gaussdb_rd/src/executor/document/check_common.cpp | 2 +- .../gaussdb_rd/src/executor/document/grd_resultset_api.cpp | 2 +- .../src/executor/document/grd_resultset_api_inner.cpp | 2 +- .../gaussdb_rd/src/executor/include/grd_resultset_inner.h | 2 +- .../gaussdb_rd/src/executor/include/grd_type_inner.h | 2 +- .../gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp | 1 + .../interface/include/{doc_errno.h => grd_store_errno.h} | 6 +++--- .../gaussdb_rd/src/interface/include/projection_tree.h | 2 +- .../gaussdb_rd/src/interface/include/result_set.h | 2 +- .../gaussdb_rd/src/interface/include/result_set_common.h | 2 +- .../gaussdb_rd/src/interface/src/collection.cpp | 2 +- .../gaussdb_rd/src/interface/src/document_key.cpp | 2 +- .../gaussdb_rd/src/interface/src/grd_store.cpp | 2 +- .../interface/src/{doc_errno.cpp => grd_store_errno.cpp} | 3 ++- .../gaussdb_rd/src/interface/src/grd_store_manager.cpp | 2 +- .../gaussdb_rd/src/interface/src/result_set_common.cpp | 2 +- .../gaussdb_rd/src/oh_adapter/src/kv_store_manager.cpp | 2 +- .../gaussdb_rd/src/oh_adapter/src/rd_json_object.cpp | 2 +- .../gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp | 2 +- .../src/oh_adapter/src/sqlite_store_executor_impl.cpp | 2 +- .../libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn | 2 +- .../gaussdb_rd/test/unittest/api/documentdb_api_test.cpp | 2 +- .../test/unittest/api/documentdb_collection_test.cpp | 2 +- .../gaussdb_rd/test/unittest/api/documentdb_data_test.cpp | 2 +- .../gaussdb_rd/test/unittest/api/documentdb_find_test.cpp | 2 +- .../unittest/oh_adapter/documentdb_json_common_test.cpp | 2 +- .../test/unittest/oh_adapter/documentdb_jsonobject_test.cpp | 2 +- frameworks/libs/distributeddb/test/BUILD.gn | 2 +- .../libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn | 2 +- .../distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn | 2 +- 39 files changed, 42 insertions(+), 40 deletions(-) rename frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/{doc_errno.h => grd_store_errno.h} (95%) rename frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/{doc_errno.cpp => grd_store_errno.cpp} (99%) diff --git a/frameworks/libs/distributeddb/distributeddb.gni b/frameworks/libs/distributeddb/distributeddb.gni index 632907aaca9..44d3df1b1c1 100755 --- a/frameworks/libs/distributeddb/distributeddb.gni +++ b/frameworks/libs/distributeddb/distributeddb.gni @@ -278,7 +278,7 @@ distributeddb_src_rd = [ "${distributeddb_path}/gaussdb_rd/src/executor/kv/grd_kv_api.cpp", "${distributeddb_path}/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/collection.cpp", - "${distributeddb_path}/gaussdb_rd/src/interface/src/doc_errno.cpp", + "${distributeddb_path}/gaussdb_rd/src/interface/src/grd_store_errno.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/document_key.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/grd_store.cpp", "${distributeddb_path}/gaussdb_rd/src/interface/src/grd_store_manager.cpp", diff --git a/frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn b/frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn index 67159dbb97b..b6568598cc1 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn +++ b/frameworks/libs/distributeddb/gaussdb_rd/BUILD.gn @@ -76,7 +76,7 @@ ohos_static_library("gaussdb_rd") { "src/executor/kv/grd_kv_api.cpp", "src/executor/kv/grd_kv_api_inner.cpp", "src/interface/src/collection.cpp", - "src/interface/src/doc_errno.cpp", + "src/interface/src/grd_store_errno.cpp", "src/interface/src/document_key.cpp", "src/interface/src/grd_store.cpp", "src/interface/src/grd_store_manager.cpp", diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp index 41bccf6f969..bca85db44fa 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/collection_option.cpp @@ -18,7 +18,7 @@ #include #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "rd_json_object.h" #include "rd_log_print.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/db_config.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/db_config.cpp index 47a9882a40d..0ca331f3b65 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/db_config.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/db_config.cpp @@ -20,7 +20,7 @@ #include #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "doc_limit.h" #include "rd_json_object.h" #include "rd_log_print.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp index d96c0b90d5a..6eb790a780c 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp @@ -20,7 +20,7 @@ #endif #include "check_common.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "grd_store_manager.h" #include "grd_base/grd_error.h" #include "grd_db_api_inner.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/json_common.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/json_common.cpp index 79930d6aa59..6c5e4a34c51 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/json_common.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/json_common.cpp @@ -17,7 +17,7 @@ #include #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "rd_log_print.h" namespace GRDDB { diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/os_api.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/os_api.cpp index 7bbc4c68d9f..d8cf96d705c 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/os_api.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/os_api.cpp @@ -19,7 +19,7 @@ #include #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "rd_log_print.h" #include "securec.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp index 271e3727056..1c9fef5c5f3 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api.cpp @@ -15,7 +15,7 @@ #include "grd_base/grd_db_api.h" #include "check_common.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "grd_store_manager.h" #include "grd_api_manager.h" #include "grd_base/grd_error.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp index d823a0bd16a..b1e3b8a5f40 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp @@ -14,7 +14,7 @@ */ #include "grd_db_api_inner.h" #include "check_common.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "grd_store_manager.h" #include "grd_api_manager.h" #include "grd_base/grd_error.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/check_common.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/check_common.cpp index b5f46800ab8..700fe0dfb54 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/check_common.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/check_common.cpp @@ -17,7 +17,7 @@ #include #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "grd_base/grd_db_api.h" #include "rd_log_print.h" #include "securec.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api.cpp index 8c3c1a9587f..08bbc74569c 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api.cpp @@ -14,7 +14,7 @@ */ #include "grd_base/grd_resultset_api.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "grd_api_manager.h" #include "grd_base/grd_error.h" #include "grd_resultset_inner.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api_inner.cpp index fbec6008271..debe8c2b5c0 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api_inner.cpp @@ -14,7 +14,7 @@ */ #include "grd_resultset_api_inner.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "grd_api_manager.h" #include "grd_base/grd_error.h" #include "grd_resultset_inner.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_resultset_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_resultset_inner.h index 54e625ac9eb..678c7cc6196 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_resultset_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_resultset_inner.h @@ -16,7 +16,7 @@ #ifndef GRD_RESULTSET_INNER_H #define GRD_RESULTSET_INNER_H -#include "doc_errno.h" +#include "grd_store_errno.h" #include "grd_base/grd_error.h" #include "result_set.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h index b38542368ab..11ee40d5cb2 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_type_inner.h @@ -16,7 +16,7 @@ #ifndef GRD_TYPE_INNER_H #define GRD_TYPE_INNER_H -#include "doc_errno.h" +#include "grd_store_errno.h" #include "grd_store.h" #include "grd_base/grd_error.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp index 0fce7bfe82b..5dd584399fe 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp @@ -19,6 +19,7 @@ #include "grd_base/grd_error.h" #include "grd_type_inner.h" #include "rd_log_print.h" + namespace GRDDB { int32_t GRD_KVPutInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT *key, const GRD_KVItemT *value) { diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/doc_errno.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_errno.h similarity index 95% rename from frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/doc_errno.h rename to frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_errno.h index 7b1be9f81ef..7b1110530be 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/doc_errno.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_errno.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef DOC_ERRNO_H -#define DOC_ERRNO_H +#ifndef GRD_STORE_ERRNO_H +#define GRD_STORE_ERRNO_H namespace GRDDB { constexpr int E_OK = 0; @@ -45,4 +45,4 @@ constexpr int E_NOT_SUPPORT = E_BASE + 55; int TransferDocErr(int err); } // namespace GRDDB -#endif // DOC_ERRNO_H \ No newline at end of file +#endif // GRD_STORE_ERRNO_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/projection_tree.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/projection_tree.h index bc110e82f16..35673b73a33 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/projection_tree.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/projection_tree.h @@ -19,7 +19,7 @@ #include #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "json_common.h" #include "rd_log_print.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h index c7e9a7eaf27..bee5e396c89 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h @@ -21,7 +21,7 @@ #include #include "check_common.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "grd_store.h" #include "grd_base/grd_type_export.h" #include "rd_json_object.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h index 7cc4c4c6464..d2afe8b5ed8 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set_common.h @@ -18,7 +18,7 @@ #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "grd_base/grd_type_export.h" #include "result_set.h" #include "vector" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp index 6ccfc973cdc..86fd527d9fb 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp @@ -17,7 +17,7 @@ #include "check_common.h" #include "rd_db_constant.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "document_key.h" #include "rd_log_print.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_key.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_key.cpp index cfbb276e9b3..a1b1fb7f7f1 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_key.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/document_key.cpp @@ -17,7 +17,7 @@ #include #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "rd_log_print.h" #include "securec.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp index 22bb0384587..5a261211973 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp @@ -17,7 +17,7 @@ #include "check_common.h" #include "collection_option.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "document_key.h" #include "grd_base/grd_type_export.h" #include "grd_resultset_inner.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/doc_errno.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_errno.cpp similarity index 99% rename from frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/doc_errno.cpp rename to frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_errno.cpp index 84f2638b5ff..dfb826452f6 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/doc_errno.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_errno.cpp @@ -13,7 +13,8 @@ * limitations under the License. */ -#include "doc_errno.h" +#include " +.h" #include "grd_base/grd_error.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_manager.cpp index a537d8b125e..d44497698a2 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_manager.cpp @@ -16,7 +16,7 @@ #include "grd_store_manager.h" #include "db_config.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "grd_base/grd_type_export.h" #include "kv_store_manager.h" #include "os_api.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp index acf3080abf3..d5d2ef37ede 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set_common.cpp @@ -15,7 +15,7 @@ #include "result_set_common.h" #include "grd_format_config.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "grd_base/grd_error.h" namespace GRDDB { diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/kv_store_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/kv_store_manager.cpp index 255377d3433..03fef46ee34 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/kv_store_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/kv_store_manager.cpp @@ -15,7 +15,7 @@ #include "kv_store_manager.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "rd_log_print.h" #include "rd_sqlite_utils.h" #include "sqlite_store_executor_impl.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_json_object.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_json_object.cpp index 6edbf715b52..2dfb69c7466 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_json_object.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_json_object.cpp @@ -19,7 +19,7 @@ #include #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "json_common.h" #include "rd_log_print.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp index 6f115738562..90b252bd2eb 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp @@ -16,7 +16,7 @@ #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "rd_log_print.h" namespace GRDDB { diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp index 5bc30b4bcc0..d9c316a5b9e 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp @@ -17,7 +17,7 @@ #include "check_common.h" #include "rd_db_constant.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "document_key.h" #include "rd_log_print.h" #include "rd_sqlite_utils.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn index 98800453ffd..74b4be33916 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/BUILD.gn @@ -61,7 +61,7 @@ ohos_source_set("src_file") { "../../src/executor/kv/grd_kv_api.cpp", "../../src/executor/kv/grd_kv_api_inner.cpp", "../../src/interface/src/collection.cpp", - "../../src/interface/src/doc_errno.cpp", + "../../src/interface/src/grd_store_errno.cpp", "../../src/interface/src/document_key.cpp", "../../src/interface/src/grd_store.cpp", "../../src/interface/src/grd_store_manager.cpp", diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp index 5a2e8eba22f..76a6186fcac 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_api_test.cpp @@ -15,7 +15,7 @@ #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "doc_limit.h" #include "documentdb_test_utils.h" #include "grd_base/grd_db_api.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_collection_test.cpp b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_collection_test.cpp index fae995e4374..cfe36263db6 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_collection_test.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_collection_test.cpp @@ -15,7 +15,7 @@ #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "documentdb_test_utils.h" #include "grd_base/grd_db_api.h" #include "grd_base/grd_error.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_data_test.cpp b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_data_test.cpp index 9955b787a74..b0b7c9b1683 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_data_test.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_data_test.cpp @@ -16,7 +16,7 @@ #include #include "cJSON.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "documentdb_test_utils.h" #include "grd_base/grd_db_api.h" #include "grd_base/grd_error.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_find_test.cpp b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_find_test.cpp index 7d44b2e1a7f..f07f89ba5a6 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_find_test.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/api/documentdb_find_test.cpp @@ -17,7 +17,7 @@ #include #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "documentdb_test_utils.h" #include "grd_base/grd_db_api.h" #include "grd_base/grd_error.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_json_common_test.cpp b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_json_common_test.cpp index 0902e60e43a..53339e14041 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_json_common_test.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_json_common_test.cpp @@ -16,7 +16,7 @@ #include #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "documentdb_test_utils.h" #include "json_common.h" #include "rd_log_print.h" diff --git a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_jsonobject_test.cpp b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_jsonobject_test.cpp index cb2eda80617..e4d24be634c 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_jsonobject_test.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/test/unittest/oh_adapter/documentdb_jsonobject_test.cpp @@ -15,7 +15,7 @@ #include -#include "doc_errno.h" +#include "grd_store_errno.h" #include "documentdb_test_utils.h" #include "rd_json_object.h" diff --git a/frameworks/libs/distributeddb/test/BUILD.gn b/frameworks/libs/distributeddb/test/BUILD.gn index d83b7def48b..ea0aa68a5c2 100644 --- a/frameworks/libs/distributeddb/test/BUILD.gn +++ b/frameworks/libs/distributeddb/test/BUILD.gn @@ -142,7 +142,7 @@ ohos_source_set("src_file") { "../gaussdb_rd/src/executor/kv/grd_kv_api.cpp", "../gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp", "../gaussdb_rd/src/interface/src/collection.cpp", - "../gaussdb_rd/src/interface/src/doc_errno.cpp", + "../gaussdb_rd/src/interface/src/grd_store_errno.cpp", "../gaussdb_rd/src/interface/src/document_key.cpp", "../gaussdb_rd/src/interface/src/grd_store.cpp", "../gaussdb_rd/src/interface/src/grd_store_manager.cpp", diff --git a/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn b/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn index a21e5a1b7e1..8ee096d418d 100644 --- a/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn +++ b/frameworks/libs/distributeddb/test/fuzztest/json_fuzzer/BUILD.gn @@ -61,7 +61,7 @@ ohos_source_set("src_file") { "../../../gaussdb_rd/src/executor/kv/grd_kv_api.cpp", "../../../gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp", "../../../gaussdb_rd/src/interface/src/collection.cpp", - "../../../gaussdb_rd/src/interface/src/doc_errno.cpp", + "../../../gaussdb_rd/src/interface/src/grd_store_errno.cpp", "../../../gaussdb_rd/src/interface/src/document_key.cpp", "../../../gaussdb_rd/src/interface/src/grd_store.cpp", "../../../gaussdb_rd/src/interface/src/grd_store_manager.cpp", diff --git a/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn b/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn index 69ea72e02d4..663a74420c1 100644 --- a/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn +++ b/frameworks/libs/distributeddb/test/fuzztest/jsoninner_fuzzer/BUILD.gn @@ -61,7 +61,7 @@ ohos_source_set("src_file") { "../../../gaussdb_rd/src/executor/kv/grd_kv_api.cpp", "../../../gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp", "../../../gaussdb_rd/src/interface/src/collection.cpp", - "../../../gaussdb_rd/src/interface/src/doc_errno.cpp", + "../../../gaussdb_rd/src/interface/src/grd_store_errno.cpp", "../../../gaussdb_rd/src/interface/src/document_key.cpp", "../../../gaussdb_rd/src/interface/src/grd_store.cpp", "../../../gaussdb_rd/src/interface/src/grd_store_manager.cpp", -- Gitee From dec8e86fae0256c0bbd18ac4c63326931d28881c Mon Sep 17 00:00:00 2001 From: bluhuang Date: Tue, 12 Nov 2024 10:40:12 +0800 Subject: [PATCH 14/21] kv api define Signed-off-by: bluhuang --- .../src/executor/kv/grd_kv_api_inner.cpp | 7 +-- .../src/interface/include/grd_store.h | 43 +++++++++++++------ .../src/interface/include/result_set.h | 5 +++ 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp index 5dd584399fe..1a793223c78 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp @@ -17,6 +17,7 @@ #include "check_common.h" #include "grd_api_manager.h" #include "grd_base/grd_error.h" +#include "grd_resultset_inner.h" #include "grd_type_inner.h" #include "rd_log_print.h" @@ -80,7 +81,7 @@ int32_t GRD_KVGetSizeInner(GRD_ResultSet *resultSet, uint32_t *keyLen, uint32_t if (resultSet == nullptr || keyLen == nullptr || valueLen == nullptr) { return GRD_INVALID_ARGS; } - int errCode = resultSet->GetSize(keyLen, valueLen); + int errCode = resultSet->resultSet_.KVGetSize(keyLen, valueLen); if (errCode != GRD_OK) { GLOGE("failed to get size"); return TransferDocErr(errCode); @@ -91,10 +92,10 @@ int32_t GRD_KVGetSizeInner(GRD_ResultSet *resultSet, uint32_t *keyLen, uint32_t int32_t GRD_GetItemInner(GRD_ResultSet *resultSet, void *key, void *value) { - if (resultSet == nullptr || keyLen == nullptr || valueLen == nullptr) { + if (resultSet == nullptr || key == nullptr || value == nullptr) { return GRD_INVALID_ARGS; } - int errCode = resultSet->GetItem(key, value); + int errCode = resultSet->resultSet_.KVGetItem(key, value); if (errCode != GRD_OK) { GLOGE("failed to get size"); return TransferDocErr(errCode); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h index d91daf30705..330eb3c4be7 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h @@ -22,6 +22,7 @@ #include "collection.h" #include "document_type.h" +#include "grd_type_export.h" #include "kv_store_executor.h" struct GRD_ResultSet; @@ -30,11 +31,32 @@ class GRDStore { public: GRDStore(KvStoreExecutor *); ~GRDStore(); - + /** + * Common api: + */ int CreateCollection(const std::string &name, const std::string &option, uint32_t flags); int DropCollection(const std::string &name, uint32_t flags); + Collection GetCollection(std::string &collectionName); + + bool IsExistResultSet(const std::string &collection); + + int EraseCollection(const std::string &collectionName); + + void OnClose(const std::function ¬ifier); + + int Close(uint32_t flags); + + int StartTransaction(); + int Commit(); + int Rollback(); + + bool IsCollectionExists(const std::string &collectionName, int &errCode); + + /** + * Document api: + */ int UpdateDocument(const std::string &collection, const std::string &filter, const std::string &update, uint32_t flags); @@ -48,21 +70,16 @@ public: int FindDocument(const std::string &collection, const std::string &filter, const std::string &projection, uint32_t flags, GRD_ResultSet *grdResultSet); - Collection GetCollection(std::string &collectionName); - - bool IsExistResultSet(const std::string &collection); - - int EraseCollection(const std::string &collectionName); - - void OnClose(const std::function ¬ifier); + /** + * Kv api: + */ + int KVInsert(const std::string &collection, const GRD_KVItemT *key, const GRD_KVItemT *value); - int Close(uint32_t flags); + int KVGet(const std::string &collection, const GRD_KVItemT *key, const GRD_KVItemT *value); - int StartTransaction(); - int Commit(); - int Rollback(); + int KVDelete(const std::string &collection, const GRD_KVItemT *key); - bool IsCollectionExists(const std::string &collectionName, int &errCode); + int KVFilter( const char *collectionName, const GRD_FilterOptionT *scanParams, GRD_ResultSet *resultSet); std::mutex dbMutex_; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h index bee5e396c89..bb668aa70a1 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h @@ -37,6 +37,11 @@ public: int GetValue(std::string &value); int GetKey(std::string &key); int EraseCollection(); + /** + * Kv api: + */ + int KVGetSize(uint32_t *keyLen, uint32_t *valueLen); + int KVGetItem(void *key, void *value); private: int GetNextInner(bool isNeedCheckTable); -- Gitee From 2558ae5cfd839e59a0eefc534db7e549042081ce Mon Sep 17 00:00:00 2001 From: bluhuang Date: Tue, 12 Nov 2024 10:41:29 +0800 Subject: [PATCH 15/21] change errno func name Signed-off-by: bluhuang --- .../src/executor/base/grd_db_api_inner.cpp | 6 +++--- .../document/grd_document_api_inner.cpp | 16 ++++++++-------- .../document/grd_resultset_api_inner.cpp | 4 ++-- .../src/executor/kv/grd_kv_api_inner.cpp | 18 +++++++++--------- .../src/interface/include/grd_store_errno.h | 2 +- .../src/interface/src/grd_store_errno.cpp | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp index b1e3b8a5f40..223150e6e0a 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/base/grd_db_api_inner.cpp @@ -32,7 +32,7 @@ int32_t GRD_DBOpenInner(const char *dbPath, const char *configStr, uint32_t flag GRDStore *store = nullptr; int ret = GRDStoreManager::GetGRDStore(path, config, flags, store); if (ret != E_OK || store == nullptr) { - return TransferDocErr(ret); + return TransToGRDErr(ret); } *db = new (std::nothrow) GRD_DB(); @@ -43,7 +43,7 @@ int32_t GRD_DBOpenInner(const char *dbPath, const char *configStr, uint32_t flag } (*db)->store_ = store; - return TransferDocErr(ret); + return TransToGRDErr(ret); } int32_t GRD_DBCloseInner(GRD_DB *db, uint32_t flags) @@ -54,7 +54,7 @@ int32_t GRD_DBCloseInner(GRD_DB *db, uint32_t flags) int ret = GRDStoreManager::CloseGRDStore(db->store_, flags); if (ret != E_OK) { - return TransferDocErr(ret); + return TransToGRDErr(ret); } db->store_ = nullptr; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp index f50016026a1..1efa992ba83 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp @@ -31,7 +31,7 @@ int32_t GRD_CreateCollectionInner(GRD_DB *db, const char *collectionName, const std::string name = (collectionName == nullptr ? "" : collectionName); std::string option = (optionStr == nullptr ? "" : optionStr); int ret = db->store_->CreateCollection(name, option, flags); - return TransferDocErr(ret); + return TransToGRDErr(ret); } int32_t GRD_DropCollectionInner(GRD_DB *db, const char *collectionName, uint32_t flags) @@ -42,7 +42,7 @@ int32_t GRD_DropCollectionInner(GRD_DB *db, const char *collectionName, uint32_t std::string name = (collectionName == nullptr ? "" : collectionName); int ret = db->store_->DropCollection(name, flags); - return TransferDocErr(ret); + return TransToGRDErr(ret); } int32_t GRD_UpdateDocInner(GRD_DB *db, const char *collectionName, const char *filter, const char *update, @@ -55,7 +55,7 @@ int32_t GRD_UpdateDocInner(GRD_DB *db, const char *collectionName, const char *f if (ret >= 0) { return ret; } - return TransferDocErr(ret); + return TransToGRDErr(ret); } int32_t GRD_UpsertDocInner(GRD_DB *db, const char *collectionName, const char *filter, const char *document, @@ -69,7 +69,7 @@ int32_t GRD_UpsertDocInner(GRD_DB *db, const char *collectionName, const char *f if (ret >= 0) { return ret; } - return TransferDocErr(ret); + return TransToGRDErr(ret); } int32_t GRD_InsertDocInner(GRD_DB *db, const char *collectionName, const char *document, uint32_t flags) @@ -78,7 +78,7 @@ int32_t GRD_InsertDocInner(GRD_DB *db, const char *collectionName, const char *d return GRD_INVALID_ARGS; } int ret = db->store_->InsertDocument(collectionName, document, flags); - return TransferDocErr(ret); + return TransToGRDErr(ret); } int32_t GRD_DeleteDocInner(GRD_DB *db, const char *collectionName, const char *filter, uint32_t flags) @@ -87,7 +87,7 @@ int32_t GRD_DeleteDocInner(GRD_DB *db, const char *collectionName, const char *f return GRD_INVALID_ARGS; } int ret = db->store_->DeleteDocument(collectionName, filter, flags); - int errCode = TransferDocErr(ret); + int errCode = TransToGRDErr(ret); switch (errCode) { case GRD_OK: return 1; // The amount of text deleted @@ -112,9 +112,9 @@ int32_t GRD_FindDocInner(GRD_DB *db, const char *collectionName, Query query, ui int ret = db->store_->FindDocument(collectionName, query.filter, query.projection, flags, grdResultSet); if (ret != E_OK) { delete grdResultSet; - return TransferDocErr(ret); + return TransToGRDErr(ret); } *resultSet = grdResultSet; - return TransferDocErr(ret); + return TransToGRDErr(ret); } } // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api_inner.cpp index debe8c2b5c0..3b9a3777d49 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_resultset_api_inner.cpp @@ -28,7 +28,7 @@ int32_t GRD_NextInner(GRD_ResultSet *resultSet) return GRD_INVALID_ARGS; }; int ret = resultSet->resultSet_.GetNext(true, true); - return TransferDocErr(ret); + return TransToGRDErr(ret); } int32_t GRD_GetValueInner(GRD_ResultSet *resultSet, char **value) @@ -44,7 +44,7 @@ int32_t GRD_GetValueInner(GRD_ResultSet *resultSet, char **value) return GRD_NOT_AVAILABLE; } *value = val; - return TransferDocErr(ret); + return TransToGRDErr(ret); } int32_t GRD_FreeValueInner(char *value) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp index 1a793223c78..9524db46af0 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp @@ -28,7 +28,7 @@ int32_t GRD_KVPutInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT return GRD_INVALID_ARGS; } int ret = db->store_->KVInsert(collectionName, key, value); - return TransferDocErr(ret); + return TransToGRDErr(ret); } int32_t GRD_KVGetInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT *key, const GRD_KVItemT *value) @@ -37,7 +37,7 @@ int32_t GRD_KVGetInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT return GRD_INVALID_ARGS; } int ret = db->store_->KVGet(collectionName, key, value); - return TransferDocErr(ret); + return TransToGRDErr(ret); } int32_t GRD_KVDelInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT *key) @@ -46,7 +46,7 @@ int32_t GRD_KVDelInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT return GRD_INVALID_ARGS; } int ret = db->store_->KVDelete(collectionName, key); - return TransferDocErr(ret); + return TransToGRDErr(ret); } int32_t GRD_KVScanInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT *key, GRD_KvScanModeE mode, @@ -70,10 +70,10 @@ int32_t GRD_KVFilterInner(GRD_DB *db, const char *collectionName, const GRD_Filt int errCode = db->store_->KVFilter(collectionName, scanParams, grdResultSet); if (errCode != E_OK) { delete grdResultSet; - return TransferDocErr(errCode); + return TransToGRDErr(errCode); } *resultSet = grdResultSet; - return TransferDocErr(errCode); + return TransToGRDErr(errCode); } int32_t GRD_KVGetSizeInner(GRD_ResultSet *resultSet, uint32_t *keyLen, uint32_t *valueLen) @@ -84,9 +84,9 @@ int32_t GRD_KVGetSizeInner(GRD_ResultSet *resultSet, uint32_t *keyLen, uint32_t int errCode = resultSet->resultSet_.KVGetSize(keyLen, valueLen); if (errCode != GRD_OK) { GLOGE("failed to get size"); - return TransferDocErr(errCode); + return TransToGRDErr(errCode); } - return TransferDocErr(errCode); + return TransToGRDErr(errCode); } } @@ -98,9 +98,9 @@ int32_t GRD_GetItemInner(GRD_ResultSet *resultSet, void *key, void *value) int errCode = resultSet->resultSet_.KVGetItem(key, value); if (errCode != GRD_OK) { GLOGE("failed to get size"); - return TransferDocErr(errCode); + return TransToGRDErr(errCode); } - return TransferDocErr(errCode); + return TransToGRDErr(errCode); } int32_t GRD_KVFreeItemInner(GRD_KVItemT *item) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_errno.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_errno.h index 7b1110530be..52b7e0c9b27 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_errno.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store_errno.h @@ -43,6 +43,6 @@ constexpr int E_INVALID_FILE_FORMAT = E_BASE + 53; constexpr int E_FAILED_FILE_OPERATION = E_BASE + 54; constexpr int E_NOT_SUPPORT = E_BASE + 55; -int TransferDocErr(int err); +int TransToGRDErr(int err); } // namespace GRDDB #endif // GRD_STORE_ERRNO_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_errno.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_errno.cpp index dfb826452f6..47c0a016c09 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_errno.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_errno.cpp @@ -27,7 +27,7 @@ int GetErrorCategory(int errCode) return categoryCode; } -int TransferDocErr(int err) +int TransToGRDErr(int err) { if (err > 0) { return err; -- Gitee From 06ce06c6a31b89c81725c17712405c2d4d9ff55e Mon Sep 17 00:00:00 2001 From: bluhuang Date: Tue, 12 Nov 2024 10:54:29 +0800 Subject: [PATCH 16/21] fix compile Signed-off-by: bluhuang --- .../src/executor/kv/grd_kv_api_inner.cpp | 3 +-- .../src/interface/include/grd_store.h | 2 +- .../src/interface/src/grd_store.cpp | 25 +++++++++++++++++++ .../src/interface/src/grd_store_errno.cpp | 4 +-- .../src/interface/src/result_set.cpp | 11 ++++++++ 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp index 9524db46af0..e77cf664dc7 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp @@ -42,7 +42,7 @@ int32_t GRD_KVGetInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT int32_t GRD_KVDelInner(GRD_DB *db, const char *collectionName, const GRD_KVItemT *key) { - if (db == nullptr || db->store_ == nullptr || collectionName == nullptr || key == nullptr || value == nullptr) { + if (db == nullptr || db->store_ == nullptr || collectionName == nullptr || key == nullptr) { return GRD_INVALID_ARGS; } int ret = db->store_->KVDelete(collectionName, key); @@ -88,7 +88,6 @@ int32_t GRD_KVGetSizeInner(GRD_ResultSet *resultSet, uint32_t *keyLen, uint32_t } return TransToGRDErr(errCode); } -} int32_t GRD_GetItemInner(GRD_ResultSet *resultSet, void *key, void *value) { diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h index 330eb3c4be7..e9fb0acf2bf 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h @@ -22,7 +22,7 @@ #include "collection.h" #include "document_type.h" -#include "grd_type_export.h" +#include "grd_base/grd_type_export.h" #include "kv_store_executor.h" struct GRD_ResultSet; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp index 5a261211973..163eb610e7a 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp @@ -903,4 +903,29 @@ bool GRDStore::IsCollectionExists(const std::string &collectionName, int &errCod } return executor_->IsCollectionExists(collectionName, errCode); } + +int GRDStore::KVInsert(const std::string &collection, const GRD_KVItemT *key, const GRD_KVItemT *value) +{ + // todohbx + return -E_NOT_SUPPORT; +} + +int GRDStore::KVGet(const std::string &collection, const GRD_KVItemT *key, const GRD_KVItemT *value) +{ + // todohbx + return -E_NOT_SUPPORT; +} + +int GRDStore::KVDelete(const std::string &collection, const GRD_KVItemT *key) +{ + // todohbx + return -E_NOT_SUPPORT; +} + +int GRDStore::KVFilter( const char *collectionName, const GRD_FilterOptionT *scanParams, GRD_ResultSet *resultSet) +{ + // todohbx + return -E_NOT_SUPPORT; +} + } // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_errno.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_errno.cpp index 47c0a016c09..7fbb6f1371d 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_errno.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store_errno.cpp @@ -13,9 +13,7 @@ * limitations under the License. */ -#include " -.h" - +#include "grd_store_errno.h" #include "grd_base/grd_error.h" namespace GRDDB { diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp index 93d826bf573..1da2105ab3d 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp @@ -296,4 +296,15 @@ int ResultSet::CutJsonBranch(std::string &jsonKey, std::string &jsonData) jsonData = cjsonObj.Print(); return E_OK; } + +int ResultSet::KVGetSize(uint32_t *keyLen, uint32_t *valueLen) +{ + // todohbx + return E_OK; +} +int ResultSet::KVGetItem(void *key, void *value) +{ + // todohbx + return E_OK; +} } // namespace GRDDB -- Gitee From 2ff783c8dedc317fe96aabd99b12f16e1c238f60 Mon Sep 17 00:00:00 2001 From: bluhuang Date: Tue, 12 Nov 2024 15:05:37 +0800 Subject: [PATCH 17/21] implete kv api Signed-off-by: bluhuang --- .../document/grd_document_api_inner.cpp | 2 +- .../src/executor/kv/grd_kv_api_inner.cpp | 28 ++++++++++++- .../src/interface/include/collection.h | 11 ++++- .../src/interface/include/grd_store.h | 11 ++++- .../src/interface/src/collection.cpp | 27 +++++++++++- .../src/interface/src/grd_store.cpp | 41 +++++++++++++++---- .../src/sqlite_store_executor_impl.cpp | 2 +- 7 files changed, 107 insertions(+), 15 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp index 1efa992ba83..c95ff50582e 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/document/grd_document_api_inner.cpp @@ -86,7 +86,7 @@ int32_t GRD_DeleteDocInner(GRD_DB *db, const char *collectionName, const char *f if (db == nullptr || db->store_ == nullptr || filter == nullptr || collectionName == nullptr) { return GRD_INVALID_ARGS; } - int ret = db->store_->DeleteDocument(collectionName, filter, flags); + int ret = db->store_->DeleteDataByKey(collectionName, filter, flags); int errCode = TransToGRDErr(ret); switch (errCode) { case GRD_OK: diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp index e77cf664dc7..c3a475bc8b9 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp @@ -55,6 +55,32 @@ int32_t GRD_KVScanInner(GRD_DB *db, const char *collectionName, const GRD_KVItem return GRD_NOT_SUPPORT; } + // GRD_FilterOptionT param; + // param.mode = KV_SCAN_ALL; + // GRD_ResultSet *resultSet = nullptr; + + // int retryTimes = CREATE_COLLECTION_RETRY_TIMES; + // int ret = E_OK; + + // do { + // ret = PreferenceDbAdapter::GetApiInstance().DbKvFilterApi(db_, TABLENAME, ¶m, &resultSet); + // if (ret == GRD_UNDEFINED_TABLE) { + // LOG_INFO("CreateCollection called when GetAll, file: %{public}s", ExtractFileName(dbPath_).c_str()); + // (void)CreateCollection(); + // } else if (ret == GRD_OK) { + // int innerErr = GetAllInner(data, resultSet); // log inside when failed + // PreferenceDbAdapter::GetApiInstance().FreeResultSetApi(resultSet); + // return innerErr; + // } else { + // LOG_ERROR("rd kv filter failed:%{public}d", ret); + // return TransferGrdErrno(ret); + // } + // retryTimes--; + // } while (retryTimes > 0); + + // LOG_ERROR("rd get over retry times, errcode: :%{public}d", ret); + // return TransferGrdErrno(ret); + int32_t GRD_KVFilterInner(GRD_DB *db, const char *collectionName, const GRD_FilterOptionT *scanParams, GRD_ResultSet **resultSet) { @@ -66,7 +92,7 @@ int32_t GRD_KVFilterInner(GRD_DB *db, const char *collectionName, const GRD_Filt GLOGE("Memory allocation failed when kv filter!"); return GRD_FAILED_MEMORY_ALLOCATE; } - + // todohbx: resultset已经创建,这里应该初始化result set,然后将result set返回, int errCode = db->store_->KVFilter(collectionName, scanParams, grdResultSet); if (errCode != E_OK) { delete grdResultSet; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/collection.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/collection.h index d576194bcf4..eab5506b458 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/collection.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/collection.h @@ -27,15 +27,24 @@ public: Collection(const std::string &name, KvStoreExecutor *executor); ~Collection(); + /** + * Document api: + */ int InsertDocument(const std::string &id, const std::string &document, bool &isIdExist); int GetDocumentById(Key &key, Value &document) const; int GetMatchedDocument(const JsonObject &filterObj, Key &key, std::pair &values, int isIdExist) const; - int DeleteDocument(Key &key); + int DeleteDataByKey(Key &key); int IsCollectionExists(int &errCode); int UpsertDocument(const std::string &id, const std::string &newDocument, bool &isIdExist); int UpdateDocument(const std::string &id, const std::string &document); + /** + * Kv api: + */ + int InsertKv(Key &key, const Value &value); + int GetKv(Key &key, Value &value) const; + private: int InsertUntilSuccess(Key &key, const std::string &id, Value &valSet); std::string name_; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h index e9fb0acf2bf..8827c398617 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h @@ -65,7 +65,7 @@ public: int InsertDocument(const std::string &collection, const std::string &document, uint32_t flags); - int DeleteDocument(const std::string &collection, const std::string &filter, uint32_t flags); + int DeleteDataByKey(const std::string &collection, const std::string &filter, uint32_t flags); int FindDocument(const std::string &collection, const std::string &filter, const std::string &projection, uint32_t flags, GRD_ResultSet *grdResultSet); @@ -84,6 +84,9 @@ public: std::mutex dbMutex_; private: + /** + * Document private api: + */ int UpdateDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, const std::string &update, bool &isReplace); int UpsertDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, const std::string &document, @@ -92,6 +95,12 @@ private: bool &isIdExist); int DeleteDataFromDB(std::shared_ptr &context, JsonObject &filterObj); int InitFindResultSet(GRD_ResultSet *grdResultSet, std::shared_ptr &context); + + /** + * Kv private api: + */ + std::vector KvItemToBlob(GRD_KVItemT &item); + KvStoreExecutor *executor_ = nullptr; std::map collections_; std::function closeNotifier_; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp index 86fd527d9fb..a728272fcd4 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp @@ -78,7 +78,7 @@ int Collection::GetDocumentById(Key &key, Value &document) const return executor_->GetDataById(name_, key, document); } -int Collection::DeleteDocument(Key &key) +int Collection::DeleteDataByKey(Key &key) { if (executor_ == nullptr) { return -E_INNER_ERROR; @@ -151,4 +151,29 @@ int Collection::UpdateDocument(const std::string &id, const std::string &newDocu Value valSet(newDocument.begin(), newDocument.end()); return executor_->PutData(name_, keyId, valSet); } + +int Collection::InsertKv(Key &key, const Value &value) +{ + if (executor_ == nullptr) { + return -E_INNER_ERROR; + } + int errCode = E_OK; + bool isCollectionExist = IsCollectionExists(errCode); + if (errCode != E_OK) { + return errCode; + } + if (!isCollectionExist) { + return -E_INVALID_ARGS; + } + return executor_->PutData(name_, key, value); +} + +int Collection::GetKv(Key &key, Value &value) const +{ + if (executor_ == nullptr) { + return -E_INNER_ERROR; + } + return executor_->GetDataByKey(name_, key, value); +} + } // namespace GRDDB diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp index 163eb610e7a..83dea723ed8 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp @@ -539,7 +539,7 @@ int GRDStore::InsertDocument(const std::string &collection, const std::string &d int DeleteArgsCheck(const std::string &collection, const std::string &filter, uint32_t flags) { if (flags != 0u) { - GLOGE("DeleteDocument flags is not zero"); + GLOGE("DeleteDataByKey flags is not zero"); return -E_INVALID_ARGS; } std::string lowerCaseCollName; @@ -584,7 +584,7 @@ int GRDStore::DeleteDataFromDB(std::shared_ptr &context, JsonObjec END: if (errCode == E_OK) { Key key(id.begin(), id.end()); - errCode = coll.DeleteDocument(key); + errCode = coll.DeleteDataByKey(key); } if (errCode == E_OK || errCode == E_NOT_FOUND) { executor_->Commit(); @@ -593,7 +593,7 @@ END: } return errCode; } -int GRDStore::DeleteDocument(const std::string &collection, const std::string &filter, uint32_t flags) +int GRDStore::DeleteDataByKey(const std::string &collection, const std::string &filter, uint32_t flags) { int errCode = DeleteArgsCheck(collection, filter, flags); if (errCode != E_OK) { @@ -906,20 +906,43 @@ bool GRDStore::IsCollectionExists(const std::string &collectionName, int &errCod int GRDStore::KVInsert(const std::string &collection, const GRD_KVItemT *key, const GRD_KVItemT *value) { - // todohbx - return -E_NOT_SUPPORT; + std::string lowerCaseCollName; + int errCode = E_OK; + if (!CheckCommon::CheckCollectionName(collection, lowerCaseCollName, errCode)) { + GLOGE("Check collection name invalid. %d", errCode); + return errCode; + } + Collection coll = Collection(collection, executor_); + Key blobKey = std::vector((uint8_t *)key->data, (uint8_t *)key->data + key->dataLen); + const Value blobValue = std::vector((uint8_t *)value->data, (uint8_t *)value->data + value->dataLen); + return coll.InsertKv(blobKey, blobValue); } int GRDStore::KVGet(const std::string &collection, const GRD_KVItemT *key, const GRD_KVItemT *value) { - // todohbx - return -E_NOT_SUPPORT; + std::string lowerCaseCollName; + int errCode = E_OK; + if (!CheckCommon::CheckCollectionName(collection, lowerCaseCollName, errCode)) { + GLOGE("Check collection name invalid. %d", errCode); + return errCode; + } + Collection coll = Collection(collection, executor_); + Key blobKey = std::vector((uint8_t *)key->data, (uint8_t *)key->data + key->dataLen); + Value blobValue; + return coll.GetKv(blobKey, blobValue); } int GRDStore::KVDelete(const std::string &collection, const GRD_KVItemT *key) { - // todohbx - return -E_NOT_SUPPORT; + std::string lowerCaseCollName; + int errCode = E_OK; + if (!CheckCommon::CheckCollectionName(collection, lowerCaseCollName, errCode)) { + GLOGE("Check collection name invalid. %d", errCode); + return errCode; + } + Collection coll = Collection(collection, executor_); + Key blobKey = std::vector((uint8_t *)key->data, (uint8_t *)key->data + key->dataLen); + return coll.DeleteDataByKey(blobKey); } int GRDStore::KVFilter( const char *collectionName, const GRD_FilterOptionT *scanParams, GRD_ResultSet *resultSet) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp index d9c316a5b9e..5bc30b4bcc0 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp @@ -17,7 +17,7 @@ #include "check_common.h" #include "rd_db_constant.h" -#include "grd_store_errno.h" +#include "doc_errno.h" #include "document_key.h" #include "rd_log_print.h" #include "rd_sqlite_utils.h" -- Gitee From d870f08457fd3c16c76003a438fe12d3dec6ec02 Mon Sep 17 00:00:00 2001 From: bluhuang Date: Tue, 12 Nov 2024 17:29:37 +0800 Subject: [PATCH 18/21] add result set Signed-off-by: bluhuang --- .../include/grd_base/grd_type_export.h | 1 + .../src/interface/include/collection.h | 1 + .../src/interface/include/grd_store.h | 2 +- .../src/interface/include/result_set.h | 10 +++++ .../src/interface/src/collection.cpp | 8 ++++ .../src/interface/src/grd_store.cpp | 40 +++++++++++++++-- .../src/interface/src/result_set.cpp | 22 ++++++++++ .../oh_adapter/include/kv_store_executor.h | 2 + .../src/oh_adapter/src/rd_sqlite_utils.cpp | 44 +++++++++++++++++++ .../src/oh_adapter/src/rd_sqlite_utils.h | 3 ++ .../src/sqlite_store_executor_impl.cpp | 12 ++++- .../src/sqlite_store_executor_impl.h | 4 ++ 12 files changed, 144 insertions(+), 5 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/include/grd_base/grd_type_export.h b/frameworks/libs/distributeddb/gaussdb_rd/include/grd_base/grd_type_export.h index b67478955ad..de47c9546a3 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/include/grd_base/grd_type_export.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/include/grd_base/grd_type_export.h @@ -67,6 +67,7 @@ typedef enum KvScanMode { KV_SCAN_EQUAL_OR_LESS_KEY = 1, KV_SCAN_EQUAL_OR_GREATER_KEY = 2, KV_SCAN_RANGE = 3, + KV_SCAN_ALL = 4, KV_SCAN_BUTT } GRD_KvScanModeE; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/collection.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/collection.h index eab5506b458..497ce253a09 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/collection.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/collection.h @@ -44,6 +44,7 @@ public: */ int InsertKv(Key &key, const Value &value); int GetKv(Key &key, Value &value) const; + int GetAllKv(std::vector> &data); private: int InsertUntilSuccess(Key &key, const std::string &id, Value &valSet); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h index 8827c398617..784f7cd26db 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/grd_store.h @@ -79,7 +79,7 @@ public: int KVDelete(const std::string &collection, const GRD_KVItemT *key); - int KVFilter( const char *collectionName, const GRD_FilterOptionT *scanParams, GRD_ResultSet *resultSet); + int KVFilter( const char *collectionName, const GRD_FilterOptionT *scanParams, GRD_ResultSet *grdResultSet); std::mutex dbMutex_; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h index bb668aa70a1..cf4e5b94c31 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h @@ -40,6 +40,7 @@ public: /** * Kv api: */ + int InitKvResultSet(std::string collectionName, GRDStore *store); int KVGetSize(uint32_t *keyLen, uint32_t *valueLen); int KVGetItem(void *key, void *value); @@ -59,6 +60,15 @@ private: std::shared_ptr context_; std::pair matchData_; std::string lastKeyIndex_; + + /** + * Kv: + */ + std::string collectionName_; + int position_ = -1; + int maxPosition_ = 0; + std::vector> data_; + std::mutex mutex_; }; } // namespace GRDDB #endif // RESULTSET_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp index a728272fcd4..6173f1da97f 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/collection.cpp @@ -176,4 +176,12 @@ int Collection::GetKv(Key &key, Value &value) const return executor_->GetDataByKey(name_, key, value); } +int Collection::GetAllKv(std::vector> &data) +{ + if (executor_ == nullptr) { + return -E_INNER_ERROR; + } + return executor_->GetAllKvByOrder(name_, data); +} + } // namespace GRDDB diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp index 83dea723ed8..2757bdfd04f 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/grd_store.cpp @@ -945,10 +945,44 @@ int GRDStore::KVDelete(const std::string &collection, const GRD_KVItemT *key) return coll.DeleteDataByKey(blobKey); } -int GRDStore::KVFilter( const char *collectionName, const GRD_FilterOptionT *scanParams, GRD_ResultSet *resultSet) +int GRDStore::KVFilter(const char *collectionName, const GRD_FilterOptionT *scanParams, GRD_ResultSet *grdResultSet) { - // todohbx - return -E_NOT_SUPPORT; + if (scanParams == nullptr || scanParams->mode != KV_SCAN_ALL) { + GLOGE("KVFilter failed, invalid scan params"); + return -E_INVALID_ARGS; + } + std::string lowerCaseCollName; + int errCode = E_OK; + if (!CheckCommon::CheckCollectionName(collectionName, lowerCaseCollName, errCode)) { + GLOGE("Check collection name invalid. %d", errCode); + return errCode; + } + if (executor_ == nullptr) { + return -E_INNER_ERROR; + } + + Collection coll = Collection(collectionName, executor_); + + errCode = executor_->StartTransaction(); + if (errCode != E_OK) { + return errCode; + } + if (!coll.IsCollectionExists(errCode)) { + errCode = -E_INVALID_ARGS; + } + if (errCode != E_OK) { + goto FILTER_END; + } + + errCode = grdResultSet->resultSet_.InitKvResultSet(collectionName, this); + +FILTER_END: + if (errCode == E_OK) { + executor_->Commit(); + } else { + executor_->Rollback(); + } + return errCode; } } // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp index 1da2105ab3d..171b9c851c1 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp @@ -297,6 +297,28 @@ int ResultSet::CutJsonBranch(std::string &jsonKey, std::string &jsonData) return E_OK; } +int ResultSet::InitKvResultSet(std::string collectionName, GRDStore *store) +{ + std::lock_guard lock(mutex_); + + collectionName_ = collectionName; + store_ = store; + position_ = -1; + maxPosition_ = 0; + + // 获取所有数据 + Collection coll = store_->GetCollection(collectionName); + std::vector> data; + int errCode = coll.GetAllKv(data); + if (errCode != E_OK) { + return errCode; + } + + data_ = data; + maxPosition_ = data.size(); + return E_OK; +} + int ResultSet::KVGetSize(uint32_t *keyLen, uint32_t *valueLen) { // todohbx diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/kv_store_executor.h b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/kv_store_executor.h index 8d48c3bf710..fc84bdce819 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/kv_store_executor.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/include/kv_store_executor.h @@ -43,6 +43,8 @@ public: virtual int SetCollectionOption(const std::string &name, const std::string &option) = 0; virtual int CleanCollectionOption(const std::string &name) = 0; + + virtual int GetAllKvByOrder(const std::string &name, std::vector> &data) = 0; }; } // namespace GRDDB #endif // KV_STORE_EXECUTOR_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp index 90b252bd2eb..00252b3934b 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp @@ -282,4 +282,48 @@ END: (void)RDSQLiteUtils::ResetStatement(stmt, true); return MapSqliteError(errCode); } + +int RDSQLiteUtils::GetBatchDataBySql(sqlite3 *db, const std::string &sql, + std::vector, std::vector>> &data) +{ + if (db == nullptr || sql.empty()) { + return -E_INVALID_ARGS; + } + sqlite3_stmt *statement = nullptr; + int errCode = RDSQLiteUtils::GetStatement(db, sql, statement); + if (errCode != E_OK) { // LCOV_EXCL_BR_LINE + return errCode; + } + + do { + errCode = RDSQLiteUtils::StepWithRetry(statement); + if (errCode == MapSqliteError(SQLITE_ROW)) { + std::vector key; + std::vector value; + errCode = RDSQLiteUtils::GetColumnBlobValue(statement, 0, key); + if (errCode != E_OK) { // LCOV_EXCL_BR_LINE + goto END; + } + + errCode = RDSQLiteUtils::GetColumnBlobValue(statement, 1, value); + if (errCode != E_OK) { // LCOV_EXCL_BR_LINE + goto END; + } + + data.push_back(std::make_pair(key, value)); + } else if (errCode == MapSqliteError(SQLITE_DONE)) { + break; + } else { + GLOGE("SQLite step failed:%d", errCode); + goto END; + } + } while (true); + + errCode = E_OK; + +END: + (void)RDSQLiteUtils::ResetStatement(statement, true); + return MapSqliteError(errCode); +} + } // namespace GRDDB diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.h b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.h index 4c82c7211d9..9cb5507114d 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.h @@ -49,6 +49,9 @@ public: static int ExecSql(sqlite3 *db, const std::string &sql, const std::function &bindCallback, const std::function &resultCallback); + static int GetBatchDataBySql(sqlite3 *db, const std::string &sql, + std::vector, std::vector>> &data); + private: static void SqliteLogCallback(void *data, int err, const char *msg); }; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp index 5bc30b4bcc0..c28e8c55721 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp @@ -17,7 +17,7 @@ #include "check_common.h" #include "rd_db_constant.h" -#include "doc_errno.h" +#include "grd_store_errno.h" #include "document_key.h" #include "rd_log_print.h" #include "rd_sqlite_utils.h" @@ -409,4 +409,14 @@ int SqliteStoreExecutorImpl::CleanCollectionOption(const std::string &name) Key collOptKey = { collOptKeyStr.begin(), collOptKeyStr.end() }; return DelData("grd_meta", collOptKey); } + +int SqliteStoreExecutorImpl::GetAllKvByOrder(const std::string &name, std::vector> &data) +{ + if (dbHandle_ == nullptr) { + return -E_INVALID_ARGS; + } + data.clear(); + std::string sql = "SELECT key, value FROM '" + name + "' ORDER BY KEY;"; + return RDSQLiteUtils::GetBatchDataBySql(dbHandle_, sql, data); +} } // namespace GRDDB \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.h b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.h index e71ca8e3f51..ec5fdb3d733 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.h @@ -52,6 +52,10 @@ public: int SetCollectionOption(const std::string &name, const std::string &option) override; int CleanCollectionOption(const std::string &name) override; + /** + * Kv api: + */ + int GetAllKvByOrder(const std::string &name, std::vector> &data) override; private: sqlite3 *dbHandle_ = nullptr; }; -- Gitee From dc5056de93286363727a08723e98aa59efc5ccf8 Mon Sep 17 00:00:00 2001 From: bluhuang Date: Tue, 12 Nov 2024 19:42:38 +0800 Subject: [PATCH 19/21] add result set impl Signed-off-by: bluhuang --- .../src/executor/kv/grd_kv_api_inner.cpp | 26 ---------------- .../src/interface/include/result_set.h | 10 ++++-- .../src/interface/src/result_set.cpp | 31 +++++++++++++++++-- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp index c3a475bc8b9..1de0f8f480a 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp @@ -55,32 +55,6 @@ int32_t GRD_KVScanInner(GRD_DB *db, const char *collectionName, const GRD_KVItem return GRD_NOT_SUPPORT; } - // GRD_FilterOptionT param; - // param.mode = KV_SCAN_ALL; - // GRD_ResultSet *resultSet = nullptr; - - // int retryTimes = CREATE_COLLECTION_RETRY_TIMES; - // int ret = E_OK; - - // do { - // ret = PreferenceDbAdapter::GetApiInstance().DbKvFilterApi(db_, TABLENAME, ¶m, &resultSet); - // if (ret == GRD_UNDEFINED_TABLE) { - // LOG_INFO("CreateCollection called when GetAll, file: %{public}s", ExtractFileName(dbPath_).c_str()); - // (void)CreateCollection(); - // } else if (ret == GRD_OK) { - // int innerErr = GetAllInner(data, resultSet); // log inside when failed - // PreferenceDbAdapter::GetApiInstance().FreeResultSetApi(resultSet); - // return innerErr; - // } else { - // LOG_ERROR("rd kv filter failed:%{public}d", ret); - // return TransferGrdErrno(ret); - // } - // retryTimes--; - // } while (retryTimes > 0); - - // LOG_ERROR("rd get over retry times, errcode: :%{public}d", ret); - // return TransferGrdErrno(ret); - int32_t GRD_KVFilterInner(GRD_DB *db, const char *collectionName, const GRD_FilterOptionT *scanParams, GRD_ResultSet **resultSet) { diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h index cf4e5b94c31..b124511a9ea 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/include/result_set.h @@ -27,6 +27,10 @@ #include "rd_json_object.h" namespace GRDDB { +enum GRD_ResultSetType { + DOCUMENT_RESULT_SET = 0, + KV_RESULT_SET +}; class ResultSet { public: ResultSet(); @@ -43,6 +47,7 @@ public: int InitKvResultSet(std::string collectionName, GRDStore *store); int KVGetSize(uint32_t *keyLen, uint32_t *valueLen); int KVGetItem(void *key, void *value); + int KVNext(); private: int GetNextInner(bool isNeedCheckTable); @@ -65,10 +70,11 @@ private: * Kv: */ std::string collectionName_; - int position_ = -1; - int maxPosition_ = 0; + size_t position_ = -1; + size_t maxPosition_ = 0; std::vector> data_; std::mutex mutex_; + int type_ = DOCUMENT_RESULT_SET; }; } // namespace GRDDB #endif // RESULTSET_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp index 171b9c851c1..bc47c24229e 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/interface/src/result_set.cpp @@ -124,6 +124,9 @@ int ResultSet::GetNextInner(bool isNeedCheckTable) int ResultSet::GetNext(bool isNeedTransaction, bool isNeedCheckTable) { + if (type_ == KV_RESULT_SET) { + return KVNext(); + } if (!isNeedTransaction) { return GetNextInner(isNeedCheckTable); } @@ -300,7 +303,7 @@ int ResultSet::CutJsonBranch(std::string &jsonKey, std::string &jsonData) int ResultSet::InitKvResultSet(std::string collectionName, GRDStore *store) { std::lock_guard lock(mutex_); - + type_ = KV_RESULT_SET; collectionName_ = collectionName; store_ = store; position_ = -1; @@ -319,14 +322,36 @@ int ResultSet::InitKvResultSet(std::string collectionName, GRDStore *store) return E_OK; } +int ResultSet::KVNext() +{ + std::lock_guard lock(mutex_); + if (data_.empty()) { + return -E_NOT_FOUND; + } + if (position_ >= (maxPosition_ - 1)) { + position_ = maxPosition_; + return -E_NOT_FOUND; + } + position_++; + return E_OK; +} + int ResultSet::KVGetSize(uint32_t *keyLen, uint32_t *valueLen) { - // todohbx + if (data_.empty() || position_ < 0 || position_ >= maxPosition_ || data_.size() != maxPosition_) { + return -E_NOT_FOUND; + } + *keyLen = data_[position_].first.size(); + *valueLen = data_[position_].second.size(); return E_OK; } int ResultSet::KVGetItem(void *key, void *value) { - // todohbx + if (data_.empty() || position_ < 0 || position_ >= maxPosition_ || data_.size() != maxPosition_) { + return -E_NOT_FOUND; + } + key = data_[position_].first.data(); + value = data_[position_].second.data(); return E_OK; } } // namespace GRDDB -- Gitee From 13100981efc0865f22525d8456480837c6b39eed Mon Sep 17 00:00:00 2001 From: bluhuang Date: Wed, 13 Nov 2024 11:19:39 +0800 Subject: [PATCH 20/21] add config and repair Signed-off-by: bluhuang --- .../include/grd_base/grd_type_export.h | 30 +++++++++++++++++++ .../gaussdb_rd/include/grd_kv/grd_kv_api.h | 2 ++ .../src/common/include/grd_api_manager.h | 5 ++++ .../src/common/src/grd_api_manager.cpp | 4 +++ .../src/executor/include/grd_kv_api_inner.h | 4 +++ .../gaussdb_rd/src/executor/kv/grd_kv_api.cpp | 23 ++++++++++++++ .../src/executor/kv/grd_kv_api_inner.cpp | 11 +++++++ 7 files changed, 79 insertions(+) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/include/grd_base/grd_type_export.h b/frameworks/libs/distributeddb/gaussdb_rd/include/grd_base/grd_type_export.h index de47c9546a3..00f4f7536bf 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/include/grd_base/grd_type_export.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/include/grd_base/grd_type_export.h @@ -94,6 +94,36 @@ typedef struct GRD_KVBatch GRD_KVBatchT; #define GRD_DOC_APPEND 0 #define GRD_DOC_REPLACE 1 +typedef enum { + GRD_CONFIG_USER_VERSION, + GRD_CONFIG_DATA_VERSION, + GRD_CONFIG_BOTTOM, +} GRD_ConfigTypeE; + +typedef enum { + GRD_DB_DATATYPE_INTEGER = 0, + GRD_DB_DATATYPE_FLOAT, + GRD_DB_DATATYPE_TEXT, + GRD_DB_DATATYPE_BLOB, + GRD_DB_DATATYPE_FLOATVECTOR, + GRD_DB_DATATYPE_NULL, +} GRD_DbDataTypeE; + +typedef struct GRD_DbValueT { + GRD_DbDataTypeE type; + union { + int64_t longValue; + double doubleValue; + struct { + union { + const void *strAddr; + void *freeAddr; + }; + uint32_t length; + }; + } value; +} GRD_DbValueT; + #ifdef __cplusplus } #endif // __cplusplus diff --git a/frameworks/libs/distributeddb/gaussdb_rd/include/grd_kv/grd_kv_api.h b/frameworks/libs/distributeddb/gaussdb_rd/include/grd_kv/grd_kv_api.h index 584b398a910..5c51fa957d7 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/include/grd_kv/grd_kv_api.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/include/grd_kv/grd_kv_api.h @@ -52,6 +52,8 @@ GRD_API int32_t GRD_KVBatchPut(GRD_DB *db, const char *collectionName, GRD_KVBat GRD_API int32_t GRD_KVBatchDel(GRD_DB *db, const char *collectionName, GRD_KVBatchT *batch); GRD_API int32_t GRD_KVBatchDestroy(GRD_KVBatchT *batch); + +GRD_API GRD_DbValueT GRD_GetConfig(GRD_DB *db, GRD_ConfigTypeE type); #ifdef __cplusplus } #endif diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/grd_api_manager.h b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/grd_api_manager.h index 44cda4c6725..1f82e89968d 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/grd_api_manager.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/include/grd_api_manager.h @@ -57,6 +57,9 @@ typedef int32_t (*KVBatchPushback)(const void *key, uint32_t keyLen, const void typedef int32_t (*KVBatchPut)(GRD_DB *db, const char *collectionName, GRD_KVBatchT *batch); typedef int32_t (*KVBatchDel)(GRD_DB *db, const char *collectionName, GRD_KVBatchT *batch); typedef int32_t (*KVBatchDestory)(GRD_KVBatchT *batch); +typedef GRD_DbValueT (*GetConfig)(GRD_DB *db, GRD_ConfigTypeE type); +typedef int32_t (*DBRepair)(const char *dbFile, const char *configStr); + struct GRD_APIInfo { DBOpen DBOpenApi = nullptr; DBClose DBCloseApi = nullptr; @@ -90,6 +93,8 @@ struct GRD_APIInfo { KVBatchDel KVBatchPutApi = nullptr; KVBatchDel KVBatchDelApi = nullptr; KVBatchDestory KVBatchDestoryApi = nullptr; + GetConfig GetConfigApi = nullptr; + DBRepair DBRepairApi = nullptr; }; GRD_APIInfo GetApiInfoInstance(); void InitApiInfo(const char *configStr); diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp index 6eb790a780c..b11dad7cb7f 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp @@ -70,6 +70,8 @@ void GRD_DBApiInitCommon(GRD_APIInfo &GRD_DBApiInfo) GRD_DBApiInfo.KVBatchPutApi = GRD_KVBatchPutInner; GRD_DBApiInfo.KVBatchDelApi = GRD_KVBatchDelInner; GRD_DBApiInfo.KVBatchDestoryApi = GRD_KVBatchDestroyInner; + GRD_DBApiInfo.GetConfigApi = GRD_GetConfigInner; + GRD_DBApiInfo.DBRepairApi = GRD_DBRepairInner; } void GRD_DBApiInitEnhance(GRD_APIInfo &GRD_DBApiInfo) @@ -107,6 +109,8 @@ void GRD_DBApiInitEnhance(GRD_APIInfo &GRD_DBApiInfo) GRD_DBApiInfo.KVBatchPutApi = (KVBatchPut)dlsym(g_library, "GRD_KVBatchPut"); GRD_DBApiInfo.KVBatchDelApi = (KVBatchDel)dlsym(g_library, "GRD_KVBatchDel"); GRD_DBApiInfo.KVBatchDestoryApi = (KVBatchDestory)dlsym(g_library, "GRD_KVBatchDestroy"); + GRD_DBApiInfo.GetConfigApi = (GetConfig)dlsym(g_library, "GRD_GetConfig"); + GRD_DBApiInfo.DBRepairApi = (DBRepair)dlsym(g_library, "GRD_DBRepair"); #endif } diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_kv_api_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_kv_api_inner.h index 40907f58e6c..895b55dc853 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_kv_api_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_kv_api_inner.h @@ -50,5 +50,9 @@ int32_t GRD_KVBatchPutInner(GRD_DB *db, const char *collectionName, GRD_KVBatchT int32_t GRD_KVBatchDelInner(GRD_DB *db, const char *collectionName, GRD_KVBatchT *batch); int32_t GRD_KVBatchDestroyInner(GRD_KVBatchT *batch); + +GRD_DbValueT GRD_GetConfigInner(GRD_DB *db, GRD_ConfigTypeE type); + +int32_t GRD_DBRepairInner(const char *dbFile, const char *configStr); } // namespace GRDDB #endif // GRD_KV_API_INNER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api.cpp index f3f52aa8daa..75083ede2d2 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api.cpp @@ -168,3 +168,26 @@ GRD_API int32_t GRD_KVBatchDestroy(GRD_KVBatchT *batch) } return GRD_KVApiInfo.KVBatchDestoryApi(batch); } + +GRD_API GRD_DbValueT GRD_GetConfig(GRD_DB *db, GRD_ConfigTypeE type) +{ + if (GRD_KVApiInfo.GetConfigApi == nullptr) { + GRD_KVApiInfo = GetApiInfoInstance(); + } + if (GRD_KVApiInfo.GetConfigApi == nullptr) { + GRD_DbValueT value = {.type = GRD_DB_DATATYPE_NULL, .value = {0}}; + return value; + } + return GRD_KVApiInfo.GetConfigApi(db, type); +} + +GRD_API int32_t GRD_DBRepair(const char *dbFile, const char *configStr) +{ + if (GRD_KVApiInfo.DBRepairApi == nullptr) { + GRD_KVApiInfo = GetApiInfoInstance(); + } + if (GRD_KVApiInfo.DBRepairApi == nullptr) { + return GRD_INNER_ERR; + } + return GRD_KVApiInfo.DBRepairApi(dbFile, configStr); +} \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp index 1de0f8f480a..c6351e10956 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp @@ -137,4 +137,15 @@ int32_t GRD_KVBatchDestroyInner(GRD_KVBatchT *batch) { return GRD_NOT_SUPPORT; } + +GRD_DbValueT GRD_GetConfigInner(GRD_DB *db, GRD_ConfigTypeE type) +{ + GRD_DbValueT value = {.type = GRD_DB_DATATYPE_NULL, .value = {0}}; + return value; +} + +int32_t GRD_DBRepairInner(const char *dbFile, const char *configStr) +{ + return GRD_DATA_CORRUPTED; +} } // namespace GRDDB \ No newline at end of file -- Gitee From c6cb06bee26e142bb5894b6dcbdbadbeaf360243 Mon Sep 17 00:00:00 2001 From: bluhuang Date: Wed, 13 Nov 2024 14:27:32 +0800 Subject: [PATCH 21/21] remove config api Signed-off-by: bluhuang --- .../gaussdb_rd/src/common/src/grd_api_manager.cpp | 2 -- .../gaussdb_rd/src/executor/include/grd_kv_api_inner.h | 2 -- .../gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp | 6 ------ 3 files changed, 10 deletions(-) diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp index b11dad7cb7f..f552d026dfb 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/common/src/grd_api_manager.cpp @@ -70,7 +70,6 @@ void GRD_DBApiInitCommon(GRD_APIInfo &GRD_DBApiInfo) GRD_DBApiInfo.KVBatchPutApi = GRD_KVBatchPutInner; GRD_DBApiInfo.KVBatchDelApi = GRD_KVBatchDelInner; GRD_DBApiInfo.KVBatchDestoryApi = GRD_KVBatchDestroyInner; - GRD_DBApiInfo.GetConfigApi = GRD_GetConfigInner; GRD_DBApiInfo.DBRepairApi = GRD_DBRepairInner; } @@ -109,7 +108,6 @@ void GRD_DBApiInitEnhance(GRD_APIInfo &GRD_DBApiInfo) GRD_DBApiInfo.KVBatchPutApi = (KVBatchPut)dlsym(g_library, "GRD_KVBatchPut"); GRD_DBApiInfo.KVBatchDelApi = (KVBatchDel)dlsym(g_library, "GRD_KVBatchDel"); GRD_DBApiInfo.KVBatchDestoryApi = (KVBatchDestory)dlsym(g_library, "GRD_KVBatchDestroy"); - GRD_DBApiInfo.GetConfigApi = (GetConfig)dlsym(g_library, "GRD_GetConfig"); GRD_DBApiInfo.DBRepairApi = (DBRepair)dlsym(g_library, "GRD_DBRepair"); #endif } diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_kv_api_inner.h b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_kv_api_inner.h index 895b55dc853..22cad3f4661 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_kv_api_inner.h +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/include/grd_kv_api_inner.h @@ -51,8 +51,6 @@ int32_t GRD_KVBatchDelInner(GRD_DB *db, const char *collectionName, GRD_KVBatchT int32_t GRD_KVBatchDestroyInner(GRD_KVBatchT *batch); -GRD_DbValueT GRD_GetConfigInner(GRD_DB *db, GRD_ConfigTypeE type); - int32_t GRD_DBRepairInner(const char *dbFile, const char *configStr); } // namespace GRDDB #endif // GRD_KV_API_INNER_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp index c6351e10956..d3398423bbf 100755 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/executor/kv/grd_kv_api_inner.cpp @@ -138,12 +138,6 @@ int32_t GRD_KVBatchDestroyInner(GRD_KVBatchT *batch) return GRD_NOT_SUPPORT; } -GRD_DbValueT GRD_GetConfigInner(GRD_DB *db, GRD_ConfigTypeE type) -{ - GRD_DbValueT value = {.type = GRD_DB_DATATYPE_NULL, .value = {0}}; - return value; -} - int32_t GRD_DBRepairInner(const char *dbFile, const char *configStr) { return GRD_DATA_CORRUPTED; -- Gitee