def get(self, fp, off=0, size=-1): """ Get object by `fingerprint` - Throws `ObjectNotFound` RADOS exception, if no object with that fingerprint exists - Return decompressed object - Return the whole object by default - If you specify `off` and `size` it is applied only after fetching the whole object """ self.log.debug("GET [%r]: %s:%s", fp, off, size) obj_size, _ = self.ioctx.stat(fp) compression_id = CAS._convert_meta(self.ioctx.get_xattr(fp, "cas.meta.compression")) decompressor = Compressor.select(compression_id) self.log.debug("GET [%r]: size %d compressed with %r", fp, obj_size, compression_id) compressed_data = self.ioctx.read(fp, obj_size, 0) data = decompressor.decompress(compressed_data) if size < 0: size = len(data) return data[off:off+size]
def get(self, fp, off=0, size=-1): """ Get object by `fingerprint` - Throws `ObjectNotFound` RADOS exception, if no object with that fingerprint exists - Return decompressed object - Return the whole object by default - If you specify `off` and `size` it is applied only after fetching the whole object """ self.log.debug("GET [%r]: %s:%s", fp, off, size) obj_size, _ = self.ioctx.stat(fp) compression_id = CAS._convert_meta( self.ioctx.get_xattr(fp, "cas.meta.compression")) decompressor = Compressor.select(compression_id) self.log.debug("GET [%r]: size %d compressed with %r", fp, obj_size, compression_id) compressed_data = self.ioctx.read(fp, obj_size, 0) data = decompressor.decompress(compressed_data) if size < 0: size = len(data) return data[off:off + size]
def __init__(self, ioctx, compression="no"): """ Initialize CAS object. Caller needs to provide a connected and initialized RADOS I/O context. CAS objects need their own, exclusive RADOS I/O Context, since they operate on objects in an extra namespace. On initialization you can also specify the compression algorithm for **new** objects. CAS never overwrites objects that already exists, but rather increments their reference count. Existing objects have metadata to select the right decompressor on `get`. """ self.ioctx = ioctx self.ioctx.set_namespace("CAS") self.compressor = Compressor.select(compression)
def __init__(self, ioctx, compression="no"): """ Initialize CAS object. Caller needs to provide a connected and initialized RADOS I/O context. CAS objects need their own, exclusive RADOS I/O Context, since they operate on objects in an extra namespace. On initialization you can also specify the compression algorithm for **new** objects. CAS never overwrites objects that already exists, but rather increments their reference count. Existing objects have metadata to select the right decompressor on `get`. """ self.ioctx = ioctx self.ioctx.set_namespace("CAS") self.compressor = Compressor.select(compression)