more TDB
This commit is contained in:
parent
0b752392aa
commit
2d1e356cc2
|
@ -477,10 +477,10 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
|
||||||
|
|
||||||
int nOlds;
|
int nOlds;
|
||||||
SPage *pOlds[3];
|
SPage *pOlds[3];
|
||||||
|
int sIdx;
|
||||||
|
|
||||||
{ // Find 3 child pages at most to do balance
|
{ // Find 3 child pages at most to do balance
|
||||||
int nCells = TDB_PAGE_TOTAL_CELLS(pParent);
|
int nCells = TDB_PAGE_TOTAL_CELLS(pParent);
|
||||||
int sIdx;
|
|
||||||
if (nCells <= 2) {
|
if (nCells <= 2) {
|
||||||
sIdx = 0;
|
sIdx = 0;
|
||||||
nOlds = nCells + 1;
|
nOlds = nCells + 1;
|
||||||
|
@ -515,7 +515,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// drop the cells
|
// drop the cells on parent page
|
||||||
for (int i = 0; i < nOlds; i++) {
|
for (int i = 0; i < nOlds; i++) {
|
||||||
nCells = TDB_PAGE_TOTAL_CELLS(pParent);
|
nCells = TDB_PAGE_TOTAL_CELLS(pParent);
|
||||||
if (sIdx < nCells) {
|
if (sIdx < nCells) {
|
||||||
|
@ -660,7 +660,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Insert records in parent page
|
{ // Insert records in parent page
|
||||||
int cIdx;
|
int cIdx = sIdx;
|
||||||
int szCell;
|
int szCell;
|
||||||
SCell pCell[128]; // TODO
|
SCell pCell[128]; // TODO
|
||||||
SCellDecoder cd;
|
SCellDecoder cd;
|
||||||
|
@ -679,12 +679,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
|
||||||
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);
|
||||||
|
// TODO: the cell here may be used by pParent as an overflow cell
|
||||||
tdbPageInsertCell(pParent, cIdx, pCell, szCell);
|
tdbPageInsertCell(pParent, cIdx, pCell, szCell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int k = 0;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue