diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index d35d6a7abd5026c259201f8bf0d471f5da6379da..a3d8c3f53bedd9bcc2ed2099a08505ae784c030e 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -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; diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index 0f096ce6648dffa38aaf4b9dff13556f7fc70cee..96427f14304876b11c4ca7800b62e570be873e4f 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -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; } diff --git a/source/libs/tdb/src/db/tdbPCache.c b/source/libs/tdb/src/db/tdbPCache.c index 4691a46bb828485a7fee6c3f019684115f17ee05..d2b893c85aa7ac0a6287f35405be008915d7b711 100644 --- a/source/libs/tdb/src/db/tdbPCache.c +++ b/source/libs/tdb/src/db/tdbPCache.c @@ -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 } diff --git a/source/libs/tdb/src/inc/tdbEnv.h b/source/libs/tdb/src/inc/tdbEnv.h index 04f91c6487f04c917b87009627f9872e2a13aaaf..a45745b4a08efbc81c940c8099f6996c81df2ec3 100644 --- a/source/libs/tdb/src/inc/tdbEnv.h +++ b/source/libs/tdb/src/inc/tdbEnv.h @@ -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); diff --git a/source/libs/tdb/src/inc/tdbPCache.h b/source/libs/tdb/src/inc/tdbPCache.h index 4474a603a44f05ad26c160ac167ba280263786bb..b54381579988a491ab35470f082908309e92d5d4 100644 --- a/source/libs/tdb/src/inc/tdbPCache.h +++ b/source/libs/tdb/src/inc/tdbPCache.h @@ -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 diff --git a/source/libs/tdb/src/inc/tdbPFile.h b/source/libs/tdb/src/inc/tdbPFile.h index a6b4620f142a6cc040db22020590f92147162d1a..e1133b99512c3653fc282a4fe609ea26299494ef 100644 --- a/source/libs/tdb/src/inc/tdbPFile.h +++ b/source/libs/tdb/src/inc/tdbPFile.h @@ -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 }