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: Rework limit node flow #767

Merged
merged 3 commits into from
Aug 31, 2022

Conversation

AndrewSisley
Copy link
Contributor

Relevant issue(s)

Resolves #764

Description

Reworks the limit logic, removing the 2 limit node types and instead relying on mapper to to add a new backing field if the limits are not equal. Should make it much much easier to add (full) limit support for aggregates, as previously they were tripping up on the deleted lines in planner (RE parent aggregates), this task was broken out of that piece of work as I saw it as an easy way to break up the PR, and a valuable improvement to the code in its own right.

There is some loss of efficiency here, I think the new limit nodes will make use of the same valuesNode (so not fetching from file twice) but not sure. The planner should be able to optimize this better in the future by using the (bigger) limitNode as the source of the smaller limit node or something similar. I am happy saving that plan optimization for another day, but please let me know your thoughts on this.

Specify the platform(s) on which this was tested:

  • Debian Linux

@AndrewSisley AndrewSisley added area/query Related to the query component 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 Aug 30, 2022
@AndrewSisley AndrewSisley added this to the DefraDB v0.3.1 milestone Aug 30, 2022
@AndrewSisley AndrewSisley requested a review from a team August 30, 2022 15:32
@AndrewSisley AndrewSisley self-assigned this Aug 30, 2022
return false
}

if !s.Limit.equal(other.Limit) {
Copy link
Member

Choose a reason for hiding this comment

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

todo: Since you are adding this new Limit comparison, please update the above Note.

suggestion(non-blocking): Removal of these lines:

// Note: Currently only compares Name and Filter as that is all that is currently required,
// but this should be extended in the future.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Aug 30, 2022

Choose a reason for hiding this comment

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

Ah cheers, I saw that and forgot about it by the time I'd fixed the tests. Changing.

  • Update comment

Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

Beauty of a PR! Nice and clean to review. LGTM.

@codecov
Copy link

codecov bot commented Aug 30, 2022

Codecov Report

Merging #767 (585c202) into develop (58fabba) will decrease coverage by 0.04%.
The diff coverage is 88.88%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #767      +/-   ##
===========================================
- Coverage    58.36%   58.31%   -0.05%     
===========================================
  Files          147      147              
  Lines        16833    16780      -53     
===========================================
- Hits          9824     9786      -38     
+ Misses        6084     6072      -12     
+ Partials       925      922       -3     
Impacted Files Coverage Δ
query/graphql/planner/explain.go 68.96% <ø> (ø)
query/graphql/planner/planner.go 74.83% <70.00%> (+0.57%) ⬆️
query/graphql/planner/limit.go 97.77% <91.66%> (+7.08%) ⬆️
query/graphql/mapper/mapper.go 86.90% <95.23%> (+0.15%) ⬆️
query/graphql/planner/select.go 75.00% <100.00%> (ø)

Some loss of efficiency here, I think the new limit nodes will make use of the same valuesNode (so not fetching from file twice) but not sure.  The planner should be able to optimise this better in the future by using the (bigger) limitNode as the source of the smaller limit node or something similar.
@AndrewSisley AndrewSisley force-pushed the sisley/refactor/I764-limit-rework branch from 4a40320 to 585c202 Compare August 30, 2022 18:48
@AndrewSisley
Copy link
Contributor Author

I rebased the aggregate-limit branch onto this one and can confirm that it solves the problem

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. Very straight forward and a good cleanup. I like it!

Copy link
Member

@jsimnz jsimnz 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 49b4bc0 into develop Aug 31, 2022
@AndrewSisley AndrewSisley deleted the sisley/refactor/I764-limit-rework branch August 31, 2022 14:19
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
* Add tests for one-many limits

* Simplify limit logic to make use of mapper

Some loss of efficiency here, I think the new limit nodes will make use of the same valuesNode (so not fetching from file twice) but not sure.  The planner should be able to optimise this better in the future by using the (bigger) limitNode as the source of the smaller limit node or something similar.
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/query Related to the query component 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.

Rework limit/render limit
4 participants