diff --git a/source/libs/tdb/src/db/btree.c b/source/libs/tdb/src/db/btree.c index a37711e399..53f2fa6c77 100644 --- a/source/libs/tdb/src/db/btree.c +++ b/source/libs/tdb/src/db/btree.c @@ -16,11 +16,14 @@ #include "tdbInt.h" struct SBtCursor { - // TODO + SBTree *pBtree; + pgno_t pgno; + SPage * pPage; // current page traversing }; static int btreeCreate(SBTree **pBt); static int btreeDestroy(SBTree *pBt); +static int btreeCursorMoveToChild(SBtCursor *pBtCur, pgno_t pgno); int btreeOpen(SBTree **ppBt, SPgFile *pPgFile) { SBTree *pBt; @@ -48,4 +51,41 @@ static int btreeCreate(SBTree **pBt) { static int btreeDestroy(SBTree *pBt) { // TODO return 0; +} + +int btreeCursorOpen(SBtCursor *pBtCur, SBTree *pBt) { + // TODO + return 0; +} + +int btreeCursorClose(SBtCursor *pBtCur) { + // TODO + return 0; +} + +int btreeCursorMoveTo(SBtCursor *pBtCur) { + SPage *pPage; + pgno_t childPgno; + + // 1. Move the cursor to the root page + + // 2. Loop to search over the whole tree + for (;;) { + pPage = pBtCur->pPage; + + // Loop to search in current page + for (;;) { + /* code */ + } + + btreeCursorMoveToChild(pBtCur, childPgno); + } + + return 0; +} + +static int btreeCursorMoveToChild(SBtCursor *pBtCur, pgno_t pgno) { + SPgFile *pPgFile; + // TODO + return 0; } \ No newline at end of file diff --git a/source/libs/tdb/src/db/tdbUtil.c b/source/libs/tdb/src/db/tdbUtil.c index 856a54a2da..591e7eedd4 100644 --- a/source/libs/tdb/src/db/tdbUtil.c +++ b/source/libs/tdb/src/db/tdbUtil.c @@ -49,4 +49,9 @@ int tdbCheckFileAccess(const char *pathname, int mode) { } return access(pathname, flags); +} + +int64_t tdbGetFileSize(const char *fname) { + // TODO + return 0; } \ No newline at end of file diff --git a/source/libs/tdb/src/inc/tdbUtil.h b/source/libs/tdb/src/inc/tdbUtil.h index 8e1fe013e8..ccd3d0b793 100644 --- a/source/libs/tdb/src/inc/tdbUtil.h +++ b/source/libs/tdb/src/inc/tdbUtil.h @@ -29,6 +29,8 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique); #define TDB_W_OK 0x4 int tdbCheckFileAccess(const char *pathname, int mode); +int64_t tdbGetFileSize(const char *fname); + #ifdef __cplusplus } #endif