本文整理匯總了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