-
Notifications
You must be signed in to change notification settings - Fork 907
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 get_element
for struct column
#8578
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
std::move(*scalar_contents)
is wrong as theunique_ptr
hasn't been informed that it doesn't have ownership anymore. I think you want:auto scalar_contents = table(std::move(row_contents.children)); std::make_unique<struct_scalar>(std::move(scalar_contents), valid, stream, mr);
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.
Not quite. The
struct_scalar
constructor needs atable&&
.The
unique_ptr
retains ownership of the "moved-from" object, which should be safe to destroy when theunique_ptr
goes out of scope. (Please correct me if I'm wrong.)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 believe you are correct. To clarify, the object (the table) being pointed to by the
std::unique_ptr<>
has had it's internal buffers emptied out, but the table held by the pointer itself still exists, so when it gets deleted, it's destructor does nothing.It is a little bit subtle though. @robertmaynard 's suggestion makes the sequence of operations a lot more clear.
As a side note, it's a little surprising the PR that added these move constructors didn't actually have any tests for 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.
Ah, I misread @robertmaynard's suggestion:
scalar_contents
is atable
, in his case.I agree. @robertmaynard's way reads better.
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.
Thanks for the comments. Moving to @robertmaynard 's suggestion.
From a lower level perspective, previously
creates a
table
object with the contents that was pointed to by theunique_ptr
and was later moved to thestruct_scalar
. After this step, theunique_ptr
still points to atable
object, but as a result of default move constructor, that object now contains 0 columns, effectively empty. It's safe forunique_ptr
to deallocate this object because thetable
object is still live, its internal_columns
field is also live, only it's empty.Agreed it's subtle compared to the new writings.