-
Notifications
You must be signed in to change notification settings - Fork 60
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
Add a parameter cloneRelations
for clone
to be able not to clone the collections
#609
Conversation
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 would argue this is intended behavior. Cloning specifically only copies the data and leaves the relations alone. Hence, it is technically user responsibility to fix up the relations. Mainly because there is no way to solve this in all generality.
I am also not entirely sure if the tests would still be working if they are done with the immutable objects. Because in that case clone
default initializes the ObjectID
, which is {untracked, untracked}
.
tests/unittests/unittest.cpp
Outdated
coll.create(); | ||
coll[0].addparents(coll[0]); | ||
coll[0].adddaughters(coll[1]); | ||
coll[0].adddaughters(coll[0]); |
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.
This is its own daughter? Does this test still work if this is removed? I don't see a reason why it wouldn't but it looks a bit odd, IMHO.
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.
It works. Adding the object itself to the relation is also a possible test case maybe different from adding something else
The workflow for keeping the relations as they are in a cloned collection seems too complicated then:
This makes merging collections and wanting to use them as if they were "original" ones quite cumbersome, no? Allowing the pointers to be different allows an original and cloned object to diverge and still compare to true, even if the data is the same (which is not checked for in the PR but probably should) then the relations could be different.
This I didn't understand but I made some changes in |
That is a good point, actually. I didn't think of that. So we would definitely need the possibility for the I think if the purpose is to clone a complete collection, then the functionality should be implemented on the collection level, no? E.g. if you clone a MCParticle might be a special case here because usually there is exactly one of those per event and it is self-contained, so cloning that can be handled accordingly. However, that would then belong to the EDM and not in podio, because podio can't know about these special cases.
This will just make things extremely complicated I think, because you have to keep track of quite a few things. Currently the user facing classes are rather simple handles and as long as the
What I meant was something like this: const auto& coll = frame.get<ExampleMCCollection>("mcparticles"); // <-- Mainly for getting a const& to a collection
auto par = coll[0]; // <-- immutable
auto dau = coll[1];
auto cPar = par.clone();
auto cDau = dau.clone();
REQUIRE(cPar.daughters()[0] == cDau); // <-- does this still work? |
I have added a parameter to clone without the relations. Having a look at this I think Mutable types being able to change the relations is not needed; the use case we were discussing here would be after cloning the object since you would have relations to "old" objects. However, with the new parameter when cloning this shouldn't be necessary (or at least I don't know which other use case would require this) and it's cleaner to use For the future, I have been thinking about a |
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 think the PR title and the release notes also need an update to match what is actually done here, right?
84df435
to
07021a4
Compare
cloneRelations
for clone
to be able not to clone the collections
I added a small figure that at least schematically shows what is happening plus a few sentences, such that there is at least a tiny bit of documentation together with this feature. I would wait for CI to pass and the merge this. |
BEGINRELEASENOTES
cloneRelations
for theclone
method of the user facing handle classes to be able to clone without the relation information.ENDRELEASENOTES
See this comment and this comment