提交 b4a2bed4 编写于 作者: H Hongze Cheng

more TDB

上级 59e7f147
...@@ -25,6 +25,7 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF ...@@ -25,6 +25,7 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF
SPFile *pFile; SPFile *pFile;
int ret; int ret;
char fFullName[TDB_FILENAME_LEN]; char fFullName[TDB_FILENAME_LEN];
SPage * pPage;
*ppDb = NULL; *ppDb = NULL;
...@@ -45,6 +46,16 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF ...@@ -45,6 +46,16 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF
} }
} }
ASSERT(pFile != NULL);
// TODO: Search if the DB already in the file
if (1 /*todo: db should be created*/) {
ret = tdbPFileAllocPage(pFile, &pPage);
if (ret < 0) {
return -1;
}
}
// pDb->pBt // pDb->pBt
ret = tdbBtreeOpen(&(pDb->pBt)); ret = tdbBtreeOpen(&(pDb->pBt));
if (ret < 0) { if (ret < 0) {
......
...@@ -103,7 +103,7 @@ SPage *tdbPFileGet(SPFile *pFile, SPgno pgno) { ...@@ -103,7 +103,7 @@ SPage *tdbPFileGet(SPFile *pFile, SPgno pgno) {
ASSERT(pPage->isLoad); ASSERT(pPage->isLoad);
return pPage; return pPage;
}
int tdbPFileWrite(SPFile *pFile, SPage *pPage) { int tdbPFileWrite(SPFile *pFile, SPage *pPage) {
// TODO: if the page is not in journal, write to journal // TODO: if the page is not in journal, write to journal
...@@ -112,8 +112,18 @@ int tdbPFileWrite(SPFile *pFile, SPage *pPage) { ...@@ -112,8 +112,18 @@ int tdbPFileWrite(SPFile *pFile, SPage *pPage) {
} }
int tdbPFileAllocPage(SPFile *pFile, SPage **ppPage) { int tdbPFileAllocPage(SPFile *pFile, SPage **ppPage) {
// TODO SPage *pPage;
*ppPage = NULL; SPgno pgno;
if (1 /*TODO: no free page*/) {
pgno = ++pFile->dbFileSize;
pPage = tdbPFileGet(pFile, pgno);
ASSERT(pPage != NULL);
} else {
ASSERT(0);
}
*ppPage = pPage;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册