提交 815233ae 编写于 作者: H Hongze Cheng

more TDB

上级 79cdb9c2
...@@ -15,6 +15,29 @@ ...@@ -15,6 +15,29 @@
#include "tdbInt.h" #include "tdbInt.h"
struct SBTree {
SPgno root;
int keyLen;
int valLen;
SPFile *pFile;
int (*FKeyComparator)(const void *pKey1, int keyLen1, const void *pKey2, int keyLen2);
};
struct SBtCursor {
SBTree *pBt;
};
int tdbBtreeOpen(SPgno root, SBTree **ppBt) {
*ppBt = NULL;
/* TODO */
return 0;
}
int tdbBtreeClose(SBTree *pBt) {
// TODO
return 0;
}
#if 0 #if 0
struct SBtCursor { struct SBtCursor {
SBTree *pBtree; SBTree *pBtree;
......
...@@ -21,7 +21,7 @@ struct STEnv { ...@@ -21,7 +21,7 @@ struct STEnv {
SPCache *pCache; SPCache *pCache;
}; };
int tdbEnvOpen(const char *rootDir, STEnv **ppEnv) { int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv) {
STEnv * pEnv; STEnv * pEnv;
int dsize; int dsize;
int zsize; int zsize;
...@@ -43,6 +43,10 @@ int tdbEnvOpen(const char *rootDir, STEnv **ppEnv) { ...@@ -43,6 +43,10 @@ int tdbEnvOpen(const char *rootDir, STEnv **ppEnv) {
memcpy(pEnv->rootDir, rootDir, dsize); memcpy(pEnv->rootDir, rootDir, dsize);
pEnv->rootDir[dsize] = '\0'; pEnv->rootDir[dsize] = '\0';
pEnv->jfd = -1;
tdbPCacheOpen(pageSize, cacheSize, 0, &(pEnv->pCache));
*ppEnv = pEnv; *ppEnv = pEnv;
return 0; return 0;
} }
......
...@@ -89,7 +89,7 @@ SPgHdr *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage) { ...@@ -89,7 +89,7 @@ SPgHdr *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage) {
return pPage; return pPage;
} }
void tdbFetchFinish(SPCache *pCache, SPgHdr *pPage) { void tdbPCacheFetchFinish(SPCache *pCache, SPgHdr *pPage) {
// TODO // TODO
} }
......
...@@ -22,7 +22,7 @@ extern "C" { ...@@ -22,7 +22,7 @@ extern "C" {
typedef struct STEnv STEnv; typedef struct STEnv STEnv;
int tdbEnvOpen(const char *rootDir, STEnv **ppEnv); int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv);
int tdbEnvClose(STEnv *pEnv); int tdbEnvClose(STEnv *pEnv);
int tdbEnvBegin(STEnv *pEnv); int tdbEnvBegin(STEnv *pEnv);
......
...@@ -39,7 +39,7 @@ struct SPgHdr { ...@@ -39,7 +39,7 @@ struct SPgHdr {
int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache); int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache);
int tdbPCacheClose(SPCache *pCache); int tdbPCacheClose(SPCache *pCache);
SPgHdr *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage); SPgHdr *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage);
void tdbFetchFinish(SPCache *pCache, SPgHdr *pPage); void tdbPCacheFetchFinish(SPCache *pCache, SPgHdr *pPage);
void tdbPCacheRelease(SPgHdr *pHdr); void tdbPCacheRelease(SPgHdr *pHdr);
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -22,11 +22,12 @@ extern "C" { ...@@ -22,11 +22,12 @@ extern "C" {
typedef struct SPFile SPFile; typedef struct SPFile SPFile;
int tdbPFileOpen(SPCache *pCache, const char *fileName, SPFile **ppFile); int tdbPFileOpen(SPCache *pCache, const char *fileName, SPFile **ppFile);
int tdbPFileClose(SPFile *pFile); int tdbPFileClose(SPFile *pFile);
int tdbPFileBegin(SPFile *pFile); void *tdbPFileGet(SPFile *pFile, SPgno pgno);
int tdbPFileCommit(SPFile *pFile); int tdbPFileBegin(SPFile *pFile);
int tdbPFileRollback(SPFile *pFile); int tdbPFileCommit(SPFile *pFile);
int tdbPFileRollback(SPFile *pFile);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册