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

Use objectAt to fetch rowValues (cause meta alloc) #727

Merged
merged 3 commits into from
Jul 19, 2019

Conversation

mixonic
Copy link
Member

@mixonic mixonic commented Jul 19, 2019

A WIP to solve #726

Although the selection set contains raw values only, some other code (like the summing of selected counts for group selection state in collapse-tree.js) expect that all items in the selection set have a meta allocated.

The non-meta-allocated rows were added where the bare children property of a rowValue was being iterated. Instead with this change the tree is referenced for pulling out the children, meaning the meta cache system is exercised and metas allocated for any selected row.

Open questions:

  • Need a few tests. I think @bantic and I have some reasonable ideas about how to test this now.
  • What is the performance implication?
  • The old code was adding only children of a selected group to the explicitly selected group. It did so as it ascended the parent meta tree.
    • This implementation ends up iterating over already processed nodes (disregarded because the depth is unexpected, but still processed).
    • The old implementation I believe would be incorrect if the data is { name: 0, children: [{ name: 1, children: [{ name: 2 }, { name: 3 }] }, { name: 4, children: [{ name: 5 }] }] }, 0 is selected, and you toggle 2 then 5 will never be explicitly selected.
    • A better implementation IMO would be to walk the parents until you find the final isSelected node in the parent tree, then walk tree nodes until the depth becomes >= the depth of that parent. That would then include all children of children.
  • We should review if there are any other uses of "raw" row values without going through the tree. Not every case is wrong, but they are all possibly not allocating a meta where one is needed.
  • Final hairbrained idea: The code that expects this meta to be allocated is itself running only a few lines below this. Is there an alternative bookkeeping which could be internal to this function and is somehow faster/better than allocating the meta? Probably not, but maybe.
    • Regardless selection the Set is actually internal, and there is no reason we can't store an array in that with the meta for each value (or have a maintained-in-parallel Set), and that would avoid the several hits to the meta cache in this function.

@mixonic mixonic requested a review from bantic July 19, 2019 02:20
@mixonic mixonic force-pushed the mixonic/allocate-meta-when-selecting branch 2 times, most recently from 88b1fe3 to ea624c6 Compare July 19, 2019 02:22
Although the `selection` set contains raw values only, some other code
(like the summing of selected counts for group selection state in
`collapse-tree.js`) expect that all items in the `selection` set have a
meta allocated.

The non-meta-allocated rows were added where the bare `children`
property of a rowValue was being iterated. Instead with this change the
`tree` is referenced for pulling out the children, meaning the meta
cache system is exercised and metas allocated for any selected row.
@mixonic mixonic force-pushed the mixonic/allocate-meta-when-selecting branch from ea624c6 to a22c73e Compare July 19, 2019 02:23
@bantic
Copy link
Contributor

bantic commented Jul 19, 2019

This looks good to me. I am working up a failing test case that we can use to ensure this fixes the specific scenario I described in #726 (comment)

Regardless selection the Set is actually internal, and there is no reason we can't store an array in that with the meta for each value (or have a maintained-in-parallel Set), and that would avoid the several hits to the meta cache in this function.

I believe this is still covered, but it's worth keeping in mind that, in addition to a user interactively selecting rows, part of the ET API is that the selection property that's passed-in to the component can be modified (without user interaction) and ET needs to react appropriately to times when the selection is changed that way.

@mixonic
Copy link
Member Author

mixonic commented Jul 19, 2019

@bantic what I mean is that the actual variable, the Set of selection in this function, is cast to an array before it is passed outside the function, so we can consider the data in that set 100% internal. We simply need to ensure we process it into an array before the function passes it out.

@bantic
Copy link
Contributor

bantic commented Jul 19, 2019

Added a failing test in #731 and I've confirmed that rebasing it onto this branch fixes that test.

I'm also going to take a stab at a test to cover this behavior that we think was buggy before:

The old implementation I believe would be incorrect if the data is { name: 0, children: [{ name: 1, children: [{ name: 2 }, { name: 3 }] }, { name: 4, children: [{ name: 5 }] }] }, 0 is selected, and you toggle 2 then 5 will never be explicitly selected.

@bantic bantic added this to the Prepare for 2.0 release milestone Jul 19, 2019
@mixonic mixonic merged commit 9261ff4 into master Jul 19, 2019
@delete-merged-branch delete-merged-branch bot deleted the mixonic/allocate-meta-when-selecting branch July 19, 2019 20:31
Copy link
Contributor

@bantic bantic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! @mixonic and I reviewed carefully in person and we believe this fixes the known issue.

@mixonic
Copy link
Member Author

mixonic commented Jul 19, 2019

@bantic and I reviewed each of the checked off items above to solidify our understanding here. As followup he intends to:

There is also low-hanging performance work that could be done after this change. Our goal in this patch was just to make it work, but the implementation is a bit naive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants