Skip to content

Commit 8c36903

Browse files
committed
support full API
1 parent 5921148 commit 8c36903

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

python/pyarrow/plasma.pyx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,14 @@ cdef class PlasmaClient:
370370
object_buffers[i].metadata_size))
371371
return result
372372

373-
def put(self, list value, ObjectID object_id=None):
373+
def put(self, object value, ObjectID object_id=None):
374374
"""
375375
Store a Python value into the object store.
376376
377377
Parameters
378378
----------
379-
value : list
380-
A Python object to store. Currently only lists are supported.
379+
value : object
380+
A Python object to store.
381381
object_id : ObjectID, default None
382382
If this is provided, the specified object ID will be used to refer
383383
to the object.
@@ -387,7 +387,9 @@ cdef class PlasmaClient:
387387
The object ID associated to the Python object.
388388
"""
389389
cdef ObjectID target_id = object_id if object_id else ObjectID.from_random()
390-
serialized = pyarrow.serialize(value)
390+
# TODO(pcm): Make serialization code support non-sequences and
391+
# get rid of packing the value into a list here (and unpacking in get)
392+
serialized = pyarrow.serialize([value])
391393
buffer = self.create(target_id, serialized.total_bytes)
392394
stream = pyarrow.FixedSizeBufferOutputStream(buffer)
393395
stream.set_memcopy_threads(4)
@@ -422,7 +424,8 @@ cdef class PlasmaClient:
422424
# buffers[i] is None if this object was not available within the
423425
# timeout
424426
if buffers[i]:
425-
results.append(pyarrow.deserialize(buffers[i]))
427+
value, = pyarrow.deserialize(buffers[i])
428+
results.append(value)
426429
else:
427430
results.append(ObjectNotAvailable)
428431
return results

python/pyarrow/tests/test_plasma.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,17 +274,17 @@ def test_get(self):
274274
assert results[i] is None
275275

276276
def test_put_and_get(self):
277-
value = ["hello", "world", 3, 1.0]
278-
object_id = self.plasma_client.put(value)
279-
[result] = self.plasma_client.get([object_id])
280-
assert result == value
277+
for value in [["hello", "world", 3, 1.0], None, "hello"]:
278+
object_id = self.plasma_client.put(value)
279+
[result] = self.plasma_client.get([object_id])
280+
assert result == value
281281

282-
result = self.plasma_client.get(object_id)
283-
assert result == value
282+
result = self.plasma_client.get(object_id)
283+
assert result == value
284284

285-
object_id = pa.plasma.ObjectID.from_random()
286-
[result] = self.plasma_client.get([object_id], timeout_ms=0)
287-
assert result == pa.plasma.ObjectNotAvailable
285+
object_id = pa.plasma.ObjectID.from_random()
286+
[result] = self.plasma_client.get([object_id], timeout_ms=0)
287+
assert result == pa.plasma.ObjectNotAvailable
288288

289289
def test_store_arrow_objects(self):
290290
data = np.random.randn(10, 4)

0 commit comments

Comments
 (0)