1 | /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
2 | // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: |
3 | #ident "$Id$" |
4 | /*====== |
5 | This file is part of PerconaFT. |
6 | |
7 | |
8 | Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. |
9 | |
10 | PerconaFT is free software: you can redistribute it and/or modify |
11 | it under the terms of the GNU General Public License, version 2, |
12 | as published by the Free Software Foundation. |
13 | |
14 | PerconaFT is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | GNU General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU General Public License |
20 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
21 | |
22 | ---------------------------------------- |
23 | |
24 | PerconaFT is free software: you can redistribute it and/or modify |
25 | it under the terms of the GNU Affero General Public License, version 3, |
26 | as published by the Free Software Foundation. |
27 | |
28 | PerconaFT is distributed in the hope that it will be useful, |
29 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
30 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31 | GNU Affero General Public License for more details. |
32 | |
33 | You should have received a copy of the GNU Affero General Public License |
34 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
35 | ======= */ |
36 | |
37 | #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." |
38 | |
39 | /* Purpose of this file is to provide the test programs with internal |
40 | * ule mechanisms that do not belong in the public interface. |
41 | */ |
42 | |
43 | #pragma once |
44 | |
45 | //1 does much slower debugging |
46 | #define ULE_DEBUG 0 |
47 | |
48 | ///////////////////////////////////////////////////////////////////////////////// |
49 | // Following data structures are the unpacked format of a leafentry. |
50 | // * ule is the unpacked leaf entry, that contains an array of unpacked |
51 | // transaction records |
52 | // * uxr is the unpacked transaction record |
53 | // |
54 | |
55 | |
56 | //Types of transaction records. |
57 | enum {XR_INSERT = 1, |
58 | XR_DELETE = 2, |
59 | XR_PLACEHOLDER = 3}; |
60 | |
61 | typedef struct uxr { // unpacked transaction record |
62 | uint8_t type; // delete/insert/placeholder |
63 | uint32_t vallen; // number of bytes in value |
64 | void * valp; // pointer to value (Where is value really stored?) |
65 | TXNID xid; // transaction id |
66 | // Note: when packing ule into a new leafentry, will need |
67 | // to copy actual data from valp to new leafentry |
68 | } UXR_S, *UXR; |
69 | |
70 | |
71 | // Unpacked Leaf Entry is of fixed size because it's just on the |
72 | // stack and we care about ease of access more than the memory footprint. |
73 | typedef struct ule { // unpacked leaf entry |
74 | uint32_t num_puxrs; // how many of uxrs[] are provisional |
75 | uint32_t num_cuxrs; // how many of uxrs[] are committed |
76 | UXR_S uxrs_static[MAX_TRANSACTION_RECORDS*2]; // uxrs[0] is oldest committed (txn commit time, not txn start time), uxrs[num_cuxrs] is outermost provisional value (if any exist/num_puxrs > 0) |
77 | UXR uxrs; //If num_cuxrs < MAX_TRANSACTION_RECORDS then &uxrs_static[0]. |
78 | //Otherwise we use a dynamically allocated array of size num_cuxrs + 1 + MAX_TRANSATION_RECORD. |
79 | } ULE_S, *ULE; |
80 | |
81 | |
82 | |
83 | void test_msg_modify_ule(ULE ule, const ft_msg &msg); |
84 | |
85 | |
86 | ////////////////////////////////////////////////////////////////////////////////////// |
87 | //Functions exported for test purposes only (used internally for non-test purposes). |
88 | void le_unpack(ULE ule, LEAFENTRY le); |
89 | int |
90 | le_pack(ULE ule, // data to be packed into new leafentry |
91 | bn_data* data_buffer, |
92 | uint32_t idx, |
93 | void* keyp, |
94 | uint32_t keylen, |
95 | uint32_t old_keylen, |
96 | uint32_t old_le_size, |
97 | LEAFENTRY * const new_leafentry_p, // this is what this function creates |
98 | void **const maybe_free |
99 | ); |
100 | |
101 | |
102 | size_t le_memsize_from_ule (ULE ule); |
103 | void ule_cleanup(ULE ule); |
104 | |