Package org.xerial.snappy
Snappy API for compressing/decompressing data.
Usage
First, import
Snappy
in your Java code:
import org.xerial.snappy.Snappy;
Then use Snappy.compress(byte[])
and Snappy.uncompress(byte[])
:
String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper of Snappy, a fast compresser/decompresser.";
byte[] compressed = Snappy.compress(input.getBytes("UTF-8"));
byte[] uncompressed = Snappy.uncompress(compressed);
String result = new String(uncompressed, "UTF-8");
System.out.println(result);
In addition, high-level methods (Snappy.compress(String), Snappy.compress(float[] ..) etc. ) and low-level ones (e.g. Snappy.rawCompress(.. ), Snappy.rawUncompress(..), etc.), which minimize memory copies, can be used.
Stream-based API
Stream-based compressor/decompressor SnappyOutputStream, SnappyInputStream are also available for reading/writing large data sets.-
Interface Summary Interface Description SnappyApi Snappy compressor/decompressor interface. -
Class Summary Class Description BitShuffle BitShuffleNative JNI interfaces of theBitShuffle
implementation.OSInfo Provides OS name and architecture name.PureJavaCrc32C A pure-java implementation of the CRC32 checksum that uses the CRC32-C polynomial, the same polynomial used by iSCSI and implemented on many Intel chipsets supporting SSE4.2.Snappy Snappy API for data compression/decompressionSnappyBundleActivator OSGi bundle entry pointSnappyCodec Preamble header forSnappyOutputStream
.SnappyFramedInputStream SnappyFramedInputStream.FrameData SnappyFramedInputStream.FrameMetaData SnappyFramedOutputStream SnappyHadoopCompatibleOutputStream SnappyInputStream A stream filter for reading data compressed bySnappyOutputStream
.SnappyLoader Internal only - Do not use this class. This class loads a native library of snappy-java (snappyjava.dll, libsnappy.so, etc.) according to the user platform (os.name and os.arch).SnappyNative JNI interface of theSnappy
implementation.SnappyOutputStream This class implements a stream filter for writing compressed data using Snappy. -
Enum Summary Enum Description BitShuffleType Type codes used in ByteBuffer based BitShuffle APIsSnappyErrorCode Error codes of snappy-java -
Exception Summary Exception Description SnappyException Deprecated. Snappy-java now usesIOException
SnappyIOException Enhanced IOException with SnappyErrorCode -
Error Summary Error Description SnappyError Used when serious errors (unchecked exception) are observed.