From 5ed7b9a2d5b177ffb7b2a479875c5a0657f5c6bc Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 14 Mar 2022 07:04:21 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/db/tdbBtree.c | 6 +++--- source/libs/tdb/src/inc/tdbPage.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index 4f96a08ad9..b0c29c77cb 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -183,7 +183,7 @@ static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen) { // ridx = pBtPage->pHdr->nCells - 1; // while (lidx <= ridx) { // midx = (lidx + ridx) >> 1; - // pCell = (void *)(pBtPage->aData + pBtPage->aCellIdx[midx]); + // pCell = (void *)(pBtPage->aData + pBtPage->pCellIdx[midx]); // c = tdbCompareKeyAndCell(pKey, kLen, pCell); // if (c == 0) { @@ -352,7 +352,7 @@ static int tdbBtreeZeroPage(SPage *pPage, void *arg) { pBt = ((SBtreeZeroPageArg *)arg)->pBt; pPage->pPageHdr = pPage->pData; - pPage->aCellIdx = (u8 *)(&(pPage->pPageHdr[1])); + pPage->pCellIdx = (u8 *)(&(pPage->pPageHdr[1])); // Init the page header TDB_PAGE_FLAGS_SET(pPage, flags); @@ -386,7 +386,7 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg) { flags = TDB_PAGE_FLAGS(pPage); pPage->pPageHdr = pPage->pData; - pPage->aCellIdx = pPage->pPageHdr + pPage->szPageHdr; + pPage->pCellIdx = pPage->pPageHdr + pPage->szPageHdr; TDB_BTREE_ASSERT_FLAG(flags); diff --git a/source/libs/tdb/src/inc/tdbPage.h b/source/libs/tdb/src/inc/tdbPage.h index c40ead624f..534ea723f7 100644 --- a/source/libs/tdb/src/inc/tdbPage.h +++ b/source/libs/tdb/src/inc/tdbPage.h @@ -54,8 +54,8 @@ struct SPage { pthread_spinlock_t lock; // Fields below used by pager and am u8 *pPageHdr; - u8 *aCellIdx; u8 *pAmHdr; + u8 *pCellIdx; u8 *pFreeStart; u8 *pFreeEnd; SPageFtr *pPageFtr; @@ -80,7 +80,7 @@ struct SPage { #define TDB_SPAGE_CCELLS(pPage) (((SPageHdr *)(pPage)->pPageHdr)->cCells) #define TDB_SPAGE_FCELL(pPage) (((SPageHdr *)(pPage)->pPageHdr)->fCell) #define TDB_SPAGE_NFREE(pPage) (((SPageHdr *)(pPage)->pPageHdr)->nFree) -#define TDB_SPAGE_CELL_OFFSET_AT(pPage, idx) ((u16 *)((pPage)->aCellIdx))[idx] +#define TDB_SPAGE_CELL_OFFSET_AT(pPage, idx) ((u16 *)((pPage)->pCellIdx))[idx] #define TDB_SPAGE_FLAGS_SET(pPage, FLAGS) TDB_SPAGE_FLAGS(pPage) = (FLAGS) #define TDB_SPAGE_NCELLS_SET(pPage, NCELLS) TDB_SPAGE_NCELLS(pPage) = (NCELLS) @@ -95,14 +95,14 @@ struct SPage { #define TDB_LPAGE_CCELLS(pPage) TDB_GET_U24(((SPageHdrL *)(pPage)->pPageHdr)->cCells) #define TDB_LPAGE_FCELL(pPage) TDB_GET_U24(((SPageHdrL *)(pPage)->pPageHdr)->fCell) #define TDB_LPAGE_NFREE(pPage) TDB_GET_U24(((SPageHdrL *)(pPage)->pPageHdr)->nFree) -#define TDB_LPAGE_CELL_OFFSET_AT(pPage, idx) TDB_GET_U24((pPage)->aCellIdx + idx * 3) +#define TDB_LPAGE_CELL_OFFSET_AT(pPage, idx) TDB_GET_U24((pPage)->pCellIdx + idx * 3) #define TDB_LPAGE_FLAGS_SET(pPage, FLAGS) TDB_LPAGE_FLAGS(pPage) = (flags) #define TDB_LPAGE_NCELLS_SET(pPage, NCELLS) TDB_PUT_U24(((SPageHdrL *)(pPage)->pPageHdr)->nCells, NCELLS) #define TDB_LPAGE_CCELLS_SET(pPage, CCELLS) TDB_PUT_U24(((SPageHdrL *)(pPage)->pPageHdr)->cCells, CCELLS) #define TDB_LPAGE_FCELL_SET(pPage, FCELL) TDB_PUT_U24(((SPageHdrL *)(pPage)->pPageHdr)->fCell, FCELL) #define TDB_LPAGE_NFREE_SET(pPage, NFREE) TDB_PUT_U24(((SPageHdrL *)(pPage)->pPageHdr)->nFree, NFREE) -#define TDB_LPAGE_CELL_OFFSET_AT_SET(pPage, idx, OFFSET) TDB_PUT_U24((pPage)->aCellIdx + idx * 3, OFFSET) +#define TDB_LPAGE_CELL_OFFSET_AT_SET(pPage, idx, OFFSET) TDB_PUT_U24((pPage)->pCellIdx + idx * 3, OFFSET) /* For page */ #define TDB_PAGE_FLAGS(pPage) (TDB_IS_LARGE_PAGE(pPage) ? TDB_LPAGE_FLAGS(pPage) : TDB_SPAGE_FLAGS(pPage))