[
https://issues.apache.org/jira/browse/ARROW-317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15568916#comment-15568916
]
Wes McKinney commented on ARROW-317:
------------------------------------
This is buffer-level slicing / refcounting -- slicing an Array is more
complicated because of the null bitmap. There, it's not enough to slice the
bitmap buffer because you may fall in the middle of a byte. Array slicing will
need to be implemented via an ArrayView object of sorts that has an offset into
another array -- another idea is that all arrays could have a value offset in
memory, so if you did
```
std::shared_ptr<Array> arr_slice = arr->Slice(5);
```
Then `arr_slice` would have an offset of 5 into arr's buffers.
Buffer level slicing is much simpler since it's just bytes
{code}
class BufferView : public Buffer {
public:
...
private:
std::shared_ptr<Buffer> parent_;
int64_t offset_;
};
{code}
One option is to make {{Buffer::data}} virtual to address to deal with parent
mutation issues (so that {{BufferView::data}} returns {{parent_->data() +
offset_}})
> [C++] Implement zero-copy Slice method on arrow::Buffer that retains
> reference to parent
> ----------------------------------------------------------------------------------------
>
> Key: ARROW-317
> URL: https://issues.apache.org/jira/browse/ARROW-317
> Project: Apache Arrow
> Issue Type: New Feature
> Components: C++
> Reporter: Wes McKinney
>
> This will help prevent referenced memory from being garbage-collected while
> it is referenced by other buffers (for example, in an IPC setting, where we
> construct Arrow vectors/arrays without copying the input memory).
> Closely related to this: resizeable buffers that are referenced by other
> buffers should return error status when calling {{Resize}} (if possible).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)