@@ -57,11 +57,16 @@ function load_omt!(tree::RTree, elems::AbstractVector;
5757 leaf_fill:: Integer = capacity (Leaf, tree),
5858 branch_fill:: Tuple{Integer, Integer} = omt_branch_fill (tree))
5959 # calculate the tree properties
60- nbranch_subtrees = min (branch_fill[1 ] * branch_fill[2 ], capacity (Leaf, tree))
61- height = ceil (Int, max (log (length (elems)) - log (leaf_fill), 0.0 ) / log (nbranch_subtrees)) + 1 # 1 for leaves
62- maxelems_subtree = leaf_fill* nbranch_subtrees^ (height- 2 ) # max elements in each root subtree
63- nroot_subtrees = fld1 (length (elems), maxelems_subtree)
64- nroot_slices = floor (Int, sqrt (nroot_subtrees))
60+ nbranch_subtrees = min (branch_fill[1 ] * branch_fill[2 ], capacity (Branch, tree))
61+ height = max (ceil (Int, (log (length (elems)) - log (leaf_fill)) / log (nbranch_subtrees)), 0 ) + 1 # 1 for leaves
62+ if height > 1
63+ maxelems_subtree = leaf_fill* nbranch_subtrees^ (height- 2 ) # max elements in each root subtree
64+ nroot_subtrees = fld1 (length (elems), maxelems_subtree)
65+ nroot_slices = floor (Int, sqrt (nroot_subtrees))
66+ else # root === single leaf
67+ maxelems_subtree = nroot_subtrees = length (elems)
68+ nroot_slices = 1
69+ end
6570 # @show length(elems) leaf_fill branch_fill height maxelems_subtree nsubtrees nslices
6671 # sort by the center of the first dim
6772 dim = mod1 (height, ndims (tree)) # root level dimension
0 commit comments