1
- #include < cista/containers/mmap_vec.h>
2
- #include < cista/mmap.h>
3
1
#include < cinttypes>
4
2
#include < cstring>
5
3
#include < iostream>
6
4
5
+ #include " cista/containers/mmap_vec.h"
7
6
#include " cista/containers/rtree.h"
7
+ #include " cista/mmap.h"
8
+ #include " cista/serialization.h"
9
+
8
10
extern " C" {
9
- #include < stdatomic.h>
10
11
#include " dependencies/rtree_c/rtree_c.h"
11
12
}
12
13
@@ -21,8 +22,8 @@ struct ctx_entry {
21
22
22
23
bool operator ==(ctx_entry other) const {
23
24
cista_rtree rt;
24
- return rt.rect_ .coord_t_equal (this ->min , other.min ) &&
25
- rt.rect_ .coord_t_equal (this ->max , other.max ) &&
25
+ return rt.m_ . rect_ .coord_t_equal (this ->min , other.min ) &&
26
+ rt.m_ . rect_ .coord_t_equal (this ->max , other.max ) &&
26
27
this ->data == other.data ;
27
28
}
28
29
};
@@ -149,30 +150,31 @@ int test_bench(uint8_t const* data, size_t size) {
149
150
iter_ref_ctx ctx{};
150
151
ctx.count = 0 ;
151
152
ctx.expected_value = 0 ;
152
- uut_tree.search (coord_min, coord_max,
153
- [coord_min, coord_max, &ctx, &uut_tree](
154
- cista_rtree::coord_t const & min_temp,
155
- cista_rtree::coord_t const & max_temp, uint32_t data) {
156
- if (uut_tree.rect_ .coord_t_equal (coord_min, min_temp) &&
157
- uut_tree.rect_ .coord_t_equal (coord_max, max_temp)) {
158
- ctx.expected_value ++;
159
- ctx_entry input_entry{};
160
- input_entry.min = min_temp;
161
- input_entry.max = max_temp;
162
- input_entry.data = data;
163
- ctx.found_entries .emplace_back (input_entry);
164
- }
165
- return true ;
166
- });
153
+ uut_tree.search (
154
+ coord_min, coord_max,
155
+ [coord_min, coord_max, &ctx, &uut_tree](
156
+ cista_rtree::coord_t const & min_temp,
157
+ cista_rtree::coord_t const & max_temp, uint32_t data) {
158
+ if (uut_tree.m_ .rect_ .coord_t_equal (coord_min, min_temp) &&
159
+ uut_tree.m_ .rect_ .coord_t_equal (coord_max, max_temp)) {
160
+ ctx.expected_value ++;
161
+ ctx_entry input_entry{};
162
+ input_entry.min = min_temp;
163
+ input_entry.max = max_temp;
164
+ input_entry.data = data;
165
+ ctx.found_entries .emplace_back (input_entry);
166
+ }
167
+ return true ;
168
+ });
167
169
168
170
ctx.expected_value_mm = 0 ;
169
171
cista_mm_rtree.search (
170
172
coord_min, coord_max,
171
173
[coord_min, coord_max, &ctx, &cista_mm_rtree](
172
174
cista_rtree::coord_t const & min_temp,
173
175
cista_rtree::coord_t const & max_temp, uint32_t data) {
174
- if (cista_mm_rtree.rect_ .coord_t_equal (coord_min, min_temp) &&
175
- cista_mm_rtree.rect_ .coord_t_equal (coord_max, max_temp)) {
176
+ if (cista_mm_rtree.m_ . rect_ .coord_t_equal (coord_min, min_temp) &&
177
+ cista_mm_rtree.m_ . rect_ .coord_t_equal (coord_max, max_temp)) {
176
178
ctx.expected_value_mm ++;
177
179
ctx_entry input_entry{};
178
180
input_entry.min = min_temp;
@@ -210,20 +212,15 @@ int test_bench(uint8_t const* data, size_t size) {
210
212
}
211
213
212
214
if (op == SAVE_LOAD) {
213
- std::fstream file;
214
- file.open (" mmap_rtree_header.bin" , std::ios::binary | std::ios::out);
215
- cista_mm_rtree.write_header_bin (file);
216
- file.close ();
215
+ cista_mm_rtree.write_meta (" mmap_rtree_header.bin" );
217
216
218
217
auto save_load_file = cista::mmap{" ./mmap_rtree_nodes.bin" ,
219
218
cista::mmap::protection::MODIFY};
220
219
cista_mm_rtree.nodes_ =
221
220
cista::mmap_vec_map<mm_rtree::node_idx_t , mm_rtree::node>{
222
221
std::move (save_load_file)};
223
222
224
- file.open (" mmap_rtree_header.bin" , std::ios::binary | std::ios::in);
225
- cista_mm_rtree.read_header_bin (file);
226
- file.close ();
223
+ cista_mm_rtree.read_meta (" mmap_rtree_header.bin" );
227
224
}
228
225
229
226
current_position = current_position + 21 ;
0 commit comments