From 34355a49e4650020921fac0f20837fca277677d1 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 7 Feb 2022 03:30:59 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/db/btree.c | 10 +++++- source/libs/tdb/src/db/pgcache.c | 53 ++++++++++++++++++++++++++++++- source/libs/tdb/src/inc/btree.h | 7 ++-- source/libs/tdb/src/inc/pgcache.h | 5 --- 4 files changed, 63 insertions(+), 12 deletions(-) diff --git a/source/libs/tdb/src/db/btree.c b/source/libs/tdb/src/db/btree.c index 2ce1e62c16..e87a25c2c3 100644 --- a/source/libs/tdb/src/db/btree.c +++ b/source/libs/tdb/src/db/btree.c @@ -13,4 +13,12 @@ * along with this program. If not, see . */ -#include "tdbInt.h" \ No newline at end of file +#include "tdbInt.h" + +struct SBTree { + // TODO +}; + +struct SBtCursor { + // TODO +}; \ No newline at end of file diff --git a/source/libs/tdb/src/db/pgcache.c b/source/libs/tdb/src/db/pgcache.c index 2ce1e62c16..25ce90e772 100644 --- a/source/libs/tdb/src/db/pgcache.c +++ b/source/libs/tdb/src/db/pgcache.c @@ -13,4 +13,55 @@ * along with this program. If not, see . */ -#include "tdbInt.h" \ No newline at end of file +#include "tdbInt.h" + +struct SPage { + pgid_t pgid; // page id + // TODO +}; + +typedef TD_DLIST(SPage) SPgList; + +struct SPgCache { + SPage *pages; + + SPgList freeList; + + struct { + int32_t nbucket; + struct { + SRWLatch latch; + TD_DLIST(SPage) ht; + } * buckets; + } pght; // page hash table +}; + +int pgCacheCreate(SPgCache **ppPgCache) { + // TODO + return 0; +} + +int pgCacheDestroy(SPgCache *pPgCache) { + // TODO + return 0; +} + +int pgCacheOpen(SPgCache *pPgCache) { + // TODO + return 0; +} + +int pgCacheClose(SPgCache *pPgCache) { + // TODO + return 0; +} + +SPage *pgCacheFetch(SPgCache *pPgCache) { + // TODO + return NULL; +} + +int pgCacheRelease(SPage *pPage) { + // TODO + return 0; +} \ No newline at end of file diff --git a/source/libs/tdb/src/inc/btree.h b/source/libs/tdb/src/inc/btree.h index 7b1b6cd2ef..757525d6a7 100644 --- a/source/libs/tdb/src/inc/btree.h +++ b/source/libs/tdb/src/inc/btree.h @@ -20,11 +20,8 @@ extern "C" { #endif -typedef struct SBTree SBTree; - -struct SBTree { - // TODO -}; +typedef struct SBTree SBTree; +typedef struct SBtCursor SBtCursor; #ifdef __cplusplus } diff --git a/source/libs/tdb/src/inc/pgcache.h b/source/libs/tdb/src/inc/pgcache.h index 0bf5d22f3f..af85e0de63 100644 --- a/source/libs/tdb/src/inc/pgcache.h +++ b/source/libs/tdb/src/inc/pgcache.h @@ -34,11 +34,6 @@ int pgCacheRelease(SPage *pPage); // SPage -// Impl -struct SPgCache { - // TODO -}; - #ifdef __cplusplus } #endif -- GitLab