You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2017/01/27 03:12:26 UTC

arrow git commit: ARROW-514: [Python] Automatically wrap pyarrow.io.Buffer in BufferReader

Repository: arrow
Updated Branches:
  refs/heads/master aac2e70c1 -> 30bb0d97d


ARROW-514: [Python] Automatically wrap pyarrow.io.Buffer in BufferReader

Author: Wes McKinney <we...@twosigma.com>

Closes #306 from wesm/ARROW-514 and squashes the following commits:

d5e3235 [Wes McKinney] Automatically wrap pyarrow.io.Buffer when passing in to FileReader or StreamReader


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/30bb0d97
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/30bb0d97
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/30bb0d97

Branch: refs/heads/master
Commit: 30bb0d97d584b65ad6ed8ab225c5c4008eafb88c
Parents: aac2e70
Author: Wes McKinney <we...@twosigma.com>
Authored: Thu Jan 26 22:12:19 2017 -0500
Committer: Wes McKinney <we...@twosigma.com>
Committed: Thu Jan 26 22:12:19 2017 -0500

----------------------------------------------------------------------
 python/pyarrow/io.pyx            | 2 ++
 python/pyarrow/tests/test_ipc.py | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/30bb0d97/python/pyarrow/io.pyx
----------------------------------------------------------------------
diff --git a/python/pyarrow/io.pyx b/python/pyarrow/io.pyx
index 0755ed8..e5f8b7a 100644
--- a/python/pyarrow/io.pyx
+++ b/python/pyarrow/io.pyx
@@ -526,6 +526,8 @@ cdef get_reader(object source, shared_ptr[ReadableFileInterface]* reader):
 
     if isinstance(source, six.string_types):
         source = MemoryMappedFile(source, mode='r')
+    elif isinstance(source, Buffer):
+        source = BufferReader(source)
     elif not isinstance(source, NativeFile) and hasattr(source, 'read'):
         # Optimistically hope this is file-like
         source = PythonFileInterface(source, mode='r')

http://git-wip-us.apache.org/repos/asf/arrow/blob/30bb0d97/python/pyarrow/tests/test_ipc.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/tests/test_ipc.py b/python/pyarrow/tests/test_ipc.py
index 819d1b7..8ca464f 100644
--- a/python/pyarrow/tests/test_ipc.py
+++ b/python/pyarrow/tests/test_ipc.py
@@ -36,7 +36,7 @@ class MessagingTest(object):
         return io.BytesIO()
 
     def _get_source(self):
-        return self.sink.getvalue()
+        return pa.BufferReader(self.sink.getvalue())
 
     def write_batches(self):
         nrows = 5
@@ -74,7 +74,7 @@ class TestFile(MessagingTest, unittest.TestCase):
         batches = self.write_batches()
         file_contents = self._get_source()
 
-        reader = pa.FileReader(pa.BufferReader(file_contents))
+        reader = pa.FileReader(file_contents)
 
         assert reader.num_record_batches == len(batches)
 
@@ -92,7 +92,7 @@ class TestStream(MessagingTest, unittest.TestCase):
     def test_simple_roundtrip(self):
         batches = self.write_batches()
         file_contents = self._get_source()
-        reader = pa.StreamReader(pa.BufferReader(file_contents))
+        reader = pa.StreamReader(file_contents)
 
         total = 0
         for i, next_batch in enumerate(reader):