You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@arrow.apache.org by John Muehlhausen <jg...@jgm.org> on 2022/07/01 20:18:43 UTC

StreamDecoder zero-copy (?) for pre-framed contiguous Messages

If I call `Consume(std::shared_ptr<Buffer> buffer)` and it is already
pre-framed to contain (e.g.) an entire RecordBatch Message and nothing
else, will it use this Buffer in zero-copy mode when calling my
Listener::OnRecordBatchDecoded() implementation?  I.e. will data in that
RecordBatch refer directly to the original Buffer I passed in?

If not, how can we get this functionality?  I have a stream transport that
can preserve Message boundaries and yield ownership of that contiguous
memory.

Thanks,
John

Re: StreamDecoder zero-copy (?) for pre-framed contiguous Messages

Posted by John Muehlhausen <jg...@jgm.org>.
I found this in reader.h ... can't get to it through the docs unless I
missed something?
https://arrow.apache.org/docs/search.html?q=ReadRecordBatch

ARROW_EXPORT
Result<std::shared_ptr<RecordBatch>> ReadRecordBatch(
    const std::shared_ptr<Schema>& schema, const DictionaryMemo*
dictionary_memo,
    const IpcReadOptions& options, io::InputStream* stream);

On Fri, Jul 1, 2022 at 3:18 PM John Muehlhausen <jg...@jgm.org> wrote:

> If I call `Consume(std::shared_ptr<Buffer> buffer)` and it is already
> pre-framed to contain (e.g.) an entire RecordBatch Message and nothing
> else, will it use this Buffer in zero-copy mode when calling my
> Listener::OnRecordBatchDecoded() implementation?  I.e. will data in that
> RecordBatch refer directly to the original Buffer I passed in?
>
> If not, how can we get this functionality?  I have a stream transport that
> can preserve Message boundaries and yield ownership of that contiguous
> memory.
>
> Thanks,
> John
>

Re: StreamDecoder zero-copy (?) for pre-framed contiguous Messages

Posted by Sutou Kouhei <ko...@clear-code.com>.
Hi,

Yes. It's zero-copy.

See also the documentation of
arrow::ipc::StreamDecoder::next_required_size():
https://arrow.apache.org/docs/cpp/api/ipc.html#_CPPv4NK5arrow3ipc13StreamDecoder18next_required_sizeEv

Thanks,
-- 
kou

In <CA...@mail.gmail.com>
  "StreamDecoder zero-copy (?) for pre-framed contiguous Messages" on Fri, 1 Jul 2022 15:18:43 -0500,
  John Muehlhausen <jg...@jgm.org> wrote:

> If I call `Consume(std::shared_ptr<Buffer> buffer)` and it is already
> pre-framed to contain (e.g.) an entire RecordBatch Message and nothing
> else, will it use this Buffer in zero-copy mode when calling my
> Listener::OnRecordBatchDecoded() implementation?  I.e. will data in that
> RecordBatch refer directly to the original Buffer I passed in?
> 
> If not, how can we get this functionality?  I have a stream transport that
> can preserve Message boundaries and yield ownership of that contiguous
> memory.
> 
> Thanks,
> John