Skip to content

Commit 14ff45a

Browse files
rtree refactor (#237)
* rtree-wip * wip * wip * wip
1 parent 4c1d58f commit 14ff45a

File tree

6 files changed

+226
-404
lines changed

6 files changed

+226
-404
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
3636
-Wno-deprecated-declarations
3737
-Wno-ctad-maybe-unsupported
3838
-Wno-self-assign-overloaded
39+
-Wno-switch-default
3940
-Werror
4041
)
4142
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")

fuzz/rtree_verification.cc

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
#include <cista/containers/mmap_vec.h>
2-
#include <cista/mmap.h>
31
#include <cinttypes>
42
#include <cstring>
53
#include <iostream>
64

5+
#include "cista/containers/mmap_vec.h"
76
#include "cista/containers/rtree.h"
7+
#include "cista/mmap.h"
8+
#include "cista/serialization.h"
9+
810
extern "C" {
9-
#include <stdatomic.h>
1011
#include "dependencies/rtree_c/rtree_c.h"
1112
}
1213

@@ -21,8 +22,8 @@ struct ctx_entry {
2122

2223
bool operator==(ctx_entry other) const {
2324
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) &&
2627
this->data == other.data;
2728
}
2829
};
@@ -149,30 +150,31 @@ int test_bench(uint8_t const* data, size_t size) {
149150
iter_ref_ctx ctx{};
150151
ctx.count = 0;
151152
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+
});
167169

168170
ctx.expected_value_mm = 0;
169171
cista_mm_rtree.search(
170172
coord_min, coord_max,
171173
[coord_min, coord_max, &ctx, &cista_mm_rtree](
172174
cista_rtree::coord_t const& min_temp,
173175
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)) {
176178
ctx.expected_value_mm++;
177179
ctx_entry input_entry{};
178180
input_entry.min = min_temp;
@@ -210,20 +212,15 @@ int test_bench(uint8_t const* data, size_t size) {
210212
}
211213

212214
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");
217216

218217
auto save_load_file = cista::mmap{"./mmap_rtree_nodes.bin",
219218
cista::mmap::protection::MODIFY};
220219
cista_mm_rtree.nodes_ =
221220
cista::mmap_vec_map<mm_rtree::node_idx_t, mm_rtree::node>{
222221
std::move(save_load_file)};
223222

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");
227224
}
228225

229226
current_position = current_position + 21;

0 commit comments

Comments
 (0)