diff options
author | delphij <delphij@FreeBSD.org> | 2009-03-28 06:25:33 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2009-03-28 06:25:33 +0000 |
commit | 7a713ce8b411c402e521967c5c26f028adfb6a99 (patch) | |
tree | 0f92adf7da6a5075519fcb304792f83e3f848f4d /lib/libc/db | |
parent | 1f2569951365fd99ae5a581c897755dccf97c67d (diff) | |
download | FreeBSD-src-7a713ce8b411c402e521967c5c26f028adfb6a99.zip FreeBSD-src-7a713ce8b411c402e521967c5c26f028adfb6a99.tar.gz |
Only squeeze a short key/value pair onto a page with other complete key/value
pairs, not onto a page containing the end of a big pair.
Obtained from: NetBSD via OpenBSD
Diffstat (limited to 'lib/libc/db')
-rw-r--r-- | lib/libc/db/hash/hash_page.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c index dc267f4..e34b30f 100644 --- a/lib/libc/db/hash/hash_page.c +++ b/lib/libc/db/hash/hash_page.c @@ -404,17 +404,22 @@ __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val) if (!bufp) return (-1); bp = (u_int16_t *)bufp->page; - } else + } else if (bp[bp[0]] != OVFLPAGE) { + /* Short key/data pairs, no more pages */ + break; + } else { /* Try to squeeze key on this page */ - if (FREESPACE(bp) > PAIRSIZE(key, val)) { + if (bp[2] >= REAL_KEY && + FREESPACE(bp) >= PAIRSIZE(key, val)) { squeeze_key(bp, key, val); - return (0); + goto stats; } else { bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); if (!bufp) return (-1); bp = (u_int16_t *)bufp->page; } + } if (PAIRFITS(bp, key, val)) putpair(bufp->page, key, val); @@ -431,6 +436,7 @@ __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val) if (__big_insert(hashp, bufp, key, val)) return (-1); } +stats: bufp->flags |= BUF_MOD; /* * If the average number of keys per bucket exceeds the fill factor, |