You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Stephen Toub (JIRA)" <ji...@apache.org> on 2019/02/28 18:43:00 UTC

[jira] [Created] (ARROW-4718) Add ArrowStreamWriter/Reader ctors that leave open the underlying Stream

Stephen Toub created ARROW-4718:
-----------------------------------

             Summary: Add ArrowStreamWriter/Reader ctors that leave open the underlying Stream
                 Key: ARROW-4718
                 URL: https://issues.apache.org/jira/browse/ARROW-4718
             Project: Apache Arrow
          Issue Type: Improvement
          Components: C#
            Reporter: Stephen Toub


It's often the case that data being read/written in arrow format is part of some larger protocol.  However, ArrowStreamWriter and ArrowStreamReader close the provided stream when they're disposed.  This means that if you need to, for example, write a footer after the arrow data is written, you need to actually construct the ArrowStreamWriter around some temporary stream, write to that, then copy the data from that stream to the actual one that you then write the footer to; otherwise, ArrowStreamWriter will end up disposing of the stream before you have the opportunity to write the footer.

Throughout .NET, this approach is generally codified as a ctor that takes a "leaveOpen" Boolean parameter, e.g. as on System.IO.StreamWriter (https://docs.microsoft.com/en-us/dotnet/api/system.io.streamwriter.-ctor?view=netframework-4.7.2#System_IO_StreamWriter__ctor_System_IO_Stream_System_Text_Encoding_System_Int32_System_Boolean_) or System.IO.DeflateStream (https://docs.microsoft.com/en-us/dotnet/api/system.io.compression.deflatestream.-ctor?view=netframework-4.7.2#System_IO_Compression_DeflateStream__ctor_System_IO_Stream_System_IO_Compression_CompressionLevel_System_Boolean_).

 

ArrowStreamReader and ArrowStreamWriter should do the same:

public ArrowStreamReader(Stream stream, bool leaveOpen);

public ArrowStreamWriter(Stream baseStream, Schema schema, bool leaveOpen);



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)