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

feat: growable buffer move_to method #2178

Merged
merged 1 commit into from
Jan 31, 2023
Merged

Conversation

ianna
Copy link
Collaborator

@ianna ianna commented Jan 31, 2023

  • growable buffer move_to method implementation and test
  • growable buffer clear method bug fix
  • more thorough checks in the tests

@codecov
Copy link

codecov bot commented Jan 31, 2023

Codecov Report

Merging #2178 (1096065) into main (a91d96b) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

@ianna ianna temporarily deployed to docs-preview January 31, 2023 10:32 — with GitHub Actions Inactive
@ianna ianna requested a review from jpivarski January 31, 2023 11:05
Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

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

I've always been a little confused about what std::move does. It seems pretty clear (in this example and others) that it copies data.

What's the difference between this new move_to function and the old concatenate_to function? Don't they both copy the panel data into an externally provided buffer and delete the panels?

I'm fine with making these changes (you can merge it when you're happy with it). I'm just asking.

@@ -408,6 +414,7 @@ namespace awkward {
panel_ = std::move(std::unique_ptr<Panel<PRIMITIVE>>(
new Panel<PRIMITIVE>((size_t)options_.initial())));
ptr_ = panel_.get();
length_ = 0;
}
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a bug-fix. Is it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've always been a little confused about what std::move does. It seems pretty clear (in this example and others) that it copies data.

I can chime in here! std::move just indicates to the compiler that the argument can be moved from, i.e. a consumer of the std::move(...) could avoid a copy by moving from the argument. So, it doesn't always eliminate a copy, depending upon how it is consumed. It's just a signal of lifetime intent IIRC.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This looks like a bug-fix. Is it?

Yes, it is.

@ianna
Copy link
Collaborator Author

ianna commented Jan 31, 2023

I've always been a little confused about what std::move does. It seems pretty clear (in this example and others) that it copies data.

What's the difference between this new move_to function and the old concatenate_to function? Don't they both copy the panel data into an externally provided buffer and delete the panels?

The concatenate_to does not delete the panels. One has to call clean to do that. We can change it, I think. Then there will be just one method.

I'm fine with making these changes (you can merge it when you're happy with it). I'm just asking.

@ianna ianna merged commit fb205ac into main Jan 31, 2023
@ianna ianna deleted the ianna/growable-buffer-move-method branch January 31, 2023 19:13
@jpivarski
Copy link
Member

It would be nice if there were only one method. That way, developers don't have to guess which one to use.

Separating the functions of "copy the data out into a contiguous buffer" and "remove the panels" would keep more use-cases open. Maybe there's reason to clear the panels without copying out the data (user initiates a reset), and maybe there's a reason to copy the data out and keep filling (the original "snapshot" idea).

If clear is already a method, maybe move_to could take a boolean argument, specifying whether to clear after copying? Then, with move_to reproducing concatenate_to's functionality, it should then become concatenate_to, since we've already given out instructions on how to copy out the data, and they use the concatenate_to spelling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants