C++压缩解压之snappy
引文出处:http://wiki.dreamrunner.org/public_html/C-C++/Library-Notes/Snappy.html
Snappy
Table of Contents
Overview
- homepage: http://google.github.io/snappy/
- git: https://github.com/google/snappy
Snappy is a compression/decompression library. It does not aim for maximum compression, or compatibility with any other compression library; instead, it aims for very high speeds and reasonable compression
- Fast: Compression speeds at 250 MB/sec and beyond, with no assembler code. See "Performance" below.
- Stable: Over the last few years, Snappy has compressed and decompressed petabytes of data in Google's production environment. The Snappy bitstream format is stable and will not change between versions.
- Robust: The Snappy decompressor is designed not to crash in the face of corrupted or malicious input.
Compile and install
./autogen.sh ./configure make # to static library ar rcs libsnappy.a ./*.o
Use
To use Snappy from your own C++ program, include the file "snappy.h" from your calling file, and link against the compiled library.
There are many ways to call Snappy, but the simplest possible is
snappy::Compress(input.data(), input.size(), &output); snappy::Uncompress(input.data(), input.size(), &output);
where "input" and "output" are both instances of std::string
.
Example
#include <snappy.h> #include <string> #include <iostream> using namespace std;int main() {string input = "Hello World";string output;for (int i = 0; i < 5; ++i) {input += input;}snappy::Compress(input.data(), input.size(), &output);cout << "input size:" << input.size() << " output size:"<< output.size() << endl;string output_uncom;snappy::Uncompress(output.data(), output.size(), &output_uncom);if (input == output_uncom) {cout << "Equal" << endl;} else {cout << "ERROR: not equal" << endl;}return 0; }
$ g++ -o example ./snappy-example.cc -I. -L. -lsnappy $ ./example input size:352 output size:32 Equal
Author: Shi Shougang
Created: 2016-03-13 Sun 22:15
Emacs 24.3.1 (Org mode 8.2.10)
Validate
C++压缩解压之snappy相关推荐
- hadoopsnappy解压_Hadoop Snappy 压缩的安装和配置
snappy是google的一个开源的压缩库,在合理的压缩率的前提下提供了提供了一个很高的压缩/解压的速度,利用单颗Intel Corei7处理器内核处理达到每秒处理250MB~500MB的数据流.s ...
- Asp.net 2.0 C#实现压缩/解压功能
Asp.net 2.0 C#实现压缩/解压功能 (示例代码下载) (一). 实现功能 对文件及目录的压缩及解压功能 (二). 运行图片示例 (三).代码 1. 压缩类 1/**//// <s ...
- 测试掌握的Linux解压,轻松掌握Linux压缩/解压文件的方法
对于在Linux下解压大型的*.zip文件,相信大家一般都会通过使用winrar直接在smb中来进行解压的操作,虽然说最终可能能够解压但有时候会存在解压时间长或者网络原因出错等故障的情况出现.那么有没 ...
- tar压缩解压命令详解
tar命令详解 -c:建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其 ...
- 一章: CentOS6.5 网络配置、修改主机名、添加硬盘、压缩——解压方法、VNC—server配置
1,配IP ,修改网络配置文件 配置网卡 # vim /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 HWADDR=00:50:56:83: ...
- Ubuntu 压缩解压汇总(自己常用+持续更新)
Ubuntu 压缩解压汇总 ZIP tar.gz ZIP sudo apt-get install unzip 安装unzip功能 unzip xxx.zip 解压到当前目录下 unzip xxx.z ...
- 【PC工具】文件压缩解压工具winrar解压缩装机必备软件,winRAR5.70免费无广告
微信关注 "DLGG创客DIY" 设为"星标",重磅干货,第一时间送达. 今天分享一个常用的压缩解压工具winrar. 为啥要搞这个无广告版呢(废话),总之网上 ...
- java 7zip解压_Apache Commons Compress介绍-JAVA压缩解压7z文件
7zip(下面简称7z)是由Igor Pavlov所开发的一种压缩格式,主要使用的压缩算法是LZMA/LZMA2.7z是一种压缩比非常高的格式,这与其压缩算法LZMA有直接关系,所以很多大文件都是用7 ...
- SAPCAR 压缩解压软件的使用方法
SAPCAR 是 SAP 公司使用的压缩解压软件,从 SAP 网站下载的补丁包和小型软件基本都是扩展名为 car 或 sar 的,它们都可以用 SAPCAR 来解压.下面是它的使用说明: 用法: 创建 ...
- WebAPI性能优化之压缩解压
有时候为了提升WebAPI的性能,减少响应时间,我们会使用压缩和解压,而现在大多数客户端浏览器都提供了内置的解压支持.在WebAPI请求的资源越大时,使用压缩对性能提升的效果越明显,而当请求的资源很小 ...
最新文章
- Twitter Storm常见模式
- mysql 高效备份_Mysql高性能备份方案解决数据不间断访问(LVM快照方式备份)
- 下列哪个不是目前python里的内置模块-python的内置模块math在哪个文件里
- C#编码规范(3):常用变量和控件在变量命名中缩写
- FOJ Problem 2253 Salty Fish
- 推荐一个快速反射调用的类
- 【java】linux命令获取百度的主页-模拟Socket三次握手
- 苹果推出Find My Friends好友追踪iOS应用
- javscript 创建类的三种方法【转】
- 计算机基础知识集体备课,计算机基础知识集体备课.doc
- 公众号文章批量导出工具
- 计算机语言日语换成中文,win7系统怎么把语言变成日语
- 如何爬取豆瓣电影?python十分钟搞定
- python 图像分割_Python中的图像分割(第2部分)
- Jumpserver堡垒机部署(完整过程)
- program received signal sigsegv,Segmentation fault的解释(可能并不全面)
- M-ATX台式电脑主板的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告
- 辩证唯物论和唯物辩证法区别
- LegendShop教您,电商系统选型要注意什么!
- win10版本查看_不知道电脑上安装的win10版本,这样操作可以轻松查看