more TDB
This commit is contained in:
parent
66213fe83f
commit
16e7fa2e9e
|
@ -65,6 +65,7 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg);
|
||||||
static int tdbBtreeEncodeCell(SPage *pPage, const void *pKey, int kLen, const void *pVal, int vLen, SCell *pCell,
|
static int tdbBtreeEncodeCell(SPage *pPage, const void *pKey, int kLen, const void *pVal, int vLen, SCell *pCell,
|
||||||
int *szCell);
|
int *szCell);
|
||||||
static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pDecoder);
|
static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pDecoder);
|
||||||
|
static int tdbBtreeBalance(SBtCursor *pCur);
|
||||||
|
|
||||||
int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, FKeyComparator kcmpr, SBTree **ppBt) {
|
int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, FKeyComparator kcmpr, SBTree **ppBt) {
|
||||||
SBTree *pBt;
|
SBTree *pBt;
|
||||||
|
@ -180,8 +181,6 @@ int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *p
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
// If page is overflow, balance the tree
|
// If page is overflow, balance the tree
|
||||||
if (pCur->pPage->nOverflow > 0) {
|
if (pCur->pPage->nOverflow > 0) {
|
||||||
ret = tdbBtreeBalance(pCur);
|
ret = tdbBtreeBalance(pCur);
|
||||||
|
@ -189,8 +188,6 @@ int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *p
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,10 +126,14 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell) {
|
||||||
int ret;
|
int ret;
|
||||||
SCell *pTarget;
|
SCell *pTarget;
|
||||||
u8 *pTmp;
|
u8 *pTmp;
|
||||||
|
int j;
|
||||||
|
|
||||||
if (pPage->nOverflow || szCell + pPage->szOffset > pPage->nFree) {
|
if (pPage->nOverflow || szCell + pPage->szOffset > pPage->nFree) {
|
||||||
// TODO: Page is full
|
// TODO: need to figure out if pCell may be used by outside of this function
|
||||||
ASSERT(0);
|
j = pPage->nOverflow++;
|
||||||
|
|
||||||
|
pPage->apOvfl[j] = pCell;
|
||||||
|
pPage->aiOvfl[j] = idx;
|
||||||
} else {
|
} else {
|
||||||
ret = tdbPageAllocate(pPage, szCell, &pTarget);
|
ret = tdbPageAllocate(pPage, szCell, &pTarget);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ TEST(tdb_test, simple_test) {
|
||||||
char key[64];
|
char key[64];
|
||||||
char val[64];
|
char val[64];
|
||||||
|
|
||||||
for (int i = 1; i <= 64; i++) {
|
for (int i = 1; i <= 65; i++) {
|
||||||
sprintf(key, "key%d", i);
|
sprintf(key, "key%d", i);
|
||||||
sprintf(val, "value%d", i);
|
sprintf(val, "value%d", i);
|
||||||
ret = tdbDbInsert(pDb, key, strlen(key), val, strlen(val));
|
ret = tdbDbInsert(pDb, key, strlen(key), val, strlen(val));
|
||||||
|
|
Loading…
Reference in New Issue