implement serialization using numbuf

This commit is contained in:
Philipp Moritz
2016-04-26 15:14:04 -07:00
parent f10c74e47d
commit 8d0c3be28f
8 changed files with 73 additions and 256 deletions
+11 -10
View File
@@ -1,6 +1,7 @@
from types import ModuleType
import typing
import numpy as np
import pynumbuf
import orchpy
import serialization
@@ -14,11 +15,11 @@ class Worker(object):
def put_object(self, objref, value):
"""Put `value` in the local object store with objref `objref`. This assumes that the value for `objref` has not yet been placed in the local object store."""
# if type(value) == np.ndarray:
# orchpy.lib.put_arrow(self.handle, objref, value)
# else:
object_capsule, contained_objrefs = serialization.serialize(self.handle, value) # contained_objrefs is a list of the objrefs contained in object_capsule
orchpy.lib.put_object(self.handle, objref, object_capsule, contained_objrefs)
if pynumbuf.serializable(value):
orchpy.lib.put_arrow(self.handle, objref, value)
else:
object_capsule, contained_objrefs = serialization.serialize(self.handle, value) # contained_objrefs is a list of the objrefs contained in object_capsule
orchpy.lib.put_object(self.handle, objref, object_capsule, contained_objrefs)
def get_object(self, objref):
"""
@@ -27,11 +28,11 @@ class Worker(object):
WARNING: get_object can only be called on a canonical objref.
"""
# if orchpy.lib.is_arrow(self.handle, objref):
# return orchpy.lib.get_arrow(self.handle, objref)
# else:
object_capsule = orchpy.lib.get_object(self.handle, objref)
return serialization.deserialize(self.handle, object_capsule)
if orchpy.lib.is_arrow(self.handle, objref):
return orchpy.lib.get_arrow(self.handle, objref)
else:
object_capsule = orchpy.lib.get_object(self.handle, objref)
return serialization.deserialize(self.handle, object_capsule)
def alias_objrefs(self, alias_objref, target_objref):
"""Make `alias_objref` refer to the same object that `target_objref` refers to."""