refact
This commit is contained in:
parent
f1619fee85
commit
e91147f8cf
|
@ -268,13 +268,4 @@ static int tdbDefaultKeyCmprFn(const void *pKey1, int keyLen1, const void *pKey2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cret;
|
return cret;
|
||||||
}
|
|
||||||
|
|
||||||
static void tdbBtreeZeroPage(SMemPage *pPage, int flags) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
static int tdbBtreeInitPage(SMemPage *pPage) {
|
|
||||||
// TODO
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
|
@ -48,7 +48,7 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv)
|
||||||
|
|
||||||
pEnv->jfd = -1;
|
pEnv->jfd = -1;
|
||||||
|
|
||||||
ret = tdbPCacheOpen(pageSize, cacheSize, sizeof(SMemPage), &(pEnv->pCache));
|
ret = tdbPCacheOpen(pageSize, cacheSize, 0, &(pEnv->pCache));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,7 +236,6 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
|
||||||
|
|
||||||
pPage = (SPage *)(&(pPtr[pCache->pageSize]));
|
pPage = (SPage *)(&(pPtr[pCache->pageSize]));
|
||||||
pPage->pData = (void *)pPtr;
|
pPage->pData = (void *)pPtr;
|
||||||
pPage->pExtra = (void *)(&(pPage[1]));
|
|
||||||
// pPage->pgid = 0;
|
// pPage->pgid = 0;
|
||||||
pPage->isAnchor = 0;
|
pPage->isAnchor = 0;
|
||||||
pPage->isLocalPage = 1;
|
pPage->isLocalPage = 1;
|
||||||
|
|
|
@ -114,7 +114,8 @@ int tdbPagerOpenDB(SPager *pPager, SPgno *ppgno, bool toCreate) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// tdbpPagerZeroPage(pPage);
|
// TODO: Need to zero the page
|
||||||
|
|
||||||
ret = tdbPagerWrite(pPager, pPage);
|
ret = tdbPagerWrite(pPager, pPage);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -128,12 +128,13 @@ typedef int (*FKeyComparator)(const void *pKey1, int kLen1, const void *pKey2, i
|
||||||
|
|
||||||
#define BTREE_MAX_DEPTH 20
|
#define BTREE_MAX_DEPTH 20
|
||||||
|
|
||||||
|
typedef struct SPager SPager;
|
||||||
|
typedef struct SPCache SPCache;
|
||||||
|
|
||||||
#include "tdbUtil.h"
|
#include "tdbUtil.h"
|
||||||
|
|
||||||
#include "tdbPage.h"
|
#include "tdbPage.h"
|
||||||
|
|
||||||
typedef struct SPager SPager;
|
|
||||||
|
|
||||||
#include "tdbPCache.h"
|
#include "tdbPCache.h"
|
||||||
|
|
||||||
#include "tdbPager.h"
|
#include "tdbPager.h"
|
||||||
|
|
|
@ -20,26 +20,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct SPCache SPCache;
|
|
||||||
typedef struct SPage SPage;
|
|
||||||
|
|
||||||
struct SPage {
|
|
||||||
void * pData;
|
|
||||||
void * pExtra;
|
|
||||||
SPgid pgid;
|
|
||||||
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 tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache);
|
||||||
int tdbPCacheClose(SPCache *pCache);
|
int tdbPCacheClose(SPCache *pCache);
|
||||||
SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage);
|
SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage);
|
||||||
|
|
|
@ -28,16 +28,30 @@ typedef struct __attribute__((__packed__)) {
|
||||||
u16 nFree;
|
u16 nFree;
|
||||||
} SPageHdr;
|
} SPageHdr;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct SPage SPage;
|
||||||
void * pData;
|
struct SPage {
|
||||||
|
// 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;
|
||||||
|
// Fields below used by pager and am
|
||||||
SPageHdr *pPageHdr;
|
SPageHdr *pPageHdr;
|
||||||
void * pAMHdr;
|
|
||||||
u16 * aCellIdx;
|
u16 * aCellIdx;
|
||||||
int kLen;
|
int kLen;
|
||||||
int vLen;
|
int vLen;
|
||||||
int maxLocal;
|
int maxLocal;
|
||||||
int minLocal;
|
int minLocal;
|
||||||
} SMemPage;
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue