提交 59e7f147 编写于 作者: H Hongze Cheng

more TDB

上级 50a86374
......@@ -24,6 +24,7 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF
STDb * pDb;
SPFile *pFile;
int ret;
char fFullName[TDB_FILENAME_LEN];
*ppDb = NULL;
......@@ -35,6 +36,15 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF
// pDb->pEnv
pDb->pEnv = pEnv;
pFile = tdbEnvGetPFile(pEnv, fname);
if (pFile == NULL) {
snprintf(fFullName, TDB_FILENAME_LEN, "%s/%s", pEnv->rootDir, fname);
ret = tdbPFileOpen(pEnv->pCache, fFullName, &pFile);
if (ret < 0) {
return -1;
}
}
// pDb->pBt
ret = tdbBtreeOpen(&(pDb->pBt));
if (ret < 0) {
......
......@@ -15,13 +15,6 @@
#include "tdbInt.h"
struct STEnv {
char * rootDir;
char * jfname;
int jfd;
SPCache *pCache;
};
int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv) {
STEnv *pEnv;
int dsize;
......@@ -69,4 +62,9 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv)
int tdbEnvClose(STEnv *pEnv) {
// TODO
return 0;
}
SPFile *tdbEnvGetPFile(STEnv *pEnv, const char *fname) {
// TODO
return NULL;
}
\ No newline at end of file
......@@ -21,10 +21,18 @@ extern "C" {
#endif
typedef struct STEnv STEnv;
struct STEnv {
char * rootDir;
char * jfname;
int jfd;
SPCache *pCache;
};
int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv);
int tdbEnvClose(STEnv *pEnv);
SPFile *tdbEnvGetPFile(STEnv *pEnv, const char *fname);
#ifdef __cplusplus
}
#endif
......
......@@ -124,6 +124,7 @@ typedef TD_DLIST_NODE(SPgFile) SPgFileListNode;
typedef int (*FKeyComparator)(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
#define TDB_JOURNAL_NAME "tdb.journal"
#define TDB_FILENAME_LEN 128
#include "tdbUtil.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册