From 737497d8b664c9dbddb0acc9b9b10896f7f75785 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 9 Mar 2022 07:48:45 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/inc/tdbInt.h | 5 +++-- source/libs/tdb/src/inc/tdbPCache.h | 13 ++++++++++++- source/libs/tdb/src/inc/tdbPage.h | 21 ++++++--------------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h index 28d7a4e54c..598b23f339 100644 --- a/source/libs/tdb/src/inc/tdbInt.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -136,11 +136,10 @@ typedef int (*FKeyComparator)(const void *pKey1, int kLen1, const void *pKey2, i typedef struct SPager SPager; typedef struct SPCache SPCache; +typedef struct SPage SPage; #include "tdbUtil.h" -#include "tdbPage.h" - #include "tdbPCache.h" #include "tdbPager.h" @@ -151,6 +150,8 @@ typedef struct SPCache SPCache; #include "tdbDb.h" +#include "tdbPage.h" + #ifdef __cplusplus } #endif diff --git a/source/libs/tdb/src/inc/tdbPCache.h b/source/libs/tdb/src/inc/tdbPCache.h index b5a6d1171d..85b795a30e 100644 --- a/source/libs/tdb/src/inc/tdbPCache.h +++ b/source/libs/tdb/src/inc/tdbPCache.h @@ -20,7 +20,18 @@ extern "C" { #endif -#define TDB_PCACHE_PAGE +#define TDB_PCACHE_PAGE \ + u8 isAnchor; \ + u8 isLocalPage; \ + u8 isDirty; \ + i32 nRef; \ + SPCache *pCache; \ + SPage *pFreeNext; \ + SPage *pHashNext; \ + SPage *pLruNext; \ + SPage *pLruPrev; \ + SPage *pDirtyNext; \ + SPager *pPager; int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache); int tdbPCacheClose(SPCache *pCache); diff --git a/source/libs/tdb/src/inc/tdbPage.h b/source/libs/tdb/src/inc/tdbPage.h index 2bb8866278..e85660ab33 100644 --- a/source/libs/tdb/src/inc/tdbPage.h +++ b/source/libs/tdb/src/inc/tdbPage.h @@ -29,23 +29,14 @@ typedef struct __attribute__((__packed__)) { SPgno rChild; } SPageHdr; -typedef struct SPage SPage; struct SPage { pthread_spinlock_t lock; - // Fields below used by page cache - void *pData; - SPgid pgid; - u8 isAnchor; - u8 isLocalPage; - u8 isDirty; - i32 nRef; - SPCache *pCache; - SPage *pFreeNext; - SPage *pHashNext; - SPage *pLruNext; - SPage *pLruPrev; - SPage *pDirtyNext; - SPager *pPager; + void *pData; + SPgid pgid; + + // Fields used by SPCache + TDB_PCACHE_PAGE + // Fields below used by pager and am SPageHdr *pPageHdr; u16 *aCellIdx;