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) {
|
int tdbEnvOpen(TENV *pEnv) {
|
||||||
SPgCache *pPgCache;
|
SPgCache *pPgCache;
|
||||||
|
pgsz_t pgSize;
|
||||||
|
int npage;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ASSERT(pEnv != NULL);
|
ASSERT(pEnv != NULL);
|
||||||
|
@ -68,13 +70,14 @@ int tdbEnvOpen(TENV *pEnv) {
|
||||||
*/
|
*/
|
||||||
mkdir(pEnv->rootDir, 0755);
|
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) {
|
if (ret != 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
pEnv->pPgCache = pPgCache;
|
pEnv->pPgCache = pPgCache;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
@ -83,7 +86,7 @@ _err:
|
||||||
|
|
||||||
int tdbEnvClose(TENV *pEnv) {
|
int tdbEnvClose(TENV *pEnv) {
|
||||||
if (pEnv == NULL) return 0;
|
if (pEnv == NULL) return 0;
|
||||||
/* TODO */
|
pgCacheClose(pEnv->pPgCache);
|
||||||
tdbEnvDestroy(pEnv);
|
tdbEnvDestroy(pEnv);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
static void pgCachePinPage(SPage *pPage);
|
static void pgCachePinPage(SPage *pPage);
|
||||||
static void pgCacheUnpinPage(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;
|
SPgCache *pPgCache;
|
||||||
SPage * pPage;
|
SPage * pPage;
|
||||||
|
|
||||||
|
@ -147,8 +147,6 @@ static void pgCacheUnpinPage(SPage *pPage) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Exposed handle
|
// Exposed handle
|
||||||
typedef struct TDB_MPOOL TDB_MPOOL;
|
typedef struct TDB_MPOOL TDB_MPOOL;
|
||||||
|
|
|
@ -24,7 +24,7 @@ typedef struct SPgCache SPgCache;
|
||||||
typedef struct SPage SPage;
|
typedef struct SPage SPage;
|
||||||
|
|
||||||
// SPgCache
|
// 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);
|
int pgCacheClose(SPgCache *pPgCache);
|
||||||
|
|
||||||
SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid);
|
SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid);
|
||||||
|
|
|
@ -37,5 +37,6 @@ TEST(tdb_test, simple_test) {
|
||||||
tdbClose(pDb1);
|
tdbClose(pDb1);
|
||||||
tdbClose(pDb2);
|
tdbClose(pDb2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tdbEnvClose(pEnv);
|
tdbEnvClose(pEnv);
|
||||||
}
|
}
|
Loading…
Reference in New Issue