From c9118a52e6776db03c854afadc9d4c77f0c9fa82 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 13 Jan 2022 06:13:10 +0000 Subject: [PATCH] more tkv and refact --- source/dnode/mgmt/impl/src/dndEnv.c | 2 +- source/dnode/vnode/inc/vnode.h | 18 ---------------- source/libs/tdb/inc/tdb.h | 15 +++++++++++-- source/libs/tdb/src/inc/tdbDB.h | 11 +++------- source/libs/tdb/src/inc/tdbEnv.h | 31 --------------------------- source/libs/tdb/test/tDiskMgrTest.cpp | 10 --------- source/libs/tdb/test/tdbTest.cpp | 5 +++++ source/libs/tdb/test/tkvTests.cpp | 0 8 files changed, 22 insertions(+), 70 deletions(-) delete mode 100644 source/libs/tdb/src/inc/tdbEnv.h delete mode 100644 source/libs/tdb/test/tDiskMgrTest.cpp create mode 100644 source/libs/tdb/test/tdbTest.cpp delete mode 100644 source/libs/tdb/test/tkvTests.cpp diff --git a/source/dnode/mgmt/impl/src/dndEnv.c b/source/dnode/mgmt/impl/src/dndEnv.c index 1bf1ea2b92..23fc643abe 100644 --- a/source/dnode/mgmt/impl/src/dndEnv.c +++ b/source/dnode/mgmt/impl/src/dndEnv.c @@ -293,7 +293,7 @@ int32_t dndInit(const SDnodeEnvCfg *pCfg) { if (vnodeInit(&vnodeOpt) != 0) { dError("failed to init vnode since %s", terrstr()); dndCleanup(); - return NULL; + return -1; } memcpy(&dndEnv.cfg, pCfg, sizeof(SDnodeEnvCfg)); diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 6113d0a536..7ff02309ec 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -37,36 +37,18 @@ typedef int32_t (*PutReqToVQueryQFp)(SDnode *pDnode, struct SRpcMsg *pReq); typedef struct SVnodeCfg { int32_t vgId; SDnode *pDnode; - - /** vnode buffer pool options */ struct { - /** write buffer size */ uint64_t wsize; uint64_t ssize; uint64_t lsize; - /** use heap allocator or arena allocator */ bool isHeapAllocator; }; - - /** time to live of tables in this vnode */ uint32_t ttl; - - /** data to keep in this vnode */ uint32_t keep; - - /** if TS data is eventually consistency */ bool isWeak; - - /** TSDB config */ STsdbCfg tsdbCfg; - - /** META config */ SMetaCfg metaCfg; - - /** TQ config */ STqCfg tqCfg; - - /** WAL config */ SWalCfg walCfg; } SVnodeCfg; diff --git a/source/libs/tdb/inc/tdb.h b/source/libs/tdb/inc/tdb.h index 2f47f545b1..40d79de821 100644 --- a/source/libs/tdb/inc/tdb.h +++ b/source/libs/tdb/inc/tdb.h @@ -22,9 +22,15 @@ extern "C" { #endif +typedef enum { + TDB_BTREE = 0, + TDB_HASH, + TDB_HEAP, +} tdb_db_t; + // Forward declaration -typedef struct TDB TDB; -typedef struct TDB_ENV TDB_ENV; +typedef struct TDB TDB; +typedef struct TDB_CURSOR TDB_CURSOR; // SKey typedef struct { @@ -32,6 +38,11 @@ typedef struct { uint32_t size; } TDB_KEY, TDB_VALUE; +// TDB Operations +int tdbCreateDB(TDB** dbpp); +int tdbOpenDB(TDB* dbp, tdb_db_t type, uint32_t flags); +int tdbCloseDB(TDB* dbp, uint32_t flags); + #ifdef __cplusplus } #endif diff --git a/source/libs/tdb/src/inc/tdbDB.h b/source/libs/tdb/src/inc/tdbDB.h index 40ddb1eb31..479ef77711 100644 --- a/source/libs/tdb/src/inc/tdbDB.h +++ b/source/libs/tdb/src/inc/tdbDB.h @@ -23,19 +23,14 @@ extern "C" { #endif -typedef enum { - TDB_BTREE = 0, - TDB_HASH, - TDB_HEAP, -} tdb_db_t; struct TDB { pgsize_t pageSize; tdb_db_t type; union { - STkvBtree btree; - STkvhash hash; - } dbimpl; + TDB_BTREE btree; + TDB_HASH hash; + } dbam; // Different access methods }; #ifdef __cplusplus diff --git a/source/libs/tdb/src/inc/tdbEnv.h b/source/libs/tdb/src/inc/tdbEnv.h deleted file mode 100644 index f3e4ef5888..0000000000 --- a/source/libs/tdb/src/inc/tdbEnv.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_TDB_ENV_H_ -#define _TD_TDB_ENV_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -struct TDB_ENV { - char *homeDir; -}; - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_TDB_ENV_H_*/ \ No newline at end of file diff --git a/source/libs/tdb/test/tDiskMgrTest.cpp b/source/libs/tdb/test/tDiskMgrTest.cpp deleted file mode 100644 index a735fdb33d..0000000000 --- a/source/libs/tdb/test/tDiskMgrTest.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "gtest/gtest.h" - -#include "iostream" - -#include "tDiskMgr.h" - -TEST(tDiskMgrTest, simple_test) { - // TODO - std::cout << "This is in tDiskMgrTest::simple_test" << std::endl; -} \ No newline at end of file diff --git a/source/libs/tdb/test/tdbTest.cpp b/source/libs/tdb/test/tdbTest.cpp new file mode 100644 index 0000000000..ee91c7669b --- /dev/null +++ b/source/libs/tdb/test/tdbTest.cpp @@ -0,0 +1,5 @@ +#include "gtest/gtest.h" + +TEST(tdb_api_test, tdb_create_open_close_db_test) { + +} \ No newline at end of file diff --git a/source/libs/tdb/test/tkvTests.cpp b/source/libs/tdb/test/tkvTests.cpp deleted file mode 100644 index e69de29bb2..0000000000