提交 a10e0649 编写于 作者: H Hongze Cheng

refact TDB

上级 d83540ae
......@@ -26,7 +26,7 @@ typedef struct STDb TDB;
typedef struct STDbEnv TENV;
typedef struct STDbCurosr TDBC;
typedef int32_t pgsize_t;
typedef int32_t pgsz_t;
typedef int32_t cachesz_t;
// TEVN
......@@ -34,9 +34,9 @@ int tdbEnvCreate(TENV **ppEnv);
int tdbEnvOpen(TENV **ppEnv);
int tdbEnvClose(TENV *pEnv);
int tdbEnvSetPageSize(TENV *pEnv, pgsize_t szPage);
int tdbEnvSetPageSize(TENV *pEnv, pgsz_t szPage);
int tdbEnvSetCacheSize(TENV *pEnv, cachesz_t szCache);
pgsize_t tdbEnvGetPageSize(TENV *pEnv);
pgsz_t tdbEnvGetPageSize(TENV *pEnv);
cachesz_t tdbEnvGetCacheSize(TENV *pEnv);
// TDB
......
......@@ -22,8 +22,8 @@ struct SBtCursor {
};
typedef struct {
pgno_t pgno;
pgsize_t offset;
pgno_t pgno;
pgsz_t offset;
} SBtIdx;
static int btreeCreate(SBTree **pBt);
......
......@@ -17,7 +17,7 @@
static void pgCachePinPage(SPage *pPage);
static void pgCacheUnpinPage(SPage *pPage);
int pgCacheCreate(SPgCache **ppPgCache, pgsize_t pgSize, int32_t npage) {
int pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage) {
SPgCache *pPgCache;
SPage * pPage;
......
......@@ -107,7 +107,7 @@ int pgFileWrite(SPage *pPage) {
}
static int pgFileRead(SPgFile *pPgFile, pgno_t pgno, uint8_t *pData) {
pgsize_t pgSize;
pgsz_t pgSize;
ssize_t rsize;
uint8_t *pTData;
size_t szToRead;
......
......@@ -16,7 +16,7 @@
#include "tdbInt.h"
struct STDbEnv {
pgsize_t pgSize; // Page size
pgsz_t pgSize; // Page size
cachesz_t cacheSize; // Total cache size
STDbList dbList; // TDB List
SPgFileList pgfList; // SPgFile List
......@@ -74,7 +74,7 @@ int tdbEnvClose(TENV *pEnv) {
return 0;
}
int tdbEnvSetPageSize(TENV *pEnv, pgsize_t szPage) {
int tdbEnvSetPageSize(TENV *pEnv, pgsz_t szPage) {
/* TODO */
pEnv->pgSize = szPage;
return 0;
......@@ -86,7 +86,7 @@ int tdbEnvSetCacheSize(TENV *pEnv, cachesz_t szCache) {
return 0;
}
pgsize_t tdbEnvGetPageSize(TENV *pEnv) { return pEnv->pgSize; }
pgsz_t tdbEnvGetPageSize(TENV *pEnv) { return pEnv->pgSize; }
cachesz_t tdbEnvGetCacheSize(TENV *pEnv) { return pEnv->cacheSize; }
......
......@@ -22,7 +22,7 @@ static int tdbMPoolFileReadPage(TDB_MPFILE *mpf, pgno_t pgno, void *p);
static int tdbMPoolFileWritePage(TDB_MPFILE *mpf, pgno_t pgno, const void *p);
static void tdbMPoolClockEvictPage(TDB_MPOOL *mp, pg_t **pagepp);
int tdbMPoolOpen(TDB_MPOOL **mpp, uint64_t cachesize, pgsize_t pgsize) {
int tdbMPoolOpen(TDB_MPOOL **mpp, uint64_t cachesize, pgsz_t pgsize) {
TDB_MPOOL *mp = NULL;
size_t tsize;
pg_t * pagep;
......@@ -300,7 +300,7 @@ static void tdbMPoolUnregFile(TDB_MPOOL *mp, TDB_MPFILE *mpf) {
}
static int tdbMPoolFileReadPage(TDB_MPFILE *mpf, pgno_t pgno, void *p) {
pgsize_t pgsize;
pgsz_t pgsize;
TDB_MPOOL *mp;
off_t offset;
size_t rsize;
......@@ -317,7 +317,7 @@ static int tdbMPoolFileReadPage(TDB_MPFILE *mpf, pgno_t pgno, void *p) {
}
static int tdbMPoolFileWritePage(TDB_MPFILE *mpf, pgno_t pgno, const void *p) {
pgsize_t pgsize;
pgsz_t pgsize;
TDB_MPOOL *mp;
off_t offset;
......
......@@ -24,7 +24,7 @@ typedef struct SPgCache SPgCache;
typedef struct SPage SPage;
// SPgCache
int pgCacheCreate(SPgCache **ppPgCache, pgsize_t pgSize, int32_t npage);
int pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage);
int pgCacheDestroy(SPgCache *pPgCache);
int pgCacheOpen(SPgCache **ppPgCache);
int pgCacheClose(SPgCache *pPgCache);
......@@ -46,9 +46,9 @@ struct SPage {
typedef TD_DLIST(SPage) SPgList;
struct SPgCache {
TENV * pEnv; // TENV containing this page cache
TENV * pEnv; // TENV containing this page cache
SRWLatch mutex;
pgsize_t pgsize;
pgsz_t pgsize;
int32_t npage;
SPage * pages;
SPgList freeList;
......
......@@ -24,7 +24,7 @@ struct SPgFile {
char * fname; // backend file name
uint8_t fileid[TDB_FILE_ID_LEN]; // file id
SPgCache *pPgCache; // page cache underline
pgsize_t pgSize;
pgsz_t pgSize;
int fd;
pgno_t pgFileSize;
};
......
......@@ -64,9 +64,9 @@ static FORCE_INLINE int tdbCmprPgId(const void *p1, const void *p2) {
// framd_id_t
typedef int32_t frame_id_t;
// pgsize_t
// pgsz_t
#define TDB_MIN_PGSIZE 512
#define TDB_MAX_PGSIZE 16384
#define TDB_MAX_PGSIZE 65536
#define TDB_DEFAULT_PGSIZE 4096
#define TDB_IS_PGSIZE_VLD(s) (((s) >= TDB_MIN_PGSIZE) && ((s) <= TDB_MAX_PGSIZE))
......
......@@ -46,7 +46,7 @@ typedef struct {
} mpf_bucket_t;
struct TDB_MPOOL {
int64_t cachesize;
pgsize_t pgsize;
pgsz_t pgsize;
int32_t npages;
pg_t * pages;
pg_list_t freeList;
......@@ -74,7 +74,7 @@ struct TDB_MPFILE {
/*=================================================== Exposed apis ==================================================*/
// TDB_MPOOL
int tdbMPoolOpen(TDB_MPOOL **mpp, uint64_t cachesize, pgsize_t pgsize);
int tdbMPoolOpen(TDB_MPOOL **mpp, uint64_t cachesize, pgsz_t pgsize);
int tdbMPoolClose(TDB_MPOOL *mp);
int tdbMPoolSync(TDB_MPOOL *mp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册