Skip to content

Add a strong_count method to Buffer #7568

@westonpace

Description

@westonpace

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

I have a synchronous method to encode an Array into a different format (Lance). I would like to verify this method is not accidentally cloning (as in rust clone of buffer data, a shallow copy) any Arrow buffers as I don't want to extend the lifetime of the array.

Describe the solution you'd like

I would like there to be a strong_count method on Buffer which returns the strong count of Buffer::data.

Describe alternatives you've considered

Alternatively, this could just be called ref_count since there is no concept of a "weak buffer". However, there could be such a concept in the future, and naming it strong_count has consistency with the equivalent method on Arc.

Alternatively, we could provide an accessor for data, but the fact that one hasn't been provided before, suggests to me that we want to hide this detail.

Additional context

Playing devil's advocate, a counter argument could be made that we are introducing new complexity to the abstraction that has to be maintained (e.g. what if we don't use an Arc in the future). However, the concept of a "reference count" seems inherent to the concept of a "cheaply cloneable buffer of data" so I think this is acceptable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrowChanges to the arrow crateenhancementAny new improvement worthy of a entry in the changelog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions