Debian Codegraph @

unittest/gunit/innodb/lob/ut0frags.cc

raw symbols SCIP
1 /*****************************************************************************
2
3 Copyright (c) 2016, 2026, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8
9 This program is designed to work with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20 for more details.
21
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26 *****************************************************************************/
27
28 #include <list>
29 #include <vector>
30
31 #include "zlob0int.h"
32
33 using namespace zlob;
34
35 void line() { std::cout << " - - - - - - - - - - - " << std::endl; }
36
37 void basic_0() {
38 zlob::z_frag_page_t frag_page;
39
40 frag_page.print(std::cout);
41
42 frag_page.alloc();
43
44 frag_page.print(std::cout);
45 }
46
47 void basic_1() {
48 zlob::z_frag_page_t frag_page;
49
50 line();
51 frag_page.print(std::cout);
52
53 frag_page.alloc();
54
55 line();
56 frag_page.print(std::cout);
57
58 frag_page.alloc_fragment(100);
59
60 line();
61 frag_page.print(std::cout);
62 }
63
64 void basic_2() {
65 zlob::z_frag_page_t frag_page;
66
67 line();
68 frag_page.print(std::cout);
69
70 frag_page.alloc();
71
72 line();
73 frag_page.print(std::cout);
74
75 ulint frag = frag_page.alloc_fragment(100);
76
77 line();
78 frag_page.print(std::cout);
79
80 frag_page.dealloc_fragment(frag);
81 line();
82 frag_page.print(std::cout);
83 }
84
85 void basic_3() {
86 zlob::z_frag_page_t frag_page;
87 frag_page.alloc();
88
89 line();
90 frag_page.print(std::cout);
91
92 std::list<ulint> fragments;
93
94 for (int i = 0; i < 5; ++i) {
95 ulint frag = frag_page.alloc_fragment(100);
96 fragments.push_back(frag);
97 }
98
99 line();
100 frag_page.print(std::cout);
101
102 while (!fragments.empty()) {
103 frag_page.dealloc_fragment(fragments.front());
104 fragments.pop_front();
105 }
106
107 line();
108 frag_page.print(std::cout);
109 }
110
111 void basic_4() {
112 zlob::z_frag_page_t frag_page;
113 frag_page.alloc();
114
115 line();
116 frag_page.print(std::cout);
117
118 std::list<ulint> fragments;
119
120 ulint frag = frag_page.alloc_fragment(100);
121
122 while (frag != FRAG_ID_NULL) {
123 fragments.push_back(frag);
124 frag = frag_page.alloc_fragment(100);
125 }
126
127 line();
128 frag_page.print(std::cout);
129
130 while (!fragments.empty()) {
131 frag_page.dealloc_fragment(fragments.front());
132 fragments.pop_front();
133 }
134
135 line();
136 frag_page.print(std::cout);
137 }
138
139 void basic_5() {
140 zlob::z_frag_page_t frag_page;
141 frag_page.alloc();
142
143 line();
144 frag_page.print(std::cout);
145
146 std::list<ulint> fragments;
147
148 ulint frag = frag_page.alloc_fragment(100);
149
150 while (frag != FRAG_ID_NULL) {
151 fragments.push_back(frag);
152 frag = frag_page.alloc_fragment(100);
153 }
154
155 frag = frag_page.alloc_fragment(32);
156
157 if (frag != FRAG_ID_NULL) {
158 fragments.push_back(frag);
159 }
160
161 line();
162 frag_page.print(std::cout);
163
164 while (!fragments.empty()) {
165 frag_page.dealloc_fragment(fragments.front());
166 fragments.pop_front();
167 }
168
169 line();
170 frag_page.print(std::cout);
171 }
172
173 void basic_6() {
174 zlob::z_frag_page_t frag_page;
175 frag_page.alloc();
176
177 line();
178 frag_page.print(std::cout);
179
180 std::vector<frag_id_t> fragments;
181
182 ulint frag = frag_page.alloc_fragment(100);
183
184 while (frag != FRAG_ID_NULL) {
185 fragments.push_back(frag);
186 frag = frag_page.alloc_fragment(100);
187 }
188
189 line();
190 frag_page.print(std::cout);
191
192 for (ulint i = 0; i < fragments.size(); i += 2) {
193 frag_page.dealloc_fragment(fragments[i]);
194 }
195
196 line();
197 frag_page.print(std::cout);
198 }
199
200 void test7() {
201 zlob::z_frag_page_t frag_page;
202 frag_page.alloc();
203
204 frag_id_t f1 = frag_page.alloc_fragment(5692);
205
206 ut_ad(f1 != FRAG_ID_NULL);
207
208 std::cout << "ONE" << std::endl;
209 frag_page.print(std::cout);
210
211 frag_id_t f2 = frag_page.alloc_fragment(433);
212 ut_ad(f2 != FRAG_ID_NULL);
213
214 std::cout << "TWO" << std::endl;
215 frag_page.print(std::cout);
216
217 frag_id_t f3 = frag_page.alloc_fragment(419);
218 ut_ad(f3 != FRAG_ID_NULL);
219
220 frag_node_t node3 = frag_page.get_frag_node(f3);
221 std::cout << node3 << std::endl;
222 }
223
224 int main() { test7(); }