You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/MANUAL.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Thanks for AI, there is a generally good [wiki](https://deepwiki.com/ucrparlay/S
9
9
Any contribution is welcomed 🤗!
10
10
11
11
## File Organization
12
-
```{bash}
12
+
```bash
13
13
include/
14
14
├── baselines
15
15
│ ├── boost_rtree
@@ -44,7 +44,7 @@ We will take the **Pkd-tree** as an example, other trees are similar.
44
44
All source files for examples can be found in the [example/](../example/).
45
45
46
46
Everything start with the definition of the `Point`:
47
-
```{c++}
47
+
```c++
48
48
// Type for each coordinate
49
49
using Coord = long;
50
50
@@ -67,7 +67,7 @@ using Point = psi::AugPoint<Coord, 2, AugId>;
67
67
```
68
68
69
69
With `Point`, we can now use all functionalities provided in `Basetree`, e.g.,
70
-
```{c++}
70
+
```c++
71
71
using BT = psi::BaseTree<Point>;
72
72
auto box = BT::GetBox(input); // demo code, to get the bounding box for the input
73
73
```
@@ -76,7 +76,7 @@ You want to augment some info on the tree nodes, both the leaf nodes, and the in
76
76
<details>
77
77
<summary>click to expand</summary>
78
78
79
-
```{c++}
79
+
```c++
80
80
// Leaf augmentation: stores bounding box
81
81
// WARN: All functions must be defined
82
82
template <classBaseTree>
@@ -167,7 +167,7 @@ struct InteriorAugBox {
167
167
</details>
168
168
169
169
Of course, as a spatial partition tree, we can choose how to split the space:
170
-
```{c++}
170
+
```c++
171
171
// Define split rule: max stretch dimension + object median
172
172
using SplitRule = psi::OrthogonalSplitRule<psi::MaxStretchDim<Point>,
173
173
psi::ObjectMedian<Point>>;
@@ -178,36 +178,36 @@ using AnotherSplitRule =
178
178
```
179
179
180
180
Now we can define the tree type with all building blocks above:
181
-
```{c++}
181
+
```c++
182
182
// Define KdTree type
183
183
using Tree = psi::KdTree<Point, SplitRule, LeafAugBox<BT>, InteriorAugBox<BT>>;
184
184
Tree tree;
185
185
```
186
186
187
187
Then we can use the tree as follows:
188
188
- Build the tree:
189
-
```{c++}
189
+
```c++
190
190
Points points;
191
191
auto points_copy = points;
192
192
tree.Build(points_copy);
193
193
```
194
194
- Batch Insert:
195
-
```{c++}
195
+
```c++
196
196
Points insert_points;
197
197
auto insert_copy = insert_points;
198
198
tree.BatchInsert(insert_copy);
199
199
```
200
200
201
201
- Batch Delete (assumes all points to be deleted are in the tree, use `BatchDiff` if you are not sure):
202
-
```{c++}
202
+
```c++
203
203
Points delete_points;
204
204
auto delete_copy = delete_points;
205
205
tree.BatchDelete(delete_copy);
206
206
// tree.BatchDiff(delete_copy);
207
207
```
208
208
209
209
- KNN query
210
-
```{c++}
210
+
```c++
211
211
int K = 10; // K for KNN
212
212
Point query_point; // Points to be queried
213
213
@@ -222,7 +222,7 @@ tree.KNN(root, query_point, bq); // do the query
222
222
```
223
223
224
224
- Range count and Range query
225
-
```{c++}
225
+
```c++
226
226
typename Tree::Box query_box; // a pair of point
227
227
Points range_result(n); // Allocate max possible size
228
228
auto [count, logger] =
@@ -235,7 +235,7 @@ A comprehensive example can be found [here](../example/kd_tree.h).
235
235
PSI also shipped a parallel data_generator for two distribution of points, namely, the `Uniform` (uniformly spread across a cube) and `Varden` (very skewed).
0 commit comments