diff --git a/source/libs/CMakeLists.txt b/source/libs/CMakeLists.txt index 1dc16c74f73344165bb81ce1c3586049bef1aa85..1d23f333b2477d979ed8c8c3ca28ba85bb66050f 100644 --- a/source/libs/CMakeLists.txt +++ b/source/libs/CMakeLists.txt @@ -1,6 +1,6 @@ add_subdirectory(transport) add_subdirectory(sync) -add_subdirectory(tkv) +add_subdirectory(tdb) add_subdirectory(index) add_subdirectory(wal) add_subdirectory(parser) diff --git a/source/libs/tkv/CMakeLists.txt b/source/libs/tdb/CMakeLists.txt similarity index 78% rename from source/libs/tkv/CMakeLists.txt rename to source/libs/tdb/CMakeLists.txt index fec3f37cd5ff4331397154725e7399b4f7b1fc45..1832ea0b5d289a8dea465c6ae3c2e6ffe7356071 100644 --- a/source/libs/tkv/CMakeLists.txt +++ b/source/libs/tdb/CMakeLists.txt @@ -1,17 +1,17 @@ -aux_source_directory(src TKV_SRC) -add_library(tkv STATIC ${TKV_SRC}) +aux_source_directory(src TDB_SRC) +add_library(tdb STATIC ${TDB_SRC}) # target_include_directories( # tkv # PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/tkv" # PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" # ) target_include_directories( - tkv + tdb PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/inc" ) target_link_libraries( - tkv + tdb PUBLIC os PUBLIC util ) \ No newline at end of file diff --git a/source/libs/tkv/inc/tkv.h b/source/libs/tdb/inc/tdb.h similarity index 91% rename from source/libs/tkv/inc/tkv.h rename to source/libs/tdb/inc/tdb.h index 00534d282795a218bb6be7842ed5fba767008205..2f47f545b1dd24df4b5a4990e858ff2b27283a4c 100644 --- a/source/libs/tkv/inc/tkv.h +++ b/source/libs/tdb/inc/tdb.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_TKV_H_ -#define _TD_TKV_H_ +#ifndef _TD_TDB_H_ +#define _TD_TDB_H_ #include "os.h" @@ -28,7 +28,7 @@ typedef struct TDB_ENV TDB_ENV; // SKey typedef struct { - void * bdata; + void* bdata; uint32_t size; } TDB_KEY, TDB_VALUE; @@ -36,4 +36,4 @@ typedef struct { } #endif -#endif /*_TD_TKV_H_*/ \ No newline at end of file +#endif /*_TD_TDB_H_*/ \ No newline at end of file diff --git a/source/libs/tkv/src/inc/tkvBtree.h b/source/libs/tdb/src/inc/tdbBtree.h similarity index 89% rename from source/libs/tkv/src/inc/tkvBtree.h rename to source/libs/tdb/src/inc/tdbBtree.h index 6360e62c79fda0a2ce2af0163d4fc0c45fbf296a..c68f94bb4870fd3323d9859f22f9c5de90a333c2 100644 --- a/source/libs/tkv/src/inc/tkvBtree.h +++ b/source/libs/tdb/src/inc/tdbBtree.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_TKV_BTREE_H_ -#define _TD_TKV_BTREE_H_ +#ifndef _TD_TDB_BTREE_H_ +#define _TD_TDB_BTREE_H_ #include "tkvDef.h" @@ -24,10 +24,10 @@ extern "C" { typedef struct { pgid_t root; // root page number -} STkvBtree; +} TDB_BTREE; #ifdef __cplusplus } #endif -#endif /*_TD_TKV_BTREE_H_*/ \ No newline at end of file +#endif /*_TD_TDB_BTREE_H_*/ \ No newline at end of file diff --git a/source/libs/tkv/src/inc/tkvBufPool.h b/source/libs/tdb/src/inc/tdbBufPool.h similarity index 82% rename from source/libs/tkv/src/inc/tkvBufPool.h rename to source/libs/tdb/src/inc/tdbBufPool.h index ec8d177a9ae3d38b6a59997a299cf967816a6ca5..7fda5bf2e6ec561c33e56caaf65f428872353e45 100644 --- a/source/libs/tkv/src/inc/tkvBufPool.h +++ b/source/libs/tdb/src/inc/tdbBufPool.h @@ -13,10 +13,10 @@ * along with this program. If not, see . */ -#ifndef _TD_TKV_BUF_POOL_H_ -#define _TD_TKV_BUF_POOL_H_ +#ifndef _TD_TDB_BUF_POOL_H_ +#define _TD_TDB_BUF_POOL_H_ -#include "tkvPage.h" +#include "tdbPage.h" #ifdef __cplusplus extern "C" { @@ -26,9 +26,9 @@ typedef struct STkvBufPool STkvBufPool; int tbpOpen(STkvBufPool **ppTkvBufPool); int tbpClose(STkvBufPool *pTkvBufPool); -STkvPage *tbpNewPage(STkvBufPool *pTkvBufPool); +STdbPage *tbpNewPage(STkvBufPool *pTkvBufPool); int tbpDelPage(STkvBufPool *pTkvBufPool); -STkvPage *tbpFetchPage(STkvBufPool *pTkvBufPool, pgid_t pgid); +STdbPage *tbpFetchPage(STkvBufPool *pTkvBufPool, pgid_t pgid); int tbpUnpinPage(STkvBufPool *pTkvBufPool, pgid_t pgid); void tbpFlushPages(STkvBufPool *pTkvBufPool); @@ -36,4 +36,4 @@ void tbpFlushPages(STkvBufPool *pTkvBufPool); } #endif -#endif /*_TD_TKV_BUF_POOL_H_*/ \ No newline at end of file +#endif /*_TD_TDB_BUF_POOL_H_*/ \ No newline at end of file diff --git a/source/libs/tkv/src/inc/tkvDB.h b/source/libs/tdb/src/inc/tdbDB.h similarity index 88% rename from source/libs/tkv/src/inc/tkvDB.h rename to source/libs/tdb/src/inc/tdbDB.h index 6fe9dabf05e2f668992d64f1512ab6938ba60c70..40ddb1eb31eb47eed1b7a3368821d2ca92542a79 100644 --- a/source/libs/tkv/src/inc/tkvDB.h +++ b/source/libs/tdb/src/inc/tdbDB.h @@ -13,11 +13,11 @@ * along with this program. If not, see . */ -#ifndef _TD_TKV_DB_H_ -#define _TD_TKV_DB_H_ +#ifndef _TD_TDB_DB_H_ +#define _TD_TDB_DB_H_ -#include "tkvBtree.h" -#include "tkvHash.h" +#include "tdbBtree.h" +#include "tdbHash.h" #ifdef __cplusplus extern "C" { @@ -42,4 +42,4 @@ struct TDB { } #endif -#endif /*_TD_TKV_DB_H_*/ \ No newline at end of file +#endif /*_TD_TDB_DB_H_*/ \ No newline at end of file diff --git a/source/libs/tkv/src/inc/tkvDef.h b/source/libs/tdb/src/inc/tdbDef.h similarity index 93% rename from source/libs/tkv/src/inc/tkvDef.h rename to source/libs/tdb/src/inc/tdbDef.h index cd418019be66a917de6417f86dcf2e0d976cc7c1..a04b8cc402d9023628411ac2b619ae66ab7c31f7 100644 --- a/source/libs/tkv/src/inc/tkvDef.h +++ b/source/libs/tdb/src/inc/tdbDef.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_TKV_DEF_H_ -#define _TD_TKV_DEF_H_ +#ifndef _TD_TDB_DEF_H_ +#define _TD_TDB_DEF_H_ #include "os.h" @@ -39,4 +39,4 @@ typedef int32_t pgsize_t; } #endif -#endif /*_TD_TKV_DEF_H_*/ \ No newline at end of file +#endif /*_TD_TDB_DEF_H_*/ \ No newline at end of file diff --git a/source/libs/tkv/src/inc/tkvDiskMgr.h b/source/libs/tdb/src/inc/tdbDiskMgr.h similarity index 96% rename from source/libs/tkv/src/inc/tkvDiskMgr.h rename to source/libs/tdb/src/inc/tdbDiskMgr.h index 2ebe98ace2414adcb3133344f38d4b98137b7c22..b83a1474371a6cbd3f0463ae5a2f160ae499eac5 100644 --- a/source/libs/tkv/src/inc/tkvDiskMgr.h +++ b/source/libs/tdb/src/inc/tdbDiskMgr.h @@ -22,7 +22,7 @@ extern "C" { #include "os.h" -#include "tkvDef.h" +#include "tdbDef.h" typedef struct STkvDiskMgr STkvDiskMgr; diff --git a/source/libs/tkv/src/inc/tkvEnv.h b/source/libs/tdb/src/inc/tdbEnv.h similarity index 91% rename from source/libs/tkv/src/inc/tkvEnv.h rename to source/libs/tdb/src/inc/tdbEnv.h index eba442e5a54f331796fabdd850bb538cc2ee2731..f3e4ef5888cd9926d5b052c4f5ecf62e950afa88 100644 --- a/source/libs/tkv/src/inc/tkvEnv.h +++ b/source/libs/tdb/src/inc/tdbEnv.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_TKV_ENV_H_ -#define _TD_TKV_ENV_H_ +#ifndef _TD_TDB_ENV_H_ +#define _TD_TDB_ENV_H_ #ifdef __cplusplus extern "C" { @@ -28,4 +28,4 @@ struct TDB_ENV { } #endif -#endif /*_TD_TKV_ENV_H_*/ \ No newline at end of file +#endif /*_TD_TDB_ENV_H_*/ \ No newline at end of file diff --git a/source/libs/tkv/src/inc/tkvHash.h b/source/libs/tdb/src/inc/tdbHash.h similarity index 90% rename from source/libs/tkv/src/inc/tkvHash.h rename to source/libs/tdb/src/inc/tdbHash.h index 06343b7ac9da32339fd9c34cbd54231914a099dd..fca19035f1d6fd40f8ece7cdb488a8dbb919bed2 100644 --- a/source/libs/tkv/src/inc/tkvHash.h +++ b/source/libs/tdb/src/inc/tdbHash.h @@ -16,15 +16,15 @@ #ifndef _TD_TKV_HAHS_H_ #define _TD_TKV_HAHS_H_ -#include "tkvDef.h" +#include "tdbDef.h" #ifdef __cplusplus extern "C" { #endif -typedef struct STkvHash { +typedef struct { // TODO -} STkvHash; +} TDB_HASH; #ifdef __cplusplus } diff --git a/source/libs/tkv/src/inc/tkvPage.h b/source/libs/tdb/src/inc/tdbPage.h similarity index 75% rename from source/libs/tkv/src/inc/tkvPage.h rename to source/libs/tdb/src/inc/tdbPage.h index d596d215cda51d00bdfc24258190e9a55a7181f5..e7245b6c393be112a0b5ab9c64085aff5ae42615 100644 --- a/source/libs/tkv/src/inc/tkvPage.h +++ b/source/libs/tdb/src/inc/tdbPage.h @@ -17,30 +17,24 @@ #define _TD_TKV_PAGE_H_ #include "os.h" -#include "tkvDef.h" +#include "tdbDef.h" #ifdef __cplusplus extern "C" { #endif -typedef struct STkvPage { +typedef struct { pgid_t pgid; int32_t pinCount; bool idDirty; char* pData; -} STkvPage; +} STdbPage; typedef struct { uint16_t dbver; uint16_t pgsize; uint32_t cksm; -} STkvPgHdr; - -// typedef struct { -// SPgHdr chdr; -// uint16_t used; // number of used slots -// uint16_t loffset; // the offset of the starting location of the last slot used -// } SSlottedPgHdr; +} STdbPgHdr; #ifdef __cplusplus } diff --git a/source/libs/tkv/src/tkvBufPool.c b/source/libs/tdb/src/tdbBufPool.c similarity index 97% rename from source/libs/tkv/src/tkvBufPool.c rename to source/libs/tdb/src/tdbBufPool.c index 86bfa0ba3e9e0faeaba3ee4e3bf0d123a3bfa470..6ae3499064c380fb971a3690d7d853f02db0bc2e 100644 --- a/source/libs/tkv/src/tkvBufPool.c +++ b/source/libs/tdb/src/tdbBufPool.c @@ -26,7 +26,7 @@ struct SFrameIdWrapper { }; struct STkvBufPool { - STkvPage* pages; + STdbPage* pages; STkvDiskMgr* pDiskMgr; SHashObj* pgTb; // page_id_t --> frame_id_t TD_SLIST(SFrameIdWrapper) freeList; diff --git a/source/libs/tkv/src/tDiskMgr.c b/source/libs/tdb/src/tdbDiskMgr.c similarity index 98% rename from source/libs/tkv/src/tDiskMgr.c rename to source/libs/tdb/src/tdbDiskMgr.c index fa8f6062d817cbe90f7fca0d398e178277fae24c..71ab5f2589d7c56bbfe3e0a493f10fa54d085463 100644 --- a/source/libs/tkv/src/tDiskMgr.c +++ b/source/libs/tdb/src/tdbDiskMgr.c @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "tkvDiskMgr.h" +#include "tdbDiskMgr.h" struct STkvDiskMgr { char * fname; diff --git a/source/libs/tkv/test/tDiskMgrTest.cpp b/source/libs/tdb/test/tDiskMgrTest.cpp similarity index 100% rename from source/libs/tkv/test/tDiskMgrTest.cpp rename to source/libs/tdb/test/tDiskMgrTest.cpp diff --git a/source/libs/tkv/test/tkvTests.cpp b/source/libs/tdb/test/tkvTests.cpp similarity index 100% rename from source/libs/tkv/test/tkvTests.cpp rename to source/libs/tdb/test/tkvTests.cpp