From ad0e3a007bba08799cf7b193db4b2f97323edf27 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 21 Mar 2022 06:45:08 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/db/tdbBtree.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index 06f96e5498..8b4bef50a5 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -392,7 +392,6 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg) { SBTree *pBt; u8 flags; u8 isLeaf; - u8 szAmHdr; pBt = ((SBtreeInitPageArg *)arg)->pBt; flags = ((SBtreeInitPageArg *)arg)->flags; @@ -400,13 +399,7 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg) { ASSERT(flags == TDB_BTREE_PAGE_GET_FLAGS(pPage)); - if (isLeaf) { - szAmHdr = sizeof(SLeafHdr); - } else { - szAmHdr = sizeof(SIntHdr); - } - - tdbPageInit(pPage, szAmHdr, tdbBtreeCellSize); + tdbPageInit(pPage, isLeaf ? sizeof(SLeafHdr) : sizeof(SIntHdr), tdbBtreeCellSize); TDB_BTREE_ASSERT_FLAG(flags); @@ -429,26 +422,26 @@ static int tdbBtreeZeroPage(SPage *pPage, void *arg) { u8 flags; SBTree *pBt; u8 isLeaf; - u8 szAmHdr; flags = ((SBtreeInitPageArg *)arg)->flags; pBt = ((SBtreeInitPageArg *)arg)->pBt; isLeaf = TDB_BTREE_PAGE_IS_LEAF(flags); - if (isLeaf) { - szAmHdr = sizeof(SLeafHdr); - } else { - szAmHdr = sizeof(SIntHdr); - } - - tdbPageZero(pPage, szAmHdr, tdbBtreeCellSize); + tdbPageZero(pPage, isLeaf ? sizeof(SLeafHdr) : sizeof(SIntHdr), tdbBtreeCellSize); if (isLeaf) { + SLeafHdr *pLeafHdr = (SLeafHdr *)(pPage->pPageHdr); + pLeafHdr->flags = flags; + pPage->kLen = pBt->keyLen; pPage->vLen = pBt->valLen; pPage->maxLocal = pBt->maxLeaf; pPage->minLocal = pBt->minLeaf; } else { + SIntHdr *pIntHdr = (SIntHdr *)(pPage->pPageHdr); + pIntHdr->flags = flags; + pIntHdr->pgno = 0; + pPage->kLen = pBt->keyLen; pPage->vLen = sizeof(SPgno); pPage->maxLocal = pBt->maxLocal; -- GitLab