-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cc
157 lines (150 loc) · 5.15 KB
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include "prtree.h"
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
namespace py = pybind11;
using T = int64_t; // is a temporary type of template. You can change it and
// recompile this.
const int B = 8; // the number of children of tree.
PYBIND11_MODULE(PRTree, m)
{
m.doc() = R"pbdoc(
INCOMPLETE Priority R-Tree
Only supports for construct and find
insert and delete are not supported.
)pbdoc";
py::class_<PRTree<T, B, 2>>(m, "_PRTree2D")
.def(py::init<py::array_t<T>, py::array_t<float>>(), R"pbdoc(
Construct PRTree with init.
)pbdoc")
.def(py::init<>(), R"pbdoc(
Construct PRTree with .
)pbdoc")
.def(py::init<std::string>(), R"pbdoc(
Construct PRTree with load.
)pbdoc")
.def("query", &PRTree<T, B, 2>::find_one, R"pbdoc(
Find all indexes which has intersect with given bounding box.
)pbdoc")
.def("batch_query", &PRTree<T, B, 2>::find_all, R"pbdoc(
parallel query with multi-thread
)pbdoc")
.def("batch_query_array", &PRTree<T, B, 2>::find_all_array, R"pbdoc(
parallel query with multi-thread with array output
)pbdoc")
.def("erase", &PRTree<T, B, 2>::erase, R"pbdoc(
Delete from prtree
)pbdoc")
.def("set_obj", &PRTree<T, B, 2>::set_obj, R"pbdoc(
Set string by index
)pbdoc")
.def("get_obj", &PRTree<T, B, 2>::get_obj, R"pbdoc(
Get string by index
)pbdoc")
.def("insert", &PRTree<T, B, 2>::insert, R"pbdoc(
Insert one to prtree
)pbdoc")
.def("save", &PRTree<T, B, 2>::save, R"pbdoc(
cereal save
)pbdoc")
.def("load", &PRTree<T, B, 2>::load, R"pbdoc(
cereal load
)pbdoc")
.def("rebuild", &PRTree<T, B, 2>::rebuild, R"pbdoc(
rebuild prtree
)pbdoc")
.def("size", &PRTree<T, B, 2>::size, R"pbdoc(
get n
)pbdoc");
py::class_<PRTree<T, B, 3>>(m, "_PRTree3D")
.def(py::init<py::array_t<T>, py::array_t<float>>(), R"pbdoc(
Construct PRTree with init.
)pbdoc")
.def(py::init<>(), R"pbdoc(
Construct PRTree with .
)pbdoc")
.def(py::init<std::string>(), R"pbdoc(
Construct PRTree with load.
)pbdoc")
.def("query", &PRTree<T, B, 3>::find_one, R"pbdoc(
Find all indexes which has intersect with given bounding box.
)pbdoc")
.def("batch_query", &PRTree<T, B, 3>::find_all, R"pbdoc(
parallel query with multi-thread
)pbdoc")
.def("batch_query_array", &PRTree<T, B, 3>::find_all_array, R"pbdoc(
parallel query with multi-thread with array output
)pbdoc")
.def("erase", &PRTree<T, B, 3>::erase, R"pbdoc(
Delete from prtree
)pbdoc")
.def("set_obj", &PRTree<T, B, 3>::set_obj, R"pbdoc(
Set string by index
)pbdoc")
.def("get_obj", &PRTree<T, B, 3>::get_obj, R"pbdoc(
Get string by index
)pbdoc")
.def("insert", &PRTree<T, B, 3>::insert, R"pbdoc(
Insert one to prtree
)pbdoc")
.def("save", &PRTree<T, B, 3>::save, R"pbdoc(
cereal save
)pbdoc")
.def("load", &PRTree<T, B, 3>::load, R"pbdoc(
cereal load
)pbdoc")
.def("rebuild", &PRTree<T, B, 3>::rebuild, R"pbdoc(
rebuild prtree
)pbdoc")
.def("size", &PRTree<T, B, 3>::size, R"pbdoc(
get n
)pbdoc");
py::class_<PRTree<T, B, 4>>(m, "_PRTree4D")
.def(py::init<py::array_t<T>, py::array_t<float>>(), R"pbdoc(
Construct PRTree with init.
)pbdoc")
.def(py::init<>(), R"pbdoc(
Construct PRTree with .
)pbdoc")
.def(py::init<std::string>(), R"pbdoc(
Construct PRTree with load.
)pbdoc")
.def("query", &PRTree<T, B, 4>::find_one, R"pbdoc(
Find all indexes which has intersect with given bounding box.
)pbdoc")
.def("batch_query", &PRTree<T, B, 4>::find_all, R"pbdoc(
parallel query with multi-thread
)pbdoc")
.def("batch_query_array", &PRTree<T, B, 4>::find_all_array, R"pbdoc(
parallel query with multi-thread with array output
)pbdoc")
.def("erase", &PRTree<T, B, 4>::erase, R"pbdoc(
Delete from prtree
)pbdoc")
.def("set_obj", &PRTree<T, B, 4>::set_obj, R"pbdoc(
Set string by index
)pbdoc")
.def("get_obj", &PRTree<T, B, 4>::get_obj, R"pbdoc(
Get string by index
)pbdoc")
.def("insert", &PRTree<T, B, 4>::insert, R"pbdoc(
Insert one to prtree
)pbdoc")
.def("save", &PRTree<T, B, 4>::save, R"pbdoc(
cereal save
)pbdoc")
.def("load", &PRTree<T, B, 4>::load, R"pbdoc(
cereal load
)pbdoc")
.def("rebuild", &PRTree<T, B, 4>::rebuild, R"pbdoc(
rebuild prtree
)pbdoc")
.def("size", &PRTree<T, B, 4>::size, R"pbdoc(
get n
)pbdoc");
#ifdef VERSION_INFO
m.attr("__version__") = VERSION_INFO;
#else
m.attr("__version__") = "dev";
#endif
}