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;
|
STDb * pDb;
|
||||||
SPFile *pFile;
|
SPFile *pFile;
|
||||||
int ret;
|
int ret;
|
||||||
|
char fFullName[TDB_FILENAME_LEN];
|
||||||
|
|
||||||
*ppDb = NULL;
|
*ppDb = NULL;
|
||||||
|
|
||||||
|
@ -35,6 +36,15 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF
|
||||||
// pDb->pEnv
|
// pDb->pEnv
|
||||||
pDb->pEnv = 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
|
// pDb->pBt
|
||||||
ret = tdbBtreeOpen(&(pDb->pBt));
|
ret = tdbBtreeOpen(&(pDb->pBt));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
|
@ -15,13 +15,6 @@
|
||||||
|
|
||||||
#include "tdbInt.h"
|
#include "tdbInt.h"
|
||||||
|
|
||||||
struct STEnv {
|
|
||||||
char * rootDir;
|
|
||||||
char * jfname;
|
|
||||||
int jfd;
|
|
||||||
SPCache *pCache;
|
|
||||||
};
|
|
||||||
|
|
||||||
int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv) {
|
int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv) {
|
||||||
STEnv *pEnv;
|
STEnv *pEnv;
|
||||||
int dsize;
|
int dsize;
|
||||||
|
@ -70,3 +63,8 @@ int tdbEnvClose(STEnv *pEnv) {
|
||||||
// TODO
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPFile *tdbEnvGetPFile(STEnv *pEnv, const char *fname) {
|
||||||
|
// TODO
|
||||||
|
return NULL;
|
||||||
|
}
|
|
@ -21,10 +21,18 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct STEnv STEnv;
|
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 tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv);
|
||||||
int tdbEnvClose(STEnv *pEnv);
|
int tdbEnvClose(STEnv *pEnv);
|
||||||
|
|
||||||
|
SPFile *tdbEnvGetPFile(STEnv *pEnv, const char *fname);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -124,6 +124,7 @@ typedef TD_DLIST_NODE(SPgFile) SPgFileListNode;
|
||||||
typedef int (*FKeyComparator)(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
|
typedef int (*FKeyComparator)(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
|
||||||
|
|
||||||
#define TDB_JOURNAL_NAME "tdb.journal"
|
#define TDB_JOURNAL_NAME "tdb.journal"
|
||||||
|
#define TDB_FILENAME_LEN 128
|
||||||
|
|
||||||
#include "tdbUtil.h"
|
#include "tdbUtil.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue