本文整理汇总了Python中mapper.Mapper.map_stor方法的典型用法代码示例。如果您正苦于以下问题:Python Mapper.map_stor方法的具体用法?Python Mapper.map_stor怎么用?Python Mapper.map_stor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapper.Mapper
的用法示例。
在下文中一共展示了Mapper.map_stor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Store
# 需要导入模块: from mapper import Mapper [as 别名]
# 或者: from mapper.Mapper import map_stor [as 别名]
class Store(object):
"""Store.
Required constructor parameters: path, block_size, hash_algorithm,
blockpool, mappool.
"""
def __init__(self, **params):
pb = {'blocksize': params['block_size'],
'hashtype': params['hash_algorithm'],
'archipelago_cfile': params['archipelago_cfile'],
}
self.blocker = Blocker(**pb)
pm = {'namelen': self.blocker.hashlen,
'hashtype': params['hash_algorithm'],
'archipelago_cfile': params['archipelago_cfile'],
}
self.mapper = Mapper(**pm)
def map_get(self, name, size):
return self.mapper.map_retr(name, size)
def map_put(self, name, map, size, block_size):
self.mapper.map_stor(name, map, size, block_size)
def map_delete(self, name):
pass
def map_copy(self, dst, src, size):
self.mapper.map_copy(dst, src, size)
def block_get(self, hash):
blocks = self.blocker.block_retr((hash,))
if not blocks:
return None
return blocks[0]
def block_get_archipelago(self, hash):
blocks = self.blocker.block_retr_archipelago((hash,))
if not blocks:
return None
return blocks[0]
def block_put(self, data):
hashes, absent = self.blocker.block_stor((data,))
return hashes[0]
def block_update(self, hash, offset, data):
h, e = self.blocker.block_delta(hash, offset, data)
return h
def block_search(self, map):
return self.blocker.block_ping(map)
示例2: Store
# 需要导入模块: from mapper import Mapper [as 别名]
# 或者: from mapper.Mapper import map_stor [as 别名]
class Store(object):
"""Store.
Required constructor parameters: path, block_size, hash_algorithm,
umask, blockpool, mappool.
"""
def __init__(self, **params):
umask = params['umask']
if umask is not None:
os.umask(umask)
path = params['path']
if path and not os.path.exists(path):
os.makedirs(path)
if not os.path.isdir(path):
raise RuntimeError("Cannot open path '%s'" % (path,))
p = {'blocksize': params['block_size'],
'blockpath': os.path.join(path + '/blocks'),
'hashtype': params['hash_algorithm'],
'blockpool': params['blockpool']}
self.blocker = Blocker(**p)
p = {'mappath': os.path.join(path + '/maps'),
'namelen': self.blocker.hashlen,
'mappool': params['mappool']}
self.mapper = Mapper(**p)
def map_get(self, name):
return self.mapper.map_retr(name)
def map_put(self, name, map):
self.mapper.map_stor(name, map)
def map_delete(self, name):
pass
def block_get(self, hash):
blocks = self.blocker.block_retr((hash,))
if not blocks:
return None
return blocks[0]
def block_put(self, data):
hashes, absent = self.blocker.block_stor((data,))
return hashes[0]
def block_update(self, hash, offset, data):
h, e = self.blocker.block_delta(hash, offset, data)
return h
def block_search(self, map):
return self.blocker.block_ping(map)
示例3: Store
# 需要导入模块: from mapper import Mapper [as 别名]
# 或者: from mapper.Mapper import map_stor [as 别名]
class Store(object):
"""Store.
Required constructor parameters: path, block_size, hash_algorithm,
umask, blockpool, mappool.
"""
def __init__(self, **params):
(pb, pm) = bootstrap_backend_storage(**params)
self.blocker = Blocker(**pb)
self.mapper = Mapper(**pm)
def map_get(self, name):
return self.mapper.map_retr(name)
def map_put(self, name, map):
self.mapper.map_stor(name, map)
def map_delete(self, name):
pass
def block_get(self, hash):
blocks = self.blocker.block_retr((hash,))
if not blocks:
return None
return blocks[0]
def block_put(self, data):
hashes, absent = self.blocker.block_stor((data,))
return hashes[0]
def block_update(self, hash, offset, data):
h, e = self.blocker.block_delta(hash, offset, data)
return h
def block_search(self, map):
return self.blocker.block_ping(map)