@@ -26,6 +26,7 @@ from libcpp.vector cimport vector as c_vector
2626from libc.stdint cimport int64_t, uint8_t, uintptr_t
2727from cpython.pycapsule cimport *
2828
29+ import collections
2930import pyarrow
3031
3132from pyarrow.lib cimport Buffer, NativeFile, check_status, SerializedPyObject
@@ -43,6 +44,9 @@ cdef extern from "plasma/common.h" nogil:
4344 @staticmethod
4445 CUniqueID from_binary(const c_string& binary)
4546
47+ @staticmethod
48+ CUniqueID from_random()
49+
4650 c_bool operator== (const CUniqueID& rhs) const
4751
4852 c_string hex () const
@@ -161,9 +165,8 @@ cdef class ObjectID:
161165
162166 @staticmethod
163167 def from_random ():
164- cdef ObjectID result
165- result.data = CUniqueID.from_random()
166- return result
168+ cdef CUniqueID data = CUniqueID.from_random()
169+ return ObjectID(data.binary())
167170
168171
169172cdef class ObjectNotAvailable:
@@ -652,13 +655,16 @@ def get(PlasmaClient client, object_ids, timeout_ms=-1):
652655 List of Python values for the data associated with the object_ids
653656 and ObjectNotAvailable if the object was not available.
654657 """
655- results = []
656- buffers = client.get(object_ids, timeout_ms)
657- for i in range (len (object_ids)):
658- # buffers[i] is None if this object was not available within the
659- # timeout
660- if buffers[i]:
661- results.append(pyarrow.deserialize(buffers[i]))
662- else :
663- results.append(ObjectNotAvailable)
664- return results
658+ if isinstance (object_ids, collections.Sequence):
659+ results = []
660+ buffers = client.get(object_ids, timeout_ms)
661+ for i in range (len (object_ids)):
662+ # buffers[i] is None if this object was not available within the
663+ # timeout
664+ if buffers[i]:
665+ results.append(pyarrow.deserialize(buffers[i]))
666+ else :
667+ results.append(ObjectNotAvailable)
668+ return results
669+ else :
670+ return get(client, [object_ids], timeout_ms)[0 ]
0 commit comments