提交 49edc62e 编写于 作者: H Hongze Cheng

more TDB

上级 a10e0649
......@@ -26,6 +26,14 @@ typedef struct {
pgsz_t offset;
} SBtIdx;
// Btree page header definition
typedef struct {
uint8_t flags;
uint16_t ncells;
pgsz_t pldOffset; // payload offset
/* TODO */
} SBtPgHdr;
static int btreeCreate(SBTree **pBt);
static int btreeDestroy(SBTree *pBt);
static int btreeCursorMoveToChild(SBtCursor *pBtCur, pgno_t pgno);
......@@ -69,9 +77,10 @@ int btreeCursorClose(SBtCursor *pBtCur) {
}
int btreeCursorMoveTo(SBtCursor *pBtCur, int kLen, const void *pKey) {
SPage *pPage;
pgno_t childPgno;
int idx;
SPage * pPage;
SBtPgHdr *pBtPgHdr;
pgno_t childPgno;
int idx;
// 1. Move the cursor to the root page
......
......@@ -20,6 +20,18 @@
extern "C" {
#endif
typedef struct __attribute__((__packed__)) {
char hdrInfo[16]; // info string
pgsz_t szPage; // page size of current file
int32_t cno; // commit number counter
pgno_t freePgno; // freelist page number
uint8_t resv[100]; // reserved space
} SPgFileHdr;
#define TDB_PG_FILE_HDR_SIZE 128
TD_STATIC_ASSERT(sizeof(SPgFileHdr) == TDB_PG_FILE_HDR_SIZE, "Page file header size if not 128");
struct SPgFile {
char * fname; // backend file name
uint8_t fileid[TDB_FILE_ID_LEN]; // file id
......
......@@ -93,11 +93,15 @@ typedef TD_DLIST(SPgFile) SPgFileList;
} \
} while (0)
#include "tdbUtil.h"
#include "btree.h"
#include "pgcache.h"
#include "pgfile.h"
#include "tdbEnv.h"
#include "tdbUtil.h"
#ifdef __cplusplus
}
......
......@@ -20,6 +20,12 @@
extern "C" {
#endif
#if __STDC_VERSION__ >= 201112L
#define TD_STATIC_ASSERT(op, info) static_assert(op, info)
#else
#define TD_STATIC_ASSERT(op, info)
#endif
#define TDB_ROUND8(x) (((x) + 7) & ~7)
int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册