转 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请求的资源越大时,使用压缩对性能提升的效果越明显,而当请求的资源很小 ...
最新文章
- 深圳高一学生,夺冠国际物理奥赛
- 如何在html页面循环回显数据,从while循环显示数据到html代码
- windows环境下python怎么安装mlxtend-python连接QQ实现自动回复python 机器学习库
- pthread_cond_wait()加一个while为什么的解释
- EFCore3.1+编写自定义的EF.Functions扩展方法
- 响应性web设计实战总结(二)
- Hive的数据模型-管理表
- SpringBoot实战(七):替代if的优雅方案,提高程序扩展性
- VirtualBox Failed to open/create the internal network 错误处理
- 一年中所有节日的排列顺序_中国传统节日有哪些 按顺序排列全部
- 《高等代数学》(姚慕生),习题1.3:n阶行列式
- GIS 如何求多边形的内接最大圆
- 查询中国天气网api需要用到的城市代码
- matlab窄带水平集,窄带水平集方法
- 数据库COUNT(*)、COUNT(字段)和COUNT(1)的异同
- html泰勒展开,常见的泰勒公式展开式大全
- 怎样提高平面设计色彩表现力
- html做成小程序,HTML-简单表单制作-表单制作-小程序表单制作
- 【算法】汇总:求解π值的算法
- “小身材,大味道”小蚁4K+运动相机深度测评
热门文章
- uni-app 实现input:type=file 上传,并实现表单提交
- Windows安全配置技术(转)
- win10无法访问linux共享服务器,Win10无法访问NAS或Linux网络共享的处理方法
- WSL2 通过 USBIP 连接USB串口设备 JetsonUSB备份刷机
- 【红外技术】红外焦平面阵列非均匀性校正
- 《用户体验要素——以用户为中心的产品设计》读书笔记
- 爬虫入门 手写一个Java爬虫
- mysql数据库语法用处_MySQL数据库语法总结笔记
- Android中淡入淡出动画
- Mac截图很大很怎么变小?