DataSet 或任何 .Net 对象的压缩/解压缩
我正在开发一个 WPF 应用程序,我想在其中加密和压缩重型数据集或对象(<2MB)并通过网络发送它。对方将数据解压、解密并消费。这个过程将在服务器(WCF)到客户端以及客户端到服务器的两侧进行。
- 我想要高效的压缩类(想坚持使用 .Net 压缩类)。
- 压缩和解压缩所需的时间更少。
- 压缩率高,数据检索应为100%。
任何人都可以建议我有关压缩类(DeflateStream/GzipStream)的信息。
谢谢
维杰
I'm developing a WPF App, in which I want to encrypt and compress heavy DataSet or Objects (<2MB) and send it across over the network. The other party would decompress and decrypt the data and consume it. This process will be on both sides from Server(WCF) to Client and Client to Server.
- I want efficient Compression Class (would like to stick to .Net compression classes).
- Takes less time to compress and decompress.
- compress ratio high while data retrieval should be 100%.
Can anyone suggest me about the compression classes (DeflateStream/GzipStream).
Thanks
VJ
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
大多数人混淆“压缩的最终大小”==“更好的网络性能”。一般来说,使用“优于 deflate”类压缩算法可以减少传输带宽,但会增加总传输时间(压缩+传输+解压缩)。从这个意义上说,LZ 级压缩机似乎是最好的。最快的实施方式可以是 QuickLZ 或 LZ4.它们都有 C# 版本。但是,它们的实现并不完全像 DeflateStream(实际上使用起来更简单)。 QuickLZ 在网络相关应用程序中的使用量不断增加,而 LZ4 最近修补到了 Apache Hadoop 源主干,而不是 Google 的 Snappy。
如果您需要更多压缩,可以获取 LZMA SDK,其中包含托管 LZMA 压缩/解压缩方法。但是,我应该警告你,LZMA 的内存消耗通常非常高(取决于参数)。因此,生成多个 LZMA 支持的线程不太可能是您真正想要的。
如果您仍然需要越来越多的压缩,请查看 PPM 或按位 CM 类算法。 PPM 非常适合文本数据,并且具有平均速度(通常为 2-3 MiB/秒)。另一方面,CM 对于二进制数据非常擅长。它们的内存消耗可能很高(取决于参数)并且非常慢(1 MiB/秒甚至几个字节/秒,取决于算法)。不幸的是,您可能只能在互联网上找到 PPM .NET 实现。但是,由于复杂性太高,在.NET中寻找CM确实很麻烦。我在.NET中编写了 order0 按位编码器如果您确实需要,可以使用其他模型将其扩展为适当的 CM。
Most people confuses "compressed final size" == "better network performance". In general sense, using "better-than-deflate" class compression algorithms can reduce transfer bandwidth, but they can increase total transfer time (compression+transfer+decompression). In that sense LZ class compressor seems best. Fastest implementation can be QuickLZ or LZ4. They both have a C# version. But, their implementation is not exactly as e.g. DeflateStream (actually simplier to use). QuickLZ has growing usage on network related applications while LZ4 patched into Apache Hadoop source trunk recently instead of Google's Snappy.
If you need more compression, you can grab LZMA SDK which consists of managed LZMA compression/decompression methods. But, I should warn you, LZMA's memory consumption is usually very high (depends on parameters). So, spawning several LZMA-powered threads is not likely you really want.
If you still need more and more compression, have a look at PPM or bitwise-CM class algorithms. PPM is very good on textual data and has an average speed (usually 2-3 MiB/sec). On the other hand, CM is very good on binary data. Their memory consumption can be high (depends on parameters) and very slow (1 MiB/sec to even several bytes/sec, depends on algorithms). Unfortunately, you may only find PPM .NET implementation on the internet. But, CM is really troublesome to find in .NET due to high complexity. I have written order0 bitwise coder in .NET that can be extended to a proper CM with additional models if you really need.