@@ -31,15 +31,16 @@ from pyarrow.includes.libarrow cimport *
3131from pyarrow.lib cimport (Buffer, Array, Schema,
3232 check_status,
3333 MemoryPool, maybe_unbox_memory_pool,
34- Table,
34+ Table, NativeFile,
3535 pyarrow_wrap_chunked_array,
3636 pyarrow_wrap_schema,
3737 pyarrow_wrap_table,
3838 pyarrow_wrap_buffer,
3939 NativeFile, get_reader, get_writer)
4040
4141from pyarrow.compat import tobytes, frombytes
42- from pyarrow.lib import ArrowException, NativeFile, _stringify_path
42+ from pyarrow.lib import (ArrowException, NativeFile, _stringify_path,
43+ BufferOutputStream)
4344from pyarrow.util import indent
4445
4546
@@ -421,11 +422,13 @@ cdef class FileMetaData:
421422 self ._metadata = metadata.get()
422423
423424 def __reduce__ (self ):
424- cdef ParquetInMemoryOutputStream sink
425+ cdef:
426+ NativeFile sink = BufferOutputStream()
427+ OutputStream* c_sink = sink.get_output_stream().get()
425428 with nogil:
426- self ._metadata.WriteTo(& sink )
429+ self ._metadata.WriteTo(c_sink )
427430
428- cdef Buffer buffer = pyarrow_wrap_buffer( sink.GetBuffer() )
431+ cdef Buffer buffer = sink.getvalue( )
429432 return _reconstruct_filemetadata, (buffer ,)
430433
431434 def __repr__ (self ):
0 commit comments