You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@arrow.apache.org by Rares Vernica <rv...@gmail.com> on 2017/09/11 03:48:06 UTC

Reuse Buffer or BufferOutputStream

Hi,

During the life of the program, can/should the Buffer or BufferOutputStream
be resused?

If the data in them is no longer needed, can they be reset? Or should I not
worry about this as they get out of scope and just create new instances?
What is the intended pattern?

Thanks!
Rares

Re: Reuse Buffer or BufferOutputStream

Posted by Wes McKinney <we...@gmail.com>.
It depends (I assume this is Python we are talking about).

The BufferOutputStream is single use -- you write a stream and then
get the result as a Buffer (BufferOutputStream.get_result). Same in
C++. In principle we could add a reset method:
https://issues.apache.org/jira/browse/ARROW-1521

You can reuse a mutable Buffer in some circumstances. The new
pyarrow.allocate_buffer function in 0.7.0 allocates a fixed size
mutable buffer of a certain size. The FixedSizeBufferWriter class can
write to such a buffer. Many buffers are immutable, though, and so you
can discard them when you are done.

- Wes

On Sun, Sep 10, 2017 at 11:48 PM, Rares Vernica <rv...@gmail.com> wrote:
> Hi,
>
> During the life of the program, can/should the Buffer or BufferOutputStream
> be resused?
>
> If the data in them is no longer needed, can they be reset? Or should I not
> worry about this as they get out of scope and just create new instances?
> What is the intended pattern?
>
> Thanks!
> Rares