more TDB
This commit is contained in:
parent
f6f6a69160
commit
1bcb109800
|
@ -72,7 +72,7 @@ int tdbEnvOpen(TENV *pEnv) {
|
|||
|
||||
pgSize = pEnv->pgSize;
|
||||
npage = pEnv->cacheSize / pEnv->pgSize;
|
||||
ret = pgCacheOpen(&pPgCache, pgSize, npage, pEnv);
|
||||
ret = pgCacheOpen(&pPgCache, pEnv);
|
||||
if (ret != 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ struct SPage {
|
|||
typedef TD_DLIST(SPage) SPgList;
|
||||
struct SPgCache {
|
||||
TENV * pEnv; // TENV containing this page cache
|
||||
SRWLatch mutex;
|
||||
pgsz_t pgsize;
|
||||
int32_t npage;
|
||||
SPage * pages;
|
||||
|
@ -39,29 +38,36 @@ struct SPgCache {
|
|||
} pght; // page hash table
|
||||
};
|
||||
|
||||
|
||||
static void pgCachePinPage(SPage *pPage);
|
||||
static void pgCacheUnpinPage(SPage *pPage);
|
||||
|
||||
int pgCacheOpen(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage, TENV *pEnv) {
|
||||
int pgCacheOpen(SPgCache **ppPgCache, TENV *pEnv) {
|
||||
SPgCache *pPgCache;
|
||||
SPage * pPage;
|
||||
pgsz_t pgSize;
|
||||
cachesz_t cacheSize;
|
||||
int32_t npage;
|
||||
|
||||
*ppPgCache = NULL;
|
||||
pgSize = tdbEnvGetPageSize(pEnv);
|
||||
cacheSize = tdbEnvGetCacheSize(pEnv);
|
||||
npage = cacheSize / pgSize;
|
||||
|
||||
if (!TDB_IS_PGSIZE_VLD(pgSize)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Allocate the handle
|
||||
pPgCache = (SPgCache *)calloc(1, sizeof(*pPgCache));
|
||||
if (pPgCache == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosInitRWLatch(&(pPgCache->mutex));
|
||||
pPgCache->pEnv = pEnv;
|
||||
pPgCache->pgsize = pgSize;
|
||||
pPgCache->npage = npage;
|
||||
|
||||
for (int32_t i = 0; i < npage; i++) {
|
||||
/* code */
|
||||
}
|
||||
|
||||
#if 0
|
||||
pPgCache->pages = (SPage *)calloc(npage, sizeof(SPage));
|
||||
if (pPgCache->pages == NULL) {
|
||||
pgCacheClose(pPgCache);
|
||||
|
@ -91,6 +97,7 @@ int pgCacheOpen(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage, TENV *pEnv)
|
|||
|
||||
TD_DLIST_APPEND_WITH_FIELD(&(pPgCache->freeList), pPage, freeNode);
|
||||
}
|
||||
#endif
|
||||
|
||||
*ppPgCache = pPgCache;
|
||||
return 0;
|
||||
|
|
|
@ -24,7 +24,7 @@ typedef struct SPgCache SPgCache;
|
|||
typedef struct SPage SPage;
|
||||
|
||||
// SPgCache
|
||||
int pgCacheOpen(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage, TENV *pEnv);
|
||||
int pgCacheOpen(SPgCache **ppPgCache, TENV *pEnv);
|
||||
int pgCacheClose(SPgCache *pPgCache);
|
||||
|
||||
SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid);
|
||||
|
|
Loading…
Reference in New Issue