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

more TDB

上级 8f6781a7
...@@ -45,12 +45,12 @@ int tdbEnvCreate(TENV **ppEnv, const char *rootDir) { ...@@ -45,12 +45,12 @@ int tdbEnvCreate(TENV **ppEnv, const char *rootDir) {
*ppEnv = NULL; *ppEnv = NULL;
slen = strlen(rootDir); slen = strlen(rootDir);
pEnv = (TENV *)calloc(1, sizeof(*pEnv) + slen + 1); pEnv = (TENV *)calloc(1, sizeof(*pEnv) + sizeof(SJournal) + slen + 1);
if (pEnv == NULL) { if (pEnv == NULL) {
return -1; return -1;
} }
pEnv->rootDir = (char *)(&pEnv[1]); pEnv->rootDir = (char *)(&pEnv[1]) + sizeof(SJournal);
pEnv->pgSize = TDB_DEFAULT_PGSIZE; pEnv->pgSize = TDB_DEFAULT_PGSIZE;
pEnv->cacheSize = TDB_DEFAULT_CACHE_SIZE; pEnv->cacheSize = TDB_DEFAULT_CACHE_SIZE;
......
...@@ -16,11 +16,15 @@ ...@@ -16,11 +16,15 @@
#include "tdbInt.h" #include "tdbInt.h"
int tdbOpenJournal(SJournal *pJournal) { int tdbOpenJournal(SJournal *pJournal) {
// pJournal->fd = open(); TENV *pEnv;
char *jname;
pJournal->fd = open(jname, O_CREAT | O_RDWR, 0755);
if (pJournal->fd < 0) { if (pJournal->fd < 0) {
// TODO: handle error // TODO: handle error
return -1; return -1;
} }
return 0; return 0;
} }
......
...@@ -20,6 +20,8 @@ TEST(tdb_test, simple_test) { ...@@ -20,6 +20,8 @@ TEST(tdb_test, simple_test) {
GTEST_ASSERT_EQ(tdbEnvOpen(pEnv), 0); GTEST_ASSERT_EQ(tdbEnvOpen(pEnv), 0);
#if 1 #if 1
tdbEnvBeginTxn(pEnv);
// DB // DB
GTEST_ASSERT_EQ(tdbCreate(&pDb1), 0); GTEST_ASSERT_EQ(tdbCreate(&pDb1), 0);
...@@ -39,6 +41,8 @@ TEST(tdb_test, simple_test) { ...@@ -39,6 +41,8 @@ TEST(tdb_test, simple_test) {
GTEST_ASSERT_EQ(tdbOpen(pDb1, "db.db", "db1", pEnv), 0); GTEST_ASSERT_EQ(tdbOpen(pDb1, "db.db", "db1", pEnv), 0);
tdbEnvCommit(pEnv);
#if 0 #if 0
// Insert // Insert
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册