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

Automatically reclaim useless tree nodes created automatically #155

Merged
merged 9 commits into from
Oct 25, 2022

Conversation

dumbbell
Copy link
Member

For instance, if a caller stores a value in "/:stock/:wood/oak", both stock and wood tree nodes are created on the fly, with no payload attached to them.

Now, for these automatically created nodes, a "keep while" condition is added so that they are automatically reclaimed as soon as they have no child nodes and no payload.

In this example, if "/:stock/:wood/oak" is deleted and no other tree nodes were added below "/:stock" or "/:stock/:wood", both stock and wood will be deleted as well.

Fixes #140.

@dumbbell dumbbell added the enhancement New feature or request label Oct 20, 2022
@dumbbell dumbbell self-assigned this Oct 20, 2022
@dumbbell dumbbell force-pushed the auto-reclaim-useless-tree-nodes branch from c3d2256 to 52ecfb8 Compare October 20, 2022 09:27
@codecov
Copy link

codecov bot commented Oct 20, 2022

Codecov Report

Base: 90.98% // Head: 90.97% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (caa77f5) compared to base (0d9e1de).
Patch coverage: 91.66% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #155      +/-   ##
==========================================
- Coverage   90.98%   90.97%   -0.02%     
==========================================
  Files          16       16              
  Lines        2951     2958       +7     
==========================================
+ Hits         2685     2691       +6     
- Misses        266      267       +1     
Flag Coverage Δ
erlang-24 89.55% <91.66%> (+0.05%) ⬆️
erlang-25 89.55% <91.66%> (-0.01%) ⬇️
os-ubuntu-latest 90.93% <91.66%> (-0.05%) ⬇️
os-windows-latest 89.55% <91.66%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/khepri_condition.erl 89.92% <84.61%> (-0.60%) ⬇️
src/khepri_machine.erl 94.33% <93.61%> (+0.23%) ⬆️
src/khepri_path.erl 96.24% <0.00%> (-0.76%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

src/khepri_condition.erl Show resolved Hide resolved
src/khepri_machine.erl Outdated Show resolved Hide resolved
@dumbbell dumbbell force-pushed the auto-reclaim-useless-tree-nodes branch from 52ecfb8 to c4a1065 Compare October 21, 2022 09:15
@dumbbell dumbbell added this to the v0.6.0 milestone Oct 21, 2022
This variable is used for triggers as well, so a more generic name, not
something keep_while-conditions-specific, makes more sense.
This makes naming more consistent.

Also, this fixes an incorrect set of `#{Watcher => remove}`. It will
never match anything and would probably crash. It means the testsuite
does not cover this code path...
... instead of `specific_node` or `many_nodes`.

This allows to access the value of `include_root_props` without having
to add it to `Extra`. Doing this broke the type spec but Dialyzer didn't
notice it.
`none` is not a valid value. To specify "return no props", the option
should be set to an empty map.
This is the same as `#if_has_data{}` but for any kind of payload. I.e.
`#if_has_payload{}` will be true if a tree node hold a stored procedure.
`#if_has_data{}` would have been false for that same tree node.
This is the same as `#if_has_data{}` but for stored procedures.

We now have a more consistent set of `#if_has_*{}` conditions. Thank you
@the-mikedavis for pointing out the issue.
…matically

For instance, if a caller stores a value in "/:stock/:wood/oak", both
`stock` and `wood` tree nodes are created on the fly, with no payload
attached to them.

Now, for these automatically created nodes, a "keep while" condition is
added so that they are automatically reclaimed as soon as they have no
child nodes and no payload.

In this example, if "/:stock/:wood/oak" is deleted and no other tree
nodes were added below "/:stock" or "/:stock/:wood", both `stock` and
`wood` will be deleted as well.

Fixes #140.
@dumbbell dumbbell force-pushed the auto-reclaim-useless-tree-nodes branch from c4a1065 to caa77f5 Compare October 25, 2022 16:35
@dumbbell dumbbell marked this pull request as ready for review October 25, 2022 16:45
@dumbbell dumbbell merged commit 99c33da into main Oct 25, 2022
@dumbbell dumbbell deleted the auto-reclaim-useless-tree-nodes branch October 25, 2022 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically delete tree nodes which were automatically created in the first place
3 participants