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

more TDB

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