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 2018/01/05 03:33:09 UTC

[arrow] branch master updated: ARROW-1919: [Plasma] Test that object ids are 20 bytes

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 0115e93  ARROW-1919: [Plasma] Test that object ids are 20 bytes
0115e93 is described below

commit 0115e93c9d891a1973f023645435866eb77cb420
Author: Philipp Moritz <pc...@gmail.com>
AuthorDate: Thu Jan 4 22:33:04 2018 -0500

    ARROW-1919: [Plasma] Test that object ids are 20 bytes
    
    Author: Philipp Moritz <pc...@gmail.com>
    
    Closes #1421 from pcmoritz/plasma-object-ids and squashes the following commits:
    
    fc779087 [Philipp Moritz] fixes
    9f613c0d [Philipp Moritz] fix windows test
    f1d7ca05 [Philipp Moritz] fix linting
    6be7f4a9 [Philipp Moritz] Test that object ids are 20 bytes
---
 python/pyarrow/plasma.pyx           |  3 +++
 python/pyarrow/tests/test_plasma.py | 10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/python/pyarrow/plasma.pyx b/python/pyarrow/plasma.pyx
index abeec32..29e233b 100644
--- a/python/pyarrow/plasma.pyx
+++ b/python/pyarrow/plasma.pyx
@@ -136,6 +136,9 @@ cdef class ObjectID:
         CUniqueID data
 
     def __cinit__(self, object_id):
+        if not isinstance(object_id, bytes) or len(object_id) != 20:
+            raise ValueError("Object ID must by 20 bytes,"
+                             " is " + str(object_id))
         self.data = CUniqueID.from_binary(object_id)
 
     def __richcmp__(ObjectID self, ObjectID object_id, operation):
diff --git a/python/pyarrow/tests/test_plasma.py b/python/pyarrow/tests/test_plasma.py
index decdc73..9ea6476 100644
--- a/python/pyarrow/tests/test_plasma.py
+++ b/python/pyarrow/tests/test_plasma.py
@@ -362,7 +362,7 @@ class TestPlasmaClient(object):
         # Read the DataFrame.
         [data] = self.plasma_client.get_buffers([object_id])
         reader = pa.RecordBatchStreamReader(pa.BufferReader(data))
-        result = reader.get_next_batch().to_pandas()
+        result = reader.read_next_batch().to_pandas()
 
         pd.util.testing.assert_frame_equal(df, result)
 
@@ -747,3 +747,11 @@ class TestPlasmaClient(object):
         with pytest.raises(pa.lib.PlasmaStoreFull):
             create_object(self.plasma_client, DEFAULT_PLASMA_STORE_MEMORY + 1,
                           0)
+
+
+@pytest.mark.plasma
+def test_object_id_size():
+    import pyarrow.plasma as plasma
+    with pytest.raises(ValueError):
+        plasma.ObjectID("hello")
+    plasma.ObjectID(20 * b"0")

-- 
To stop receiving notification emails like this one, please contact
['"commits@arrow.apache.org" <co...@arrow.apache.org>'].