erlang 压缩zlib
来源:互联网 发布:手机淘宝客户端改差评 编辑:程序博客网 时间:2024/06/03 11:17
一:写在之前
今天和同事讨论偶然提到了,代码中注释掉的压缩方法,想了想好像还没有看过压缩相关的内容
一位同事提出了,之前他们项目因为压缩崩溃过一次,这更激起了自己兴趣,晚上看了会,记录下一些心得
二:简介
erlang提供了一个压缩模块 zlib
那么,什么是zlib?
wiki 连接点这里
wiki中的简介
zlib is a software library used for data compression. zlib was written by Jean-Loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compression program. zlib is also a crucial component of many software platforms including Linux, Mac OS X, and iOS. It has also been used in gaming consoles such as the PlayStation 4, PlayStation 3, Wii U, Wii, Xbox One and Xbox 360.zlib是一种通用的压缩格式,而erlang 只是提供了一个api调用 zlib的api
erlang zlib简介
The zlib module provides an API for the zlib library (http://www.zlib.org). It is used to compress and decompress data. The data format is described by RFCs 1950 to 1952.
三:使用
zlib:compress(iodata())
直接使用即可,那么压缩效果和?做个测试
BinaryPart = list_to_binart(lists:seq(1,255)),Binary = <<BinaryPart/binary, BinaryPart/binary,BinaryPart/binary,BinaryPart/binary, BinaryPart/binary,BinaryPart/binary,BinaryPart/binary,BinaryPart/binary, BinaryPart/binary>>CompressBinary = zlib:compress(Binary),{byte_size(Binary), byte_size(CBinary)}重复数据,这是非常适合压缩的情况,结果为{3060,304}
证明压缩确实有效。。。
四:问题
有一位同事提出,zlib:compress每次都需要打开一个端口,当有压缩有异常时端口不能正常关闭,他之前项目曾经出过问题。
so...真的是这样么。。
有一篇记录到这个问题的文章,这里不再重复。原文链接
但是。。这里也提到了,15b01 erlang已经修复了这个问题 原文链接
做了个实验。。大致就是,不断的调用zlib:compress 重复100万次,一半错误,一半正确,记录打开的端口数量
最后结果是,所有端口都正常关闭了,所以可以放心使用。
0 0
- erlang 压缩zlib
- ZLIB压缩算法
- 用zlib压缩文件夹
- zlib压缩解压库
- zlib压缩库备忘
- 通用压缩库zlib
- Delphi ZLib压缩
- zlib压缩解压缩文件
- zlib压缩算法
- zlib压缩解压
- zlib压缩解压库
- python zlib字符串压缩
- ZLib压缩技术
- zlib的使用-压缩
- iOS zlib 压缩解压
- android ZLib压缩/解压缩
- node---zlib压缩模块
- Java压缩技术ZLib
- 程序员应该具备的12种能力!
- Opencv研读笔记:haartraining程序之icvCreateCARTStageClassifier函数详解(强分类器创建)~
- 最新百度 阿里 华为 腾讯 谷歌面试笔试题及解析
- OGNL 对象图导航语言
- 开始
- erlang 压缩zlib
- 第一个自己写的banner动画
- 第一题
- 卡塔兰(Catalan)数
- 【JAVA笔记——道】java动态代理源码深入
- Hadoop集群搭建
- maven错误处理-创建新工程失败
- 全面理解 Unity UI 系统
- CentOS 7 (RHEL 7)服务管理命令的变化