more TDB
This commit is contained in:
parent
50a8637464
commit
59e7f147c3
|
@ -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;
|
||||
}
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Reference in New Issue