是否有任何主流压缩算法本身支持流数据 [英] Does any mainstream compression algorithm natively support streaming data
问题描述
执行任何主流压缩算法,例如 snappy , zlib 或 bzip 本机支持通过网络流传输数据?例如,如果我必须发送压缩的有效负载,那么在发送消息之前,是否需要手动添加有效负载的大小?还是有任何库提供API来告知给定 x
个字节是否消息完整?
Does any mainstream compression algorithm, for example either snappy, zlib or bzip natively support streaming data across the network? For example if I have to send a compressed payload, then will I have to manually prepend the size of the payload before sending the message? Or does any library provide the API to tell whether a message is complete given x
bytes?
推荐答案
zlib,bzip2,lz4,zstd,brotli,lzma2和其他许多文件都通过在压缩数据中使用数据结尾标记来支持流传输。
zlib, bzip2, lz4, zstd, brotli, lzma2, and many others all support streaming through the use of an end-of-data marker in the compressed data.
碰巧的是,您提到的其中一种快照式(snappy)不能按照您的要求进行流式传输,因为格式以未压缩的大小开头。
As it happens, one of the ones you mentioned, snappy, is not streamable in the sense you ask, since the format starts with an uncompressed size.
这篇关于是否有任何主流压缩算法本身支持流数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!