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

refact TDB

上级 71ad7db1
......@@ -19,7 +19,7 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv)
STEnv *pEnv;
int dsize;
int zsize;
u8 * pPtr;
u8 *pPtr;
int ret;
*ppEnv = NULL;
......@@ -48,7 +48,7 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv)
pEnv->jfd = -1;
ret = tdbPCacheOpen(pageSize, cacheSize, 0, &(pEnv->pCache));
ret = tdbPCacheOpen(pageSize, cacheSize, &(pEnv->pCache));
if (ret < 0) {
return -1;
}
......
......@@ -17,7 +17,6 @@
struct SPCache {
int pageSize;
int cacheSize;
int extraSize;
pthread_mutex_t mutex;
int nFree;
SPage *pFree;
......@@ -47,7 +46,7 @@ static void tdbPCacheRemovePageFromHash(SPage *pPage);
static void tdbPCacheAddPageToHash(SPage *pPage);
static void tdbPCacheUnpinPage(SPage *pPage);
int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache) {
int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) {
SPCache *pCache;
void *pPtr;
SPage *pPgHdr;
......@@ -59,7 +58,6 @@ int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache)
pCache->pageSize = pageSize;
pCache->cacheSize = cacheSize;
pCache->extraSize = extraSize;
if (tdbPCacheOpenImpl(pCache) < 0) {
free(pCache);
......@@ -244,7 +242,7 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
pCache->nFree = 0;
pCache->pFree = NULL;
for (int i = 0; i < pCache->cacheSize; i++) {
tsize = pCache->pageSize + sizeof(SPage) + pCache->extraSize;
tsize = pCache->pageSize + sizeof(SPage);
pPtr = (u8 *)calloc(1, tsize);
if (pPtr == NULL) {
// TODO
......
......@@ -33,7 +33,7 @@ extern "C" {
SPage *pDirtyNext; \
SPager *pPager;
int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache);
int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache);
int tdbPCacheClose(SPCache *pCache);
SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage);
void tdbPCacheRelease(SPage *pPage);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册