@@ -10,12 +10,25 @@ function omt_branch_fill(tree::RTree; fill_factor::Number=1.0) where T<:Node
1010end
1111
1212"""
13- Bulk-load the `data` into `tree`.
13+ load!(tree::RTree{T,N,V}, data::Any;
14+ convertel = identity, method = :OMT,
15+ leaf_fill = capacity(Leaf, tree),
16+ branch_fill::Tuple{Integer, Integer} = omt_branch_fill(tree)) where {T,N,V}
17+
18+ Bulk-load `data` into `tree`.
19+ * `tree`: an *empty* R-tree for storing elements of type `V`
20+ * `data`: iterable container with the elements to put into `tree`
21+ * `convertel`: function to convert elements of `data` to type `V`
22+ * `method`: bulk-loading method
23+ * `leaf_fill`: the average number of elements to store in R-tree leaves (1-level nodes)
24+ * `branch_fill`: the tuple of the number of slices and the number of subtrees per slice
25+ in the R-tree nodes (level ≥ 1).
26+
27+ The supported bulk-loading methods are:
28+ * `:OMT`: *Overlap Minimizing Top-down method* by Taewon Lee and Sukho Lee
1429"""
1530function load! (tree:: RTree{T,N,V} , data:: Any ;
16- getmbr = first,
17- getid = idtrait (V) === HasNoID ? x -> nothing : x -> x[2 ],
18- getval = idtrait (V) === HasNoID ? x -> x[2 ] : x -> x[3 ],
31+ convertel = identity,
1932 method:: Symbol = :OMT ,
2033 leaf_fill:: Integer = capacity (Leaf, tree),
2134 branch_fill:: Tuple{Integer, Integer} = omt_branch_fill (tree)) where {T, N, V}
@@ -25,27 +38,14 @@ function load!(tree::RTree{T,N,V}, data::Any;
2538 @warn " No bulk-load data provided"
2639 return tree
2740 end
28- # FIXME kwargs... doesn't work for some reason
29- return load! (tree, V[V (getmbr (x), getid (x), getval (x)) for x in data],
30- method= method, leaf_fill= leaf_fill, branch_fill= branch_fill)
31- end
32-
33- function load! (tree:: RTree{T,N,V} , data:: AbstractVector{V} ;
34- method:: Symbol = :OMT ,
35- leaf_fill:: Integer = capacity (Leaf, tree),
36- branch_fill:: Tuple{Integer, Integer} = omt_branch_fill (tree)) where {T,N,V}
37- isempty (tree) || throw (ArgumentError (" Cannot bulk-load into non-empty tree" ))
38- if isempty (data)
39- @warn " No bulk-load data provided"
40- return tree
41- end
4241 0 < leaf_fill <= capacity (Leaf, tree) ||
4342 throw (ArgumentError (" Leaf fill should be positive and not exceed leaf capacity" ))
4443 prod (branch_fill) > 1 || throw (ArgumentError (" Branch fill should be > 1" ))
4544 if method == :OMT
46- return load_omt! (tree, data, leaf_fill= leaf_fill, branch_fill= branch_fill)
45+ return load_omt! (tree, V[convertel (x) for x in data],
46+ leaf_fill= leaf_fill, branch_fill= branch_fill)
4747 else
48- throw (ArgumentError (" Unsupported bulk-loadaing method $method " ))
48+ throw (ArgumentError (" Unsupported bulk-loading method $method " ))
4949 end
5050end
5151
0 commit comments