more TDB
This commit is contained in:
parent
cc893cf96d
commit
933fbaffe8
|
@ -68,7 +68,7 @@ int tdbEnvOpen(TENV *pEnv) {
|
||||||
*/
|
*/
|
||||||
mkdir(pEnv->rootDir, 0755);
|
mkdir(pEnv->rootDir, 0755);
|
||||||
|
|
||||||
ret = pgCacheCreate(&pPgCache, pEnv->pgSize, pEnv->cacheSize / pEnv->pgSize);
|
ret = pgCacheOpen(&pPgCache, pEnv->pgSize, pEnv->cacheSize / pEnv->pgSize);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage) {
|
int pgCacheOpen(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage) {
|
||||||
SPgCache *pPgCache;
|
SPgCache *pPgCache;
|
||||||
SPage * pPage;
|
SPage * pPage;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ int pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage) {
|
||||||
|
|
||||||
pPgCache->pages = (SPage *)calloc(npage, sizeof(SPage));
|
pPgCache->pages = (SPage *)calloc(npage, sizeof(SPage));
|
||||||
if (pPgCache->pages == NULL) {
|
if (pPgCache->pages == NULL) {
|
||||||
pgCacheDestroy(pPgCache);
|
pgCacheClose(pPgCache);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,14 +52,14 @@ int pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage) {
|
||||||
|
|
||||||
pPage->pData = (uint8_t *)calloc(1, pgSize);
|
pPage->pData = (uint8_t *)calloc(1, pgSize);
|
||||||
if (pPage->pData == NULL) {
|
if (pPage->pData == NULL) {
|
||||||
pgCacheDestroy(pPgCache);
|
pgCacheClose(pPgCache);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pPgCache->pght.nbucket = npage;
|
pPgCache->pght.nbucket = npage;
|
||||||
pPgCache->pght.buckets = (SPgList *)calloc(pPgCache->pght.nbucket, sizeof(SPgList));
|
pPgCache->pght.buckets = (SPgList *)calloc(pPgCache->pght.nbucket, sizeof(SPgList));
|
||||||
if (pPgCache->pght.buckets == NULL) {
|
if (pPgCache->pght.buckets == NULL) {
|
||||||
pgCacheDestroy(pPgCache);
|
pgCacheClose(pPgCache);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ int pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pgCacheDestroy(SPgCache *pPgCache) {
|
int pgCacheClose(SPgCache *pPgCache) {
|
||||||
SPage *pPage;
|
SPage *pPage;
|
||||||
if (pPgCache) {
|
if (pPgCache) {
|
||||||
tfree(pPgCache->pght.buckets);
|
tfree(pPgCache->pght.buckets);
|
||||||
|
|
|
@ -24,8 +24,8 @@ typedef struct SPgCache SPgCache;
|
||||||
typedef struct SPage SPage;
|
typedef struct SPage SPage;
|
||||||
|
|
||||||
// SPgCache
|
// SPgCache
|
||||||
int pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage);
|
int pgCacheOpen(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage);
|
||||||
int pgCacheDestroy(SPgCache *pPgCache);
|
int pgCacheClose(SPgCache *pPgCache);
|
||||||
|
|
||||||
SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid);
|
SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid);
|
||||||
int pgCacheRelease(SPage *pPage);
|
int pgCacheRelease(SPage *pPage);
|
||||||
|
|
Loading…
Reference in New Issue