提交 3ccb52e4 编写于 作者: H Hongze Cheng

more TDB

上级 933fbaff
......@@ -59,6 +59,8 @@ int tdbEnvCreate(TENV **ppEnv, const char *rootDir) {
int tdbEnvOpen(TENV *pEnv) {
SPgCache *pPgCache;
pgsz_t pgSize;
int npage;
int ret;
ASSERT(pEnv != NULL);
......@@ -68,13 +70,14 @@ int tdbEnvOpen(TENV *pEnv) {
*/
mkdir(pEnv->rootDir, 0755);
ret = pgCacheOpen(&pPgCache, pEnv->pgSize, pEnv->cacheSize / pEnv->pgSize);
pgSize = pEnv->pgSize;
npage = pEnv->cacheSize / pEnv->pgSize;
ret = pgCacheOpen(&pPgCache, pgSize, npage, pEnv);
if (ret != 0) {
goto _err;
}
pEnv->pPgCache = pPgCache;
return 0;
_err:
......@@ -83,7 +86,7 @@ _err:
int tdbEnvClose(TENV *pEnv) {
if (pEnv == NULL) return 0;
/* TODO */
pgCacheClose(pEnv->pPgCache);
tdbEnvDestroy(pEnv);
return 0;
}
......
......@@ -17,7 +17,7 @@
static void pgCachePinPage(SPage *pPage);
static void pgCacheUnpinPage(SPage *pPage);
int pgCacheOpen(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage) {
int pgCacheOpen(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage, TENV *pEnv) {
SPgCache *pPgCache;
SPage * pPage;
......@@ -147,8 +147,6 @@ static void pgCacheUnpinPage(SPage *pPage) {
// TODO
}
#if 0
// Exposed handle
typedef struct TDB_MPOOL TDB_MPOOL;
......
......@@ -24,7 +24,7 @@ typedef struct SPgCache SPgCache;
typedef struct SPage SPage;
// SPgCache
int pgCacheOpen(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage);
int pgCacheOpen(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage, TENV *pEnv);
int pgCacheClose(SPgCache *pPgCache);
SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid);
......
......@@ -37,5 +37,6 @@ TEST(tdb_test, simple_test) {
tdbClose(pDb1);
tdbClose(pDb2);
#endif
tdbEnvClose(pEnv);
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册