/** Display all the keys in the page. */
static void
-mdb_page_keys(MDB_page *mp)
+mdb_page_list(MDB_page *mp)
{
MDB_node *node;
- unsigned int i, nkeys;
+ unsigned int i, nkeys, nsize;
MDB_val key;
DKBUF;
node = NODEPTR(mp, i);
key.mv_size = node->mn_ksize;
key.mv_data = node->mn_data;
- fprintf(stderr, "key %d: %s\n", i, DKEY(&key));
+ nsize = NODESIZE + NODEKSZ(node) + sizeof(indx_t);
+ if (F_ISSET(node->mn_flags, F_BIGDATA))
+ nsize += sizeof(pgno_t);
+ else
+ nsize += NODEDSZ(node);
+ fprintf(stderr, "key %d: nsize %d, %s\n", i, nsize, DKEY(&key));
}
}
}
nkeys = NUMKEYS(mp);
- split_indx = (nkeys + 1) / 2;
+ split_indx = nkeys / 2;
if (newindx < split_indx)
newpos = 0;
psize += NODEDSZ(node);
psize += psize & 1;
if (psize > pmax) {
- if (i == split_indx - 1 && newindx == split_indx)
- newpos = 1;
+ if (i <= newindx) {
+ split_indx = newindx;
+ if (i < newindx)
+ newpos = 1;
+ }
else
split_indx = i;
break;
psize += NODEDSZ(node);
psize += psize & 1;
if (psize > pmax) {
- split_indx = i+1;
+ if (i >= newindx)
+ split_indx = newindx;
+ else
+ split_indx = i+1;
break;
}
}