Insertion fails after rbush becomes empty
twpayne opened this issue · comments
After removing all items from an rbush, inserting new items fails.
Quick steps to reproduce
- Go to the uniformly distributed random data demo
- Click the "Remove leftmost 10000" button five times
- Click "Insert 1000" button
- Observe that no new items are added
Extra information
The console displays:
Uncaught TypeError: Cannot read property 'leaf' of undefined rbush.js:223
rbush._chooseSubtree rbush.js:223
rbush._insert rbush.js:259
rbush.insert rbush.js:89
(anonymous function) viz-uniform.html:37
Interesting! It works perfectly for me with the steps you provided in Chrome / OS X. What browser / OS are you using? Could you check other browsers?
Oh, I see now! I clicked "bulk-insert" instead of insert. Thanks for the report!
Good that you can duplicate it. I've observed this in Mac OS X / Chrome Canary (32) but you're already on the case...
Yeah. The problem is that _condense
doesn't update tree height and leaf status when condensing the tree after removal (which potentially can lead to other performance problems).