標籤:freemaker springmvc mybatis ssm bootstrap
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. For instance, compared to the fastest mode of zlib, Snappy is an order of magnitude faster for most inputs, but the resulting compressed files are anywhere from 20% to 100% bigger. On a single core of a Core i7 processor in 64-bit mode, Snappy compresses at about 250 MB/sec or more and decompresses at about 500 MB/sec or more.
Snappy is widely used inside Google, in everything from BigTable and MapReduce to our internal RPC systems. (Snappy has previously been referred to as “Zippy” in some presentations and the likes.)
Snappy 是Google的一個 C++ 的用來壓縮和解壓縮的開發包。其目標不是最大限度壓縮或者相容其他壓縮格式,而是旨在提供高速壓縮速度和合理的壓縮率。Snappy 比 zlib 更快,但檔案相對要大 20% 到 100%。在 64位元模式的 Core i7 處理器上,可達每秒 250~500兆的壓縮速度。
snappy 的前身是Zippy。雖然只是一個資料壓縮庫,它卻被Google用於許多內部項目程,其中就包括BigTable,MapReduce和RPC。Google宣稱它在這個庫本身及其演算法做了資料處理速度上的最佳化,作為代價,並沒有考慮輸出大小以及和其他類似工具的相容性問題。Snappy特地為64位x86處理器做了最佳化,在單個Intel Core i7處理器核心上能夠達到至少每秒250MB的壓縮速率和每秒500MB的解壓速率。
Google極力讚揚Snappy的各種優點,Snappy下載從一開始就被“設計為即便遇到損壞或者惡意的輸入檔案都不會崩潰”,而且被Google在生產環境中用於壓縮PB級的資料。其健壯性和穩定程度可見一斑。
650) this.width=650;" src="http://dl2.iteye.com/upload/attachment/0122/3746/477ac64b-4326-3b34-9a85-1f1427e2bb84.png" title="點擊查看原始大小圖片" class="magplus" width="700" height="408" style="border:0px;" />
核心代碼下載:
package cn.com.kafkademo.kafkademo;
import java.io.IOException;
import org.xerial.snappy.Snappy;
public class SnappyDemo {
/**
* args
*/
public static void main(String[] args) {
}
public static byte[] compressHtml(String html) {
try {
return Snappy.compress(html.getBytes("UTF-8"));
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public static String decompressHtml(byte[] bytes) {
try {
return new String(Snappy.uncompress(bytes));
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}
下載
650) this.width=650;" src="http://dl2.iteye.com/upload/attachment/0122/3750/6c4d4123-87e3-3dce-920a-61db21493a1b.png" title="點擊查看原始大小圖片" class="magplus" width="700" height="400" style="border:0px;" />
650) this.width=650;" src="http://dl2.iteye.com/upload/attachment/0122/3748/5da210a0-1f88-3c3a-ba4c-ec74e8214be4.png" title="點擊查看原始大小圖片" class="magplus" width="700" height="431" style="border:0px;" />
650) this.width=650;" src="http://dl2.iteye.com/upload/attachment/0122/3748/5da210a0-1f88-3c3a-ba4c-ec74e8214be4.png" title="點擊查看原始大小圖片" class="magplus" width="700" height="431" style="border:0px;" />
JAVA代碼之Snappy 壓縮