more TDB
This commit is contained in:
parent
933fbaffe8
commit
3ccb52e424
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue