提交 081677b2 编写于 作者: H Hongze Cheng

refact

上级 e91147f8
...@@ -49,11 +49,16 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF ...@@ -49,11 +49,16 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF
ASSERT(pPager != NULL); ASSERT(pPager != NULL);
// Try to open the database
ret = tdbPagerOpenDB(pPager, &pgno, true); ret = tdbPagerOpenDB(pPager, &pgno, true);
if (ret < 0) { if (ret < 0) {
return -1; return -1;
} }
if (pgno == 0) {
// TODO: Try to create a new database
}
// pDb->pBt // pDb->pBt
ret = tdbBtreeOpen(pgno, keyLen, valLen, pPager, keyCmprFn, &(pDb->pBt)); ret = tdbBtreeOpen(pgno, keyLen, valLen, pPager, keyCmprFn, &(pDb->pBt));
if (ret < 0) { if (ret < 0) {
......
...@@ -243,3 +243,18 @@ static int tdbPagerReadPage(SPager *pPager, SPage *pPage) { ...@@ -243,3 +243,18 @@ static int tdbPagerReadPage(SPager *pPager, SPage *pPage) {
} }
int tdbPagerGetPageSize(SPager *pPager) { return pPager->pageSize; } int tdbPagerGetPageSize(SPager *pPager) { return pPager->pageSize; }
static void tdbPagerZeroPage(SPage *pPage, int flags) {
SPager *pPager;
pPager = pPage->pPager;
memset(pPage->pData, 0, pPager->pageSize);
pPage->pPageHdr = (SPageHdr *)(pPage->pData);
pPage->aCellIdx = (u16 *)(&(pPage->pPageHdr[1]));
/* TODO */
}
static int tdbPagerInitPage(SPage *pPage) {
// TODO
return 0;
}
\ No newline at end of file
...@@ -20,14 +20,14 @@ ...@@ -20,14 +20,14 @@
extern "C" { extern "C" {
#endif #endif
int tdbPagerOpen(SPCache *pCache, const char *fileName, SPager **ppFile); int tdbPagerOpen(SPCache *pCache, const char *fileName, SPager **ppPager);
int tdbPagerClose(SPager *pFile); int tdbPagerClose(SPager *pPager);
int tdbPagerOpenDB(SPager *pFile, SPgno *ppgno, bool toCreate); int tdbPagerOpenDB(SPager *pPager, SPgno *ppgno, bool toCreate);
SPage *tdbPagerGet(SPager *pPager, SPgno pgno, bool toLoad); SPage *tdbPagerGet(SPager *pPager, SPgno pgno, bool toLoad);
int tdbPagerWrite(SPager *pFile, SPage *pPage); int tdbPagerWrite(SPager *pPager, SPage *pPage);
int tdbPagerAllocPage(SPager *pFile, SPage **ppPage, SPgno *ppgno); int tdbPagerAllocPage(SPager *pPager, SPage **ppPage, SPgno *ppgno);
int tdbPagerBegin(SPager *pFile); int tdbPagerBegin(SPager *pPager);
int tdbPagerCommit(SPager *pFile); int tdbPagerCommit(SPager *pPager);
int tdbPagerGetPageSize(SPager *pPager); int tdbPagerGetPageSize(SPager *pPager);
#ifdef __cplusplus #ifdef __cplusplus
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册