diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2011-12-05 12:01:48 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2011-12-05 12:01:48 +1100 |
commit | 09649cb0c7dbb3aa3cf09480e1538c235f5ec399 (patch) | |
tree | 1561c5c38228eea6c7a2707afd1ec39efcbfe295 /src/btree/rec_write.c | |
parent | 05cb2237f6fb652708b5b8e9baaaf04335da4e44 (diff) | |
download | mongo-09649cb0c7dbb3aa3cf09480e1538c235f5ec399.tar.gz |
Cache and use prefixes from the previous key when reconciling row store pages.
Diffstat (limited to 'src/btree/rec_write.c')
-rw-r--r-- | src/btree/rec_write.c | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/src/btree/rec_write.c b/src/btree/rec_write.c index 4b3277e6fa3..8218bd97333 100644 --- a/src/btree/rec_write.c +++ b/src/btree/rec_write.c @@ -2177,6 +2177,13 @@ __rec_row_leaf( __wt_cell_unpack(cell, unpack); WT_ERR( __rec_track_kcell(session, page, unpack)); + + /* + * We skip creating the key, don't try to use + * the last valid key in prefix calculations. + */ + tmp->size = 0; + goto leaf_insert; } @@ -2206,11 +2213,48 @@ __rec_row_leaf( key->cell_len = 0; key->len = key->buf.size; ovfl_key = 1; - } else if (ikey != NULL) - WT_ERR(__rec_cell_build_key(session, - WT_IKEY_DATA(ikey), ikey->size, 0, &ovfl_key)); - else { - WT_ERR(__wt_row_key(session, page, rip, tmp)); + + /* Don't try to use a prefix across an overflow key. */ + tmp->size = 0; + } else { + if (ikey != NULL) { + tmp->data = WT_IKEY_DATA(ikey); + tmp->size = ikey->size; + } else if (session->btree->huffman_key == NULL && + unpack->type == WT_CELL_KEY && + unpack->prefix == 0) { + tmp->data = unpack->data; + tmp->size = unpack->size; + } else if (session->btree->huffman_key == NULL && + unpack->type == WT_CELL_KEY && + tmp->size >= unpack->prefix) { + /* + * If we previously built a prefix-compressed + * key in the temporary buffer, the + * WT_BUF->data field will be the same as the + * WT_BUF->mem field: grow the buffer if + * necessary and copy the suffix into place. + * If we previously pointed the temporary + * buffer at an on-page key, the WT_BUF->data + * field will not be the same as the + * WT_BUF->mem field: grow the buffer if + * necessary, copy the prefix into place, and + * then re-point the WT_BUF->data field to the + * newly constructed memory. + */ + WT_RET(__wt_buf_grow(session, + tmp, unpack->prefix + unpack->size)); + if (tmp->data != tmp->mem) { + memcpy(tmp->mem, tmp->data, + unpack->prefix); + tmp->data = tmp->mem; + } + memcpy((uint8_t *)tmp->data + unpack->prefix, + unpack->data, unpack->size); + tmp->size = unpack->prefix + unpack->size; + } else + WT_ERR(__wt_row_key(session, page, rip, tmp)); + WT_ERR(__rec_cell_build_key( session, tmp->data, tmp->size, 0, &ovfl_key)); } |