diff options
author | Keith Bostic <keith@wiredtiger.com> | 2014-05-30 09:54:20 -0400 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2014-05-30 09:54:20 -0400 |
commit | 983da1ff448fdfa5b2ee1508f1f6601afc4d6f73 (patch) | |
tree | f0a0024d1f0aaab86fb47eb02786e69e936550c9 /src/include/cursor.i | |
parent | 8b2027b80b8ce0226489d6a94738ae721847ea6c (diff) | |
download | mongo-983da1ff448fdfa5b2ee1508f1f6601afc4d6f73.tar.gz |
Experimental change to avoid unpacking cells in order to access
row-store leaf page keys.
If a page has no Huffman or prefix compression, and no overflow keys,
encode the key's page offset and size in the WT_ROW pointer and set a
flag on the page. From that point on, when the flag is set, we can
go directly to the key instead of unpacking the key's cell each time.
Diffstat (limited to 'src/include/cursor.i')
-rw-r--r-- | src/include/cursor.i | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/include/cursor.i b/src/include/cursor.i index 5505bc1b702..c9026c2ee8f 100644 --- a/src/include/cursor.i +++ b/src/include/cursor.i @@ -177,6 +177,7 @@ __cursor_row_slot_return(WT_CURSOR_BTREE *cbt, WT_ROW *rip, WT_UPDATE *upd) WT_PAGE *page; WT_SESSION_IMPL *session; int key_unpacked; + void *copy; session = (WT_SESSION_IMPL *)cbt->iface.session; btree = S2BT(session); @@ -189,26 +190,27 @@ __cursor_row_slot_return(WT_CURSOR_BTREE *cbt, WT_ROW *rip, WT_UPDATE *upd) vb = &cbt->iface.value; /* - * Return the WT_ROW slot's K/V pair. + * The row-store key can change underfoot; explicitly take a copy. */ + copy = WT_ROW_KEY_COPY(rip); - ikey = WT_ROW_KEY_COPY(rip); /* - * Key copied. - * * Get a reference to the key, ideally without doing a copy: we could * call __wt_row_leaf_key, but if a cursor is running through the tree, * we actually have more information here than that function has, we * may have the prefix-compressed key that comes immediately before the * one we want. * - * If the key has been instantiated (the key points off-page), we don't - * have any work to do. + * If the key can be accessed directly, or has been instantiated (the + * key points off-page), we don't have any work to do. * * If the key points on-page, we have a copy of a WT_CELL value that can * be processed, regardless of what any other thread is doing. */ - if (__wt_off_page(page, ikey)) { + if (F_ISSET_ATOMIC(page, WT_PAGE_DIRECT_KEY)) + __wt_row_leaf_direct(page, copy, kb); + else if (__wt_off_page(page, copy)) { + ikey = copy; kb->data = WT_IKEY_DATA(ikey); kb->size = ikey->size; } else { @@ -220,7 +222,7 @@ __cursor_row_slot_return(WT_CURSOR_BTREE *cbt, WT_ROW *rip, WT_UPDATE *upd) */ if (btree->huffman_key != NULL) goto slow; - __wt_cell_unpack_with_value(page, (WT_CELL *)ikey, unpack); + __wt_cell_unpack_with_value(page, copy, unpack); key_unpacked = 1; if (unpack->type == WT_CELL_KEY && unpack->prefix == 0) { cbt->tmp.data = unpack->data; |