You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Mars storage needs to handle both memory and disk, we can define a abstract base class StorageBackend and implements backends like plasma, filesystem, vineyard, etc.
API
StorageBackend defines as below:
classStorageBackend(ABC):
@classmethod@abstractmethodasyncdefsetup(cls, **kwargs) ->Tuple[Dict, Dict]:
""" Setup environments, for example, start plasma store for plasma backend. Parameters ---------- kwargs : kwargs Kwargs for setup. Returns ------- Tuple of two dicts Dicts for initialization and teardown. """@staticmethodasyncdefteardown(**kwargs):
""" Clean up the environments. Parameters ---------- kwargs : kwargs Parameters for clean up. """@property@abstractmethoddeflevel(self):
""" Level of current storage backend. Returns ------- Level: str storage level. """@abstractmethodasyncdefget(self, object_id, **kwargs) ->object:
""" Get object by key. For some backends, `columns` or `slice` can pass to get part of data. Parameters ---------- object_id : object id Object id to get. kwargs: Additional keyword arguments Returns ------- Python object """@abstractmethodasyncdefput(self, obj, importance=0) ->ObjectInfo:
""" Put object into storage with object_id. Parameters ---------- obj : python object Object to put. importance: int The priority to spill when storage is full Returns ------- ObjectInfo object information including size, raw_size, device """@abstractmethodasyncdefdelete(self, object_id):
""" Delete object from storage by object_id. Parameters ---------- object_id object id """@abstractmethodasyncdefobject_info(self, object_id) ->ObjectInfo:
""" Get information about stored object. Parameters ---------- object_id object id Returns ------- ObjectInfo Object info including size, device and etc. """@abstractmethodasyncdefopen_writer(self, size=None) ->StorageFileObject:
""" Return a file-like object for writing. Parameters ---------- size: int Maximum size in bytes Returns ------- fileobj: StorageFileObject """@abstractmethodasyncdefopen_reader(self, object_id) ->StorageFileObject:
""" Return a file-like object for reading. Parameters ---------- object_id Object id Returns ------- fileobj: StorageFileObject """asyncdeflist(self) ->List:
""" List all stored objects in storage. Returns ------- List of objects """asyncdefprefetch(self, object_id):
""" Fetch object to current worker. Parameters ---------- object_id Object id. """asyncdefpin(self, object_id):
""" Pin the data to prevent the data being released or spilled. Parameters ---------- object_id object id """asyncdefunpin(self, object_id):
""" Unpin the data, allow storage to release the data. Parameters ---------- object_id object id """
Currently, Mars storage needs to handle both memory and disk, we can define a abstract base class
StorageBackend
and implements backends like plasma, filesystem, vineyard, etc.API
StorageBackend defines as below:
the definition of
StorageLevel
:if the storage could handle both memory and disk, the level can be expressed as
StorageLevel.MEMORY & StorageLevel.DISK
.The text was updated successfully, but these errors were encountered: