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

refactor: Merkle clock heads cleanup #918

Merged
merged 14 commits into from
Oct 27, 2022

Conversation

AndrewSisley
Copy link
Contributor

Relevant issue(s)

Part of #849

Description

I cleaned up the code a bit as part of #849 however I have hit another snag (unrelated to these changes) and will need to think more. I consider these commits to be a desirable improvement in there own right and it could be good to get them in earlier (it will also shrink the feature PR when it comes along).

@AndrewSisley AndrewSisley added area/crdt Related to the (Merkle) CRDT system refactor This issue specific to or requires *notable* refactoring of existing codebases and components action/no-benchmark Skips the action that runs the benchmark. labels Oct 26, 2022
@AndrewSisley AndrewSisley added this to the DefraDB v0.4 milestone Oct 26, 2022
@AndrewSisley AndrewSisley requested a review from a team October 26, 2022 19:23
@AndrewSisley AndrewSisley self-assigned this Oct 26, 2022
Add is a poor name, and adds an extra layer of misdirection.
Is only called from here, and the caller to this function knows that this row exists, so we will never actually hit the isNotFound error allowing it to be safely dropped.
Old names unhelpful and the distinction was easily missed resulting in a bug (caught by tests).
Is only called once, and the unfactoring allows for future refactorings
Error would have been way up the callstack where ever height was declared, and it is on those funcs to make sure it fits whatever constraints they may have.
Is also potentially misleading as the cid's location in the key is dependent on the index format, not the code in this file/package
@AndrewSisley AndrewSisley force-pushed the sisley/feat/I849-heads-refactor branch from af48e5d to cd604de Compare October 26, 2022 19:24
This optimization should be handled by the index, not the scan code.  It also produces undesirable errors which have been corrected in this commit.
@AndrewSisley AndrewSisley force-pushed the sisley/feat/I849-heads-refactor branch from cd604de to 50b7193 Compare October 26, 2022 19:27
@codecov
Copy link

codecov bot commented Oct 26, 2022

Codecov Report

Merging #918 (50b7193) into develop (3b53193) will decrease coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #918      +/-   ##
===========================================
- Coverage    59.90%   59.82%   -0.08%     
===========================================
  Files          159      159              
  Lines        17391    17335      -56     
===========================================
- Hits         10418    10371      -47     
+ Misses        6044     6038       -6     
+ Partials       929      926       -3     
Impacted Files Coverage Δ
planner/commit.go 83.13% <ø> (-1.23%) ⬇️
merkle/clock/clock.go 63.96% <100.00%> (ø)
merkle/clock/heads.go 70.00% <100.00%> (-3.46%) ⬇️

merkle/clock/heads.go Show resolved Hide resolved
merkle/clock/heads.go Show resolved Hide resolved
Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

LGTM.

@AndrewSisley AndrewSisley merged commit dbc8cd0 into develop Oct 27, 2022
@AndrewSisley AndrewSisley deleted the sisley/feat/I849-heads-refactor branch October 27, 2022 15:36
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
* Remove commented out code

* Remove dead code (Len)

* Remove unnessecary var declaration

* Remove unessecary func param

* Remove extra Add func

Add is a poor name, and adds an extra layer of misdirection.

* Remove extra delete func

Is only called from here, and the caller to this function knows that this row exists, so we will never actually hit the isNotFound error allowing it to be safely dropped.

* Rename func params

Old names unhelpful and the distinction was easily missed resulting in a bug (caught by tests).

* Unfactor IsHead

Is only called once, and the unfactoring allows for future refactorings

* Remove unused return param

* Use Has instead of Get+IsError

* Remove private constructor

* Remove incorrect error

Error would have been way up the callstack where ever height was declared, and it is on those funcs to make sure it fits whatever constraints they may have.

* Remove unhelpful comment

Is also potentially misleading as the cid's location in the key is dependent on the index format, not the code in this file/package

* Remove cid-based shortcut

This optimization should be handled by the index, not the scan code.  It also produces undesirable errors which have been corrected in this commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/crdt Related to the (Merkle) CRDT system refactor This issue specific to or requires *notable* refactoring of existing codebases and components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants