Snappy is a compression/decompression library. It does not an 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 was an order of magnitude faster for most inputs, but the result ing compressed files is anywhere from 20% to 100% bigger. On a single core of a core i7 processor in 64-bit mode, Snappy compresses at about + mb/sec or more and decompresses at About $ mb/sec or more.
Snappy is widely used inside Google, in everything from BigTable and MapReduce to our internal RPC systems. (Snappy have previously been referred to as "Zippy" in some presentations and the likes.)
Snappy is a C + + development package for compression and decompression in Google. The goal is not to maximize compression or compatibility with other compression formats, but to provide high speed compression and reasonable compression. Snappy is faster than zlib, but files are 20% to 100% larger. On the Core i7 processor in 64-bit mode, the compression speed of 250~500 MB per second is up.
The predecessor of Snappy was Zippy. Although it is just a data compression library, it is used by Google for many internal projects, including Bigtable,mapreduce and RPC. Google claims that it has optimized the speed of data processing in the library itself and its algorithms, without regard to output size and compatibility issues with other similar tools. The snappy specifically optimizes the 64-bit x86 processor to achieve a compression rate of at least 250MB per second and an decompression rate of 500MB per second on a single Intel Core i7 processor core.
Google is highly appreciative of the advantages of Snappy, and the Snappy download was "designed to not crash even in the face of corrupted or malicious input files" from the outset, and was used by Google to compress petabytes of data in production environments. Its robustness and stability are evident.
650) this.width=650; "Src=" http://dl2.iteye.com/upload/attachment/0122/3746/ 477ac64b-4326-3b34-9a85-1f1427e2bb84.png "title=" click to view original size picture "class=" Magplus "width=" "height=" 408 "style=" border : 0px; "/>
Core code Download :
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;
}
}
}
Download
650) this.width=650; "Src=" http://dl2.iteye.com/upload/attachment/0122/3750/ 6c4d4123-87e3-3dce-920a-61db21493a1b.png "title=" Click to view the original size picture "class=" Magplus "width=" "height=" "style=" border : 0px; "/>
650) this.width=650; "Src=" http://dl2.iteye.com/upload/attachment/0122/3748/ 5da210a0-1f88-3c3a-ba4c-ec74e8214be4.png "title=" click to view original size picture "class=" Magplus "width=" "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=" click to view original size picture "class=" Magplus "width=" "height=" 431 "style=" border : 0px; "/>
Snappy Compression of Java code