Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-4718

Add ArrowStreamWriter/Reader ctors that leave open the underlying Stream

    XMLWordPrintableJSON

Details

    Description

      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);

      Attachments

        Issue Links

          Activity

            People

              stephentoub Stephen Toub
              stephentoub Stephen Toub
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 20m
                  1h 20m