提交 6a8424b6 编写于 作者: H Hongze Cheng

more TDB

上级 ac620c0d
......@@ -49,13 +49,9 @@ int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t)
pPage->pData = ptr;
pPage->pageSize = pageSize;
if (pageSize < 65536) {
pPage->szOffset = 2;
pPage->szPageHdr = sizeof(SPageHdr);
pPage->szFreeCell = sizeof(SFreeCell);
pPage->pPageMethods = &pageMethods;
} else {
pPage->szOffset = 3;
pPage->szPageHdr = sizeof(SPageHdrL);
pPage->szFreeCell = sizeof(SFreeCellL);
pPage->pPageMethods = &pageLargeMethods;
}
TDB_INIT_PAGE_LOCK(pPage);
......@@ -249,6 +245,9 @@ static inline void setPageCellOffset(SPage *pPage, int idx, int offset) {
}
SPageMethods pageMethods = {
2, // szOffset
sizeof(SPageHdr), // szPageHdr
sizeof(SFreeCell), // szFreeCell
getPageFlags, // getPageFlags
setPageFlags, // setFlagsp
getPageCellNum, // getCellNum
......
......@@ -24,6 +24,9 @@ typedef u8 SCell;
// PAGE APIS implemented
typedef struct {
int szOffset;
int szPageHdr;
int szFreeCell;
// flags
u16 (*getFlags)(SPage *);
void (*setFlags)(SPage *, u16);
......@@ -56,9 +59,7 @@ struct SPage {
pthread_spinlock_t lock;
u8 *pData;
int pageSize;
u8 szOffset;
u8 szPageHdr;
u8 szFreeCell;
SPageMethods *pPageMethods;
// Fields below used by pager and am
u8 szAmHdr;
u8 *pPageHdr;
......@@ -75,7 +76,6 @@ struct SPage {
int nOverflow;
SCell *apOvfl[4];
int aiOvfl[4];
SPageMethods *pPageMethods;
// Fields used by SPCache
TDB_PCACHE_PAGE
};
......
......@@ -67,6 +67,9 @@ static inline void setPageCellOffset(SPage *pPage, int idx, int offset) {
}
SPageMethods pageLargeMethods = {
3, // szOffset
sizeof(SPageHdrL), // szPageHdr
sizeof(SFreeCellL), // szFreeCell
getPageFlags, // getPageFlags
setPageFlags, // setFlagsp
getPageCellNum, // getCellNum
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册