-
Notifications
You must be signed in to change notification settings - Fork 64
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
Implement deep copies for the Operation
subclasses.
#1815
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1815 +/- ##
==========================================
+ Coverage 90.12% 90.19% +0.06%
==========================================
Files 399 399
Lines 38220 38399 +179
Branches 4283 4294 +11
==========================================
+ Hits 34446 34634 +188
+ Misses 2483 2470 -13
- Partials 1291 1295 +4 ☔ View full report in Codecov by Sentry. |
150a56b
to
3f8f44a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much.
I think there is some work to do to make this correct and to make it harder to break this in the future.
Haven't looked at all the tests yet, because they need some generalization (see my comments)
auto newJoin = std::make_unique<ExistsJoin>(*this); | ||
newJoin->left_ = left_->clone(); | ||
newJoin->right_ = right_->clone(); | ||
return newJoin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How much does it break if you delete the copy constructor of the Operation
base class, such that this pattern doesn't work anymore, and then always explicitly call appropriate constructors?
|
||
// _____________________________________________________________________________ | ||
std::unique_ptr<Operation> Minus::clone() const { | ||
auto copy = std::make_unique<Minus>(*this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already like this much better, we are getting there!
} | ||
return true; | ||
}; | ||
AD_CORRECTNESS_CHECK(areChildrenDifferent()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can also include expensive checks for the equality of variableToColumnMaps, sizeEstimates, multiplicities, whatNotElse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(have a look at the public interface of Operation
for inspiration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many of these don't work because their public interface is not const (even though it seems like it could be const for most of them)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The really last request:
In the unit test matcher of clone,
you can assert that the varToColMaps and Multiplicities are equal, and that (most importantly) the getResult
yields equal results.
Otherwise this is ready to merge (so you can rebase all your code that depens on it on this PR.
Conformance check passed ✅No test result changes. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much.
Operation
classOperation
subclasses.
The deep copies are implemented via an explicit
clone
methods.The reason behind this explicit method is two-fold:
shared_ptr
s to make the query planning cheaper, so we need explicit logic to recursively deep clone all the children.clone
method anyway, becauseOperation
is a virtual base class, where we need an explicitclone
method (the socalledvirtual copy constructor
idiom, to create a copy of a pointer to the virtual base class.