uint cnt; // count of keys in page
uint act; // count of active keys
uint min; // next key offset
- unsigned char bits; // page size in bits
+ unsigned char bits:7; // page size in bits
+ unsigned char free:1; // page is on free list
unsigned char lvl:7; // level of page
unsigned char dirty:1; // page is dirty
unsigned char right[BtId]; // page number to right
int nodemax; // highest page cache segment allocated
int hashmask; // number of pages in segments - 1
int hashsize; // size of hash table
- int posted; // last loadpage found posted key
int found; // last deletekey found key
int fence; // last load page used fence position
BtHash *lrufirst; // lru list head
// store chain in second right
bt_putid(bt->temp->right, bt_getid(bt->alloc[1].right));
bt_putid(bt->alloc[1].right, page_no);
+ bt->temp->free = 1;
if( bt_update(bt, bt->alloc, ALLOC_page) )
return bt->err;
uint diff, higher = bt->page->cnt, low = 1, slot;
uint good = 0;
- // if page is being deleted, send to right
-
- if( !bt->page->cnt )
- return 0;
-
- // if page is an empty fence holder
-
- if( !bt->page->act )
- return bt->page->cnt;
-
// make stopper key an infinite fence value
if( bt_getid (bt->page->right) )
// start at root of btree and drill down
- bt->posted = 1;
-
do {
// determine lock mode of drill level
mode = (lock == BtLockWrite) && (drill == lvl) ? BtLockWrite : BtLockRead;
continue;
}
+ prevpage = bt->page_no;
+ prevmode = mode;
+
// find key on page at this level
// and descend to requested level
if( slot++ < bt->page->cnt )
continue;
else
- return bt->err = BTERR_struct, 0;
+ break;
+
+ // if the page has no active slots,
+ // move right otherwise drill down
- page_no = bt_getid(slotptr(bt->page, slot)->id);
- bt->fence = slot == bt->page->cnt;
- bt->posted = 1;
- drill--;
+ if( slot <= bt->page->cnt ) {
+ page_no = bt_getid(slotptr(bt->page, slot)->id);
+ bt->fence = slot == bt->page->cnt;
+ drill--;
+ continue;
+ }
}
// or slide right into next page
- // (slide left from deleted page)
- else {
- page_no = bt_getid(bt->page->right);
- bt->posted = 0;
- }
-
- // continue down / right using overlapping locks
- // to protect pages being killed or split.
+ page_no = bt_getid(bt->page->right);
- prevpage = bt->page_no;
- prevmode = mode;
} while( page_no );
// return error on end of right chain