Skip to content
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

[core] Implement tree-based row management #2996

Merged
merged 14 commits into from
Nov 2, 2021

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Oct 26, 2021

Extracted from #2725
Closes #2813

Contains all the evolution of the existing components / hooks to prepare for the Tree Data and other tree-related features.
Should not contain any behavior change when used with a flat tree.

Performances

Impact on large dataset when Tree Data is not enabled

We have on additional loop over the rows in getFlatRowTree to convert to the tree format. It takes ~30ms on my Ryzen 5800X for 100.000 lines so it is not totally painless on very large dataset. I think it is not worth working on it right now, and it won't be trivial because the only solution I see is to allow to store no tree in the state and everywhere we use it take care of the scenario where it is not defined.

For all the others children-related selectors / methods that loop over the rows, they should not do it if the treeDepth === 1 (for instance do not calculate the filteredDescendantCountLookup if the tree is flat, it would be a wast of time).

Should we sort collapsed children ?

Right now I sort all the rows, even the collapsed children.
But if users have large amount of children, it will spend time sorting all of them even though they are not visible.
Should we leave the collapsed children unsorted and accept that the apiRef.current.getSortedRows returns unsorted one for the collapsed ?

Main points

useGridRows

  • Small overhead when the tree is flat (see "Impact on large dataset when Tree Data is not enabled")

  • All non-throttled updates are done on the list structure

  • Only generates the tree structure in the throttled update

  • Major changes to the internal cache structure to avoid useless tree generation

useGridSorting

  • No overhead when the tree is flat

  • No state change

useGridFilter

  • No overhead when the tree is flat

  • Re-apply the filter when a row is collapsed / expanded

  • New state key filteredDescendantCountLookup to count the descendants passing the filters (allow to display the (6) below)

image

  • Remove the key visibleRows that is never used, it is the selector gridVisibleSortedRowEntriesSelector that generates it. This mean that the sorting and filtering process are now very independent.

useCurrentPageRows

With the children, getting the list of the paginated visible rows is not a simple slice anymore.
So I did not want to implement this logic on several files.
This new hook tries to only add the overhead of looking for the children when we have the pagination enabled AND the tree is not flat. That is why I don't use useGridSelector in it.

@flaviendelangle flaviendelangle marked this pull request as draft October 26, 2021 13:37
@flaviendelangle flaviendelangle marked this pull request as ready for review October 26, 2021 13:47
@flaviendelangle flaviendelangle added component: data grid This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes labels Oct 26, 2021
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 28, 2021
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 28, 2021
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 1, 2021
@github-actions
Copy link

github-actions bot commented Nov 1, 2021

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 1, 2021
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 2, 2021
@github-actions
Copy link

github-actions bot commented Nov 2, 2021

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core] Implement tree-based row management
1 participant