more TDB
This commit is contained in:
parent
3abd4b2e67
commit
0b752392aa
|
@ -495,17 +495,17 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
|
||||||
}
|
}
|
||||||
nOlds = 3;
|
nOlds = 3;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < nOlds; i++, sIdx++) {
|
for (int i = 0; i < nOlds; i++) {
|
||||||
ASSERT(sIdx <= nCells);
|
ASSERT(sIdx + i <= nCells);
|
||||||
|
|
||||||
SPgno pgno;
|
SPgno pgno;
|
||||||
if (sIdx == nCells) {
|
if (sIdx + i == nCells) {
|
||||||
ASSERT(!TDB_BTREE_PAGE_IS_LEAF(TDB_BTREE_PAGE_GET_FLAGS(pParent)));
|
ASSERT(!TDB_BTREE_PAGE_IS_LEAF(TDB_BTREE_PAGE_GET_FLAGS(pParent)));
|
||||||
pgno = ((SIntHdr *)(pParent->pData))->pgno;
|
pgno = ((SIntHdr *)(pParent->pData))->pgno;
|
||||||
} else {
|
} else {
|
||||||
SCell *pCell;
|
SCell *pCell;
|
||||||
|
|
||||||
pCell = tdbPageGetCell(pParent, sIdx);
|
pCell = tdbPageGetCell(pParent, sIdx + i);
|
||||||
pgno = *(SPgno *)pCell;
|
pgno = *(SPgno *)pCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,6 +515,15 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// drop the cells
|
||||||
|
for (int i = 0; i < nOlds; i++) {
|
||||||
|
nCells = TDB_PAGE_TOTAL_CELLS(pParent);
|
||||||
|
if (sIdx < nCells) {
|
||||||
|
tdbPageDropCell(pParent, sIdx);
|
||||||
|
} else {
|
||||||
|
((SIntHdr *)pParent->pData)->pgno = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int nNews = 0;
|
int nNews = 0;
|
||||||
|
@ -657,6 +666,16 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
|
||||||
SCellDecoder cd;
|
SCellDecoder cd;
|
||||||
|
|
||||||
for (int iNew = 0; iNew < nNews; iNew++) {
|
for (int iNew = 0; iNew < nNews; iNew++) {
|
||||||
|
if (iNew == nNews - 1) {
|
||||||
|
// The last new page
|
||||||
|
|
||||||
|
SIntHdr *pIntHdr = (SIntHdr *)pParent->pData;
|
||||||
|
if (pIntHdr->pgno == 0) {
|
||||||
|
pIntHdr->pgno = TDB_PAGE_PGNO(pNews[iNew]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tdbBtreeDecodeCell(pNews[iNew], tdbPageGetCell(pNews[iNew], TDB_PAGE_TOTAL_CELLS(pNews[iNew]) - 1), &cd);
|
tdbBtreeDecodeCell(pNews[iNew], tdbPageGetCell(pNews[iNew], TDB_PAGE_TOTAL_CELLS(pNews[iNew]) - 1), &cd);
|
||||||
|
|
||||||
tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&TDB_PAGE_PGNO(pNews[iNew]), sizeof(SPgno), pCell, &szCell);
|
tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&TDB_PAGE_PGNO(pNews[iNew]), sizeof(SPgno), pCell, &szCell);
|
||||||
|
@ -664,6 +683,8 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int k = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue