Skip to content

Commit 4c40bf2

Browse files
committed
Adapt Python bindings
1 parent 769974a commit 4c40bf2

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

cpp/src/parquet/api/reader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
#include "parquet/exception.h"
2525
#include "parquet/file_reader.h"
2626
#include "parquet/metadata.h"
27+
#include "parquet/platform.h"
2728
#include "parquet/printer.h"
29+
#include "parquet/properties.h"
2830

2931
// Schemas
3032
#include "parquet/api/schema.h"

python/pyarrow/_parquet.pxd

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ cdef extern from "parquet/api/reader.h" namespace "parquet" nogil:
229229
unique_ptr[CRowGroupMetaData] RowGroup(int i)
230230
const SchemaDescriptor* schema()
231231
shared_ptr[const CKeyValueMetadata] key_value_metadata() const
232-
void WriteTo(ParquetOutputStream* dst) const
232+
void WriteTo(OutputStream* dst) const
233233

234234
cdef shared_ptr[CFileMetaData] CFileMetaData_Make \
235235
" parquet::FileMetaData::Make"(const void* serialized_metadata,
@@ -253,13 +253,6 @@ cdef extern from "parquet/api/reader.h" namespace "parquet" nogil:
253253

254254

255255
cdef extern from "parquet/api/writer.h" namespace "parquet" nogil:
256-
cdef cppclass ParquetOutputStream" parquet::OutputStream":
257-
pass
258-
259-
cdef cppclass ParquetInMemoryOutputStream \
260-
" parquet::InMemoryOutputStream"(ParquetOutputStream):
261-
shared_ptr[CBuffer] GetBuffer()
262-
263256
cdef cppclass WriterProperties:
264257
cppclass Builder:
265258
Builder* version(ParquetVersion version)

python/pyarrow/_parquet.pyx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ from pyarrow.includes.libarrow cimport *
3131
from 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

4141
from 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)
4344
from 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

Comments
 (0)