提交 09833d22 编写于 作者: H Hongze Cheng

more TDB

上级 7b894472
...@@ -710,28 +710,43 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) { ...@@ -710,28 +710,43 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
if (nNewCells < infoNews[iNew].cnt) { if (nNewCells < infoNews[iNew].cnt) {
tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0); tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0);
nNewCells++; nNewCells++;
} else {
if (childNotLeaf) {
// Insert to parent
// set current new page right-most child // insert parent page
((SIntHdr *)pNews[iNew]->pData)->pgno = ((SPgno *)pCell)[0]; if (!childNotLeaf && nNewCells == infoNews[iNew].cnt) {
SIntHdr *pIntHdr = (SIntHdr *)pParent->pData;
if (iNew == nNews - 1 && pIntHdr->pgno == 0) {
pIntHdr->pgno = TDB_PAGE_PGNO(pNews[iNew]);
} else {
// TODO:
((SPgno *)pCell)[0] = TDB_PAGE_PGNO(pNews[iNew]);
// TODO: pCell here may be inserted as an overflow cell, handle it
tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0);
}
// move to next new page // move to next new page
iNew++; iNew++;
nNewCells = 0; nNews = 0;
} else { }
// TODO: Insert to parent max key and current page number or the right most child } else {
ASSERT(childNotLeaf);
// move to next new page // set current new page right-most child
iNew++; ((SIntHdr *)pNews[iNew]->pData)->pgno = ((SPgno *)pCell)[0];
nNewCells = 0;
// insert to parent as divider cell
SIntHdr *pIntHdr = (SIntHdr *)pParent->pData;
// insert the cell to the new page if (iNew == nNews - 1 && pIntHdr->pgno == 0) {
ASSERT(nNewCells < infoNews[iNew].cnt); pIntHdr->pgno = TDB_PAGE_PGNO(pNews[iNew]);
tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0); } else {
nNewCells++; ((SPgno *)pCell)[0] = TDB_PAGE_PGNO(pNews[iNew]);
tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0);
} }
// move to next new page
iNew++;
nNewCells = 0;
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册