Clarify various RecordBatchStream{Reader,Writer} wrappers

This commit is contained in:
David Li committed 2019-02-13 10:49:38 -05:00
1 parent e1c298ad36
commit 9d5442a010
2 files changed
+21 -5

No files matched your search

+19 -3
View File
@@ -149,6 +149,14 @@ cdef class MessageReader:
# File and stream readers and writers
cdef class _CRecordBatchWriter:
"""The base RecordBatchWriter wrapper.
Provides common implementations of convenience methods. Should not
be instantiated directly by user code.
"""
# cdef block is in lib.pxd
def write(self, table_or_batch):
"""
Write RecordBatch or Table to stream
@@ -209,7 +217,7 @@ cdef class _CRecordBatchWriter:
self.close()
cdef class _RecordBatchWriter(_CRecordBatchWriter):
cdef class _RecordBatchStreamWriter(_CRecordBatchWriter):
cdef:
shared_ptr[OutputStream] sink
bint closed
@@ -245,6 +253,14 @@ cdef _get_input_stream(object source, shared_ptr[InputStream]* out):
cdef class _CRecordBatchReader:
"""The base RecordBatchReader wrapper.
Provides common implementations of convenience methods. Should not
be instantiated directly by user code.
"""
# cdef block is in lib.pxd
def __iter__(self):
while True:
yield self.read_next_batch()
@@ -280,7 +296,7 @@ cdef class _CRecordBatchReader:
return pyarrow_wrap_table(table)
cdef class _RecordBatchReader(_CRecordBatchReader):
cdef class _RecordBatchStreamReader(_CRecordBatchReader):
cdef:
shared_ptr[InputStream] in_stream
@@ -299,7 +315,7 @@ cdef class _RecordBatchReader(_CRecordBatchReader):
self.schema = pyarrow_wrap_schema(self.reader.get().schema())
cdef class _RecordBatchFileWriter(_RecordBatchWriter):
cdef class _RecordBatchFileWriter(_RecordBatchStreamWriter):
def _open(self, sink, Schema schema):
get_writer(sink, &self.sink)
+2 -2
View File
@@ -45,7 +45,7 @@ class _ReadPandasOption(object):
return table.to_pandas(**options)
class RecordBatchStreamReader(lib._RecordBatchReader, _ReadPandasOption):
class RecordBatchStreamReader(lib._RecordBatchStreamReader, _ReadPandasOption):
"""
Reader for the Arrow streaming binary format
@@ -58,7 +58,7 @@ class RecordBatchStreamReader(lib._RecordBatchReader, _ReadPandasOption):
self._open(source)
class RecordBatchStreamWriter(lib._RecordBatchWriter):
class RecordBatchStreamWriter(lib._RecordBatchStreamWriter):
"""
Writer for the Arrow streaming binary format