mourner / kdbush

A fast static index for 2D points

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

more documentation

turtleDev opened this issue · comments

Hi !

Can you please document the tree-building process, as well as search and range queries?
especially the select process.

What kind of documentation would you want to see? More comments in the code? Or a section in the readme with a high-level description of the algorithms?

A little bit of both.
Things like how dataset is arranged (are data points only kept in node leaves vs data points in internal nodes?), how the tree is stored, and some general insights into design of your implementation.

I see, thanks! I'll try to add a bit of both. The main concept here is that the data is stored flat — it's a sorted array where median splits items into two halfs horizontally, then medians of both halfs split it into quarters vertically, etc. This makes it very fast, but also static.

do you think query performance would take a hit, if instead of using an array, you used an object based tree ?

Yes, both query performance and initial indexing would take much longer (judging by speedup compared to RBush, which is tree-based). V8 is really fast when it comes to working with arrays of numbers.

I'd also appreciate a few comments in the code! I'm interested in porting to Swift...

To shed light on the original question, the select function is basically doing Quicksort.

@hsnetzer it's related to quicksort, but does a different thing: https://en.wikipedia.org/wiki/Quickselect