-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tree-table] Refactor tree-table, make data structures private #500
Conversation
Refactors the tree-table component to use private internal data structures instead of the semi-public LinkedListTree. Replaces the LinkedListTree with a simpler CollapseTree which should be much cheaper to build and operate in general. The new data structure automatically wraps a much simpler POJO structure that should be passed into TreeTable. It will respond to changes in the underlying data structure, so if the user updates the POJO everything will update accordingly.
This is an interesting data structure. Some question I want to check if my understanding is correct:
This might not be a big issue until the table hits 100k rows. If the API is better, we can adopt this over LinkedListTree |
The main advantage to this strategy besides autowrapping is reducing the number of allocations by an order of magnitude. We generally have trees which are pretty flat, and leveraging this can reduce the number of allocations to a point where it's almost unnoticeable. Let's say you have a tree with 100 children per parent. At 3 levels deep, that would be 1,000,000 rows. Creating a node per actual, real value-node takes a huge amount of time, and costs a massive amount of memory. By comparison, this tree would generate 10,000 rows, and can be done almost instantaneously on a decently powerful machine. Denser trees will likely not benefit nearly as much from this strategy, but it also shouldn't hurt them. |
// Changes to the value directly should properly update all computeds on this | ||
// node, but we need to manually propogate changes upwards to notify any other | ||
// watchers | ||
addObserver(this, 'length', () => Ember.propertyDidChange(parent, 'length')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this create memleak when Node is no longer used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Observers are instance state and will be garbage collected along with the instance, so long as there are no other references to the instance.
:+1 Overall looks good. Only one comment regarding the observer. |
Refactors the tree-table component to use private internal data
structures instead of the semi-public LinkedListTree. Replaces the
LinkedListTree with a simpler CollapseTree which should be much cheaper
to build and operate in general.
The new data structure automatically wraps a much simpler POJO structure
that should be passed into TreeTable. It will respond to changes in the
underlying data structure, so if the user updates the POJO everything
will update accordingly.