sdd / kiddo

Kiddo
Apache License 2.0
91 stars 14 forks source link

Clear Float KdTree #76

Closed DawChihLiou closed 1 year ago

DawChihLiou commented 1 year ago

Hi @sdd, thanks for the great work! I'm wondering if there's a way to clean all the nodes from a KdTree without iterating through. Thanks so much!

sdd commented 1 year ago

Thanks @DawChihLiou! No, there is no specific method for that. It would be pretty straight forward to add one though. What are you trying to achieve with this?

DawChihLiou commented 1 year ago

I came across a use case where users deleted documents in bulk and sometimes an entire k-d tree became invalid because all the reference data were deleted and the nodes were pointing nowhere. So I'm exploring a less expensive removal to clean the tree. Would it be more straightforward just to instantiate a new tree in this case?

sdd commented 1 year ago

Yes, in this case it would certainly be better to rebuild the tree. Removal of items is implemented in a very basic way - there is no rebalancing of the tree performed on removal.

DawChihLiou commented 1 year ago

Will you consider implement rebalancing on removal? Removal happens quite frequently and maintaining query performance would be something my clients love to see.