本文整理汇总了Python中snappy.StreamCompressor方法的典型用法代码示例。如果您正苦于以下问题:Python snappy.StreamCompressor方法的具体用法?Python snappy.StreamCompressor怎么用?Python snappy.StreamCompressor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snappy
的用法示例。
在下文中一共展示了snappy.StreamCompressor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import snappy [as 别名]
# 或者: from snappy import StreamCompressor [as 别名]
def __init__(self, infile, mode, **kwargs):
import snappy
self.details = {"size": 999999999} # not true, but OK if we don't seek
super().__init__(fs=None, path="snappy", mode=mode.strip("b") + "b", **kwargs)
self.infile = infile
if "r" in mode:
self.codec = snappy.StreamDecompressor()
else:
self.codec = snappy.StreamCompressor()
示例2: __init__
# 需要导入模块: import snappy [as 别名]
# 或者: from snappy import StreamCompressor [as 别名]
def __init__(self, socket):
self._decompressor = snappy.StreamDecompressor()
self._compressor = snappy.StreamCompressor()
super(SnappySocket, self).__init__(socket)
示例3: _write_with_snappy
# 需要导入模块: import snappy [as 别名]
# 或者: from snappy import StreamCompressor [as 别名]
def _write_with_snappy(data: bytes, stream: INetStream) -> None:
compressor = StreamCompressor()
data_reader = io.BytesIO(data)
chunk = data_reader.read(MAX_CHUNK_SIZE)
while chunk:
chunk = compressor.add_chunk(chunk)
await stream.write(chunk)
chunk = data_reader.read(MAX_CHUNK_SIZE)
示例4: __init__
# 需要导入模块: import snappy [as 别名]
# 或者: from snappy import StreamCompressor [as 别名]
def __init__(self, src_fp, algorithm, level=0):
super().__init__(src_fp, minimum_read_size=32 * 1024)
if algorithm == "lzma":
self._compressor = lzma.LZMACompressor(lzma.FORMAT_XZ, -1, level, None)
elif algorithm == "snappy":
self._compressor = snappy.StreamCompressor()
elif algorithm == "zstd":
self._compressor = zstd.ZstdCompressor(level=level).compressobj()
else:
InvalidConfigurationError("invalid compression algorithm: {!r}".format(algorithm))
示例5: __init__
# 需要导入模块: import snappy [as 别名]
# 或者: from snappy import StreamCompressor [as 别名]
def __init__(self, next_fp, mode):
if snappy is None:
raise io.UnsupportedOperation("Snappy is not available")
if mode == "rb":
self.decr = snappy.StreamDecompressor()
self.encr = None
elif mode == "wb":
self.decr = None
self.encr = snappy.StreamCompressor()
else:
raise io.UnsupportedOperation("unsupported mode for SnappyFile")
super().__init__(next_fp)
self.decr_done = False