Skip to content

Conversation

@tustvold
Copy link
Contributor

Which issue does this PR close?

Closes #.

Rationale for this change

Follow up to #6790

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Nov 29, 2024
@alamb
Copy link
Contributor

alamb commented Dec 1, 2024

FYI @emilk

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @tustvold -- makes sense to me

fn dangling_ptr() -> NonNull<u8> {
pub(crate) fn dangling_ptr() -> NonNull<u8> {
// SAFETY: ALIGNMENT is a non-zero usize which is then casted
// to a *mut T. Therefore, `ptr` is not null and the conditions for
Copy link
Contributor

Choose a reason for hiding this comment

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

Not introduced in this PR, but this function isn't generic, so I am not sure what *mut T is talking about

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is a copy-pasta from NonNull::dangling


#[inline]
fn dangling_ptr() -> NonNull<u8> {
pub(crate) fn dangling_ptr() -> NonNull<u8> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest adding some some comments about this function given its name.

Specifically, that it returns a valid, u8 pointer that is valid for the entire life of the process. Suitable for allocations of 0 length.

I realize it wasn't introduced in this PR, but the name is confusing to me -- Maybe calling it arbtrary_ptr() or something would be less confusing 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah dangling is an odd name, but is based on what the standard library calls it. I have added some docs to this effect

@tustvold tustvold merged commit 7247e6b into apache:main Dec 1, 2024
26 checks passed
emilk pushed a commit to rerun-io/arrow-rs that referenced this pull request Jan 10, 2025
* Support shrink to empty

* Docs

* Format
alamb pushed a commit that referenced this pull request Jan 13, 2025
* Add `Array::shrink_to_fit(&mut self)` (#6790)

* Add `Array::shrink_to_fit`

* Test that shrink_to_fit actually frees memory

* Make sure the buffer isn't shared in the test of shrink_to_fit

* Remove `#[inline]`

* Use `realloc` to reallocate the bytes

* Clean up test

* Improve docstring for `Array::shrink_to_fit`

Co-authored-by: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com>

* `Buffer::shrink_to_fit`: ignore shared buffers

* Improve comment in `ArrayRef::shrink_to_fit`

* Document why `try_realloc` is safe, and actually make it safe :)

* Improve testing of shrink_to_fit

* Fix a few corner cases, and improve test

* Add license header to new test file

---------

Co-authored-by: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com>

* Support shrink to empty (#6817)

* Support shrink to empty

* Docs

* Format

---------

Co-authored-by: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants