downflux / go-kd

Golang k-D tree implementation with duplicate coordinate support

Home Page:https://pkg.go.dev/github.com/downflux/go-kd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement faster RangeSearch

minkezhang opened this issue · comments

RangeSearch implements a recursive model for searching through a bounding box. In order to increase efficiency, RangeSearch runs the left and right recursion calls in parallel via a channel. This recursion becomes expensive as we near the bottom of the tree, and we should instead swap to using a serial execution model instead. However, we do not have a good heuristic as to how much data is left in the subtree to prune -- node.Data() []T only returns the data stored in each individual node and does not reflect child nodes. We will need to implement node.Depth() int or some other heuristic in order to make RangeSearch more efficient.

Overall, this makes RangeSearch of small N (< 10k) fairly slow as compared to the reference http://github.com/kyroy/kdtree implementation. For large N, RangeSearch is still overall faster, but the execution time can still be improved.