Note
if the native libraries cannot be loaded, an ExceptionInInitializerError will be thrown at first use of this class.
| Modifier and Type | Field and Description |
|---|---|
| private static SnappyApi | impl
An instance of SnappyNative |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static void | |
| public static void | |
| public static byte[] | Returns: the compressed byte arraythe input data input)High-level API for compressing the input byte array. |
| public static int | Returns: byte size of the compressed dataCompress the input buffer content in [inputOffset, ...inputOffset+inputLength) then output to the specified output buffer. |
| public static int | Returns: byte size of the compressed data.buffer[pos() ... limit()) containing the input data uncompressed, ByteBuffer output of the compressed data. Uses range [pos()..]. compressed)Compress the content in the given input buffer. |
| public static byte[] | |
| public static byte[] | |
| public static byte[] | |
| public static byte[] | |
| public static byte[] | |
| public static byte[] | |
| public static byte[] | |
| public static byte[] | |
| public static byte[] | |
| public static String | Returns: native library versionGet the native library version of the snappy |
| pack-priv static void | |
| public static boolean | isValidCompressedBuffer(byte[] input, int offset, int length)
Returns true iff the contents of compressed buffer [offset, offset+length) can be uncompressed successfully. |
| public static boolean | isValidCompressedBuffer(byte[] input)
Returns true iff the contents of compressed buffer [offset, offset+length) can be uncompressed successfully. |
| public static boolean | isValidCompressedBuffer(ByteBuffer compressed)
Returns true iff the contents of compressed buffer [pos() ... |
| public static boolean | isValidCompressedBuffer(long inputAddr, long offset, long length)
Returns true iff the contents of compressed buffer [offset, offset+length) can be uncompressed successfully. |
| public static int | Returns: maximum byte size of the compressed databyte size of the data to compress byteSize)Get the maximum byte size needed for compressing data of the given byte size. |
| public static long | Returns: the compressed data sizeinput memory address inputAddr, long input byte size inputSize, long destination address of the compressed data destAddr)Zero-copy compress using memory addresses. |
| public static byte[] | Returns: compressed datainput array. The input MUST be an array type data, int the input byte size byteSize)Compress the input data and produce a byte array of the uncompressed data |
| public static int | Returns: byte size of the compressed datainput array. This MUST be a primitive array type input, int byte offset at the output array inputOffset, int byte length of the input data inputLength, byte[] output array. This MUST be a primitive array type output, int byte offset at the output array outputOffset)Compress the input buffer [offset,... |
| public static long | Returns: the uncompressed data sizeinput memory address inputAddr, long input byte size inputSize, long destination address of the uncompressed data destAddr)Zero-copy decompress using memory addresses. |
| public static int | Returns: the byte size of the uncompressed datainput byte array input, int byte offset in the input byte array inputOffset, int byte length of the input data inputLength, Object output buffer, MUST be a primitive type array output, int byte offset in the output buffer outputOffset)Uncompress the content in the input buffer. |
| public static byte[] | Returns: the uncompressed byte arrayHigh-level API for uncompressing the input byte array. |
| public static int | Returns: the byte size of the uncompressed dataUncompress the content in the input buffer. |
| public static int | Returns: uncompressed data sizebuffer[pos() ... limit()) containing the input data compressed, ByteBuffer output of the the uncompressed data. It uses buffer[pos()..] uncompressed)Uncompress the content in the input buffer. |
| public static char[] | Returns: the uncompressed dataUncompress the input data as char array |
| public static char[] | Returns: the uncompressed dataUncompress the input[offset, .., offset+length) as a char array |
| public static double[] | Returns: the uncompressed dataUncompress the input as a double array |
| public static double[] | Returns: the uncompressed dataUncompress the input as a double array |
| public static int | Returns: uncompressed byte size of the the given input dataGet the uncompressed byte size of the given compressed input. |
| public static int | Returns: uncompressed byte size of the the given input dataGet the uncompressed byte size of the given compressed input. |
| public static int | Returns: uncompressed byte length of the given inputinput data [pos() ... limit()) compressed)Get the uncompressed byte size of the given compressed input. |
| public static long | Returns: uncompressed byte length of the given inputcompressed data address inputAddr, long byte length of the input len)Get the uncompressed byte size of the given compressed input. |
| public static float[] | Returns: the uncompressed dataUncompress the input as a float array |
| public static float[] | Returns: the uncompressed dataUncompress the input[offset, offset+length) as a float array |
| public static int[] | Returns: the uncompressed dataUncompress the input data as an int array |
| public static int[] | Returns: the uncompressed dataUncompress the input[offset, offset+length) as an int array |
| public static long[] | Returns: the uncompressed dataUncompress the input data as a long array |
| public static long[] | Returns: the uncompressed dataUncompress the input[offset, offset+length) as a long array |
| public static short[] | Returns: the uncompressed dataUncompress the input as a short array |
| public static short[] | Returns: the uncompressed dataUncompress the input[offset, offset+length) as a short array |
| public static String | |
| public static String | Returns: the uncompressed dataUncompress the input[offset, offset+length) as a String |
| public static String | Returns: the uncompressed dataUncompress the input[offset, offset+length) as a String of the given encoding |
| public static String | Returns: the uncompressed dataUncompress the input[offset, offset+length) as a String of the given encoding |
| public static String | Returns: the uncompressed dataUncompress the input as a String of the given encoding |
| public static String | Returns: the uncompressed dataUncompress the input as a String of the given encoding |
| impl | back to summary |
|---|---|
| private static SnappyApi impl An instance of SnappyNative | |
| Snappy | back to summary |
|---|---|
| public Snappy() | |
| arrayCopy | back to summary |
|---|---|
| public static void arrayCopy(Object src, int offset, int byteLength, Object dest, int dest_offset) throws IOException Copy bytes from source to destination | |
| cleanUp | back to summary |
|---|---|
| public static void cleanUp() Clean up a temporary file (native lib) generated by snappy-java. General users do not need to call this method, since the native library extracted in snappy-java is deleted upon JVM termination (vie deleteOnExit()). This method is useful when using a J2EE container, which will restart servlet containers multiple times without restarting JVM. | |
| compress | back to summary |
|---|---|
| public static byte[] compress(byte[] input) throws IOException High-level API for compressing the input byte array. This method performs
array copy to generate the result. If you want to reduce the memory copy
cost, use
| |
| compress | back to summary |
|---|---|
| public static int compress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException Compress the input buffer content in [inputOffset, ...inputOffset+inputLength) then output to the specified output buffer.
| |
| compress | back to summary |
|---|---|
| public static int compress(ByteBuffer uncompressed, ByteBuffer compressed) throws IOException Compress the content in the given input buffer. After the compression, you can retrieve the compressed data from the output buffer [pos() ... limit()) (compressed data size = limit() - pos() = remaining())
| |
| compress | back to summary |
|---|---|
| public static byte[] compress(char[] input) throws IOException Compress the input char array
| |
| compress | back to summary |
|---|---|
| public static byte[] compress(double[] input) throws IOException Compress the input double array
| |
| compress | back to summary |
|---|---|
| public static byte[] compress(float[] input) throws IOException Compress the input float array
| |
| compress | back to summary |
|---|---|
| public static byte[] compress(int[] input) throws IOException Compress the input int array
| |
| compress | back to summary |
|---|---|
| public static byte[] compress(long[] input) throws IOException Compress the input long array
| |
| compress | back to summary |
|---|---|
| public static byte[] compress(short[] input) throws IOException Compress the input short array
| |
| compress | back to summary |
|---|---|
| public static byte[] compress(String s) throws IOException Compress the input String
| |
| compress | back to summary |
|---|---|
| public static byte[] compress(String s, String encoding) throws UnsupportedEncodingException, IOException Compress the input string using the given encoding
| |
| compress | back to summary |
|---|---|
| public static byte[] compress(String s, Charset encoding) throws IOException Compress the input string using the given encoding
| |
| getNativeLibraryVersion | back to summary |
|---|---|
| public static String getNativeLibraryVersion() Get the native library version of the snappy
| |
| init | back to summary |
|---|---|
| pack-priv static void init() | |
| isValidCompressedBuffer | back to summary |
|---|---|
| public static boolean isValidCompressedBuffer(byte[] input, int offset, int length) throws IOException Returns true iff the contents of compressed buffer [offset, offset+length) can be uncompressed successfully. Does not return the uncompressed data. Takes time proportional to the input length, but is usually at least a factor of four faster than actual decompression. | |
| isValidCompressedBuffer | back to summary |
|---|---|
| public static boolean isValidCompressedBuffer(byte[] input) throws IOException Returns true iff the contents of compressed buffer [offset, offset+length) can be uncompressed successfully. Does not return the uncompressed data. Takes time proportional to the input length, but is usually at least a factor of four faster than actual decompression. | |
| isValidCompressedBuffer | back to summary |
|---|---|
| public static boolean isValidCompressedBuffer(ByteBuffer compressed) throws IOException Returns true iff the contents of compressed buffer [pos() ... limit()) can be uncompressed successfully. Does not return the uncompressed data. Takes time proportional to the input length, but is usually at least a factor of four faster than actual decompression. | |
| isValidCompressedBuffer | back to summary |
|---|---|
| public static boolean isValidCompressedBuffer(long inputAddr, long offset, long length) throws IOException Returns true iff the contents of compressed buffer [offset, offset+length) can be uncompressed successfully. Does not return the uncompressed data. Takes time proportional to the input length, but is usually at least a factor of four faster than actual decompression. | |
| maxCompressedLength | back to summary |
|---|---|
| public static int maxCompressedLength(int byteSize) Get the maximum byte size needed for compressing data of the given byte size.
| |
| rawCompress | back to summary |
|---|---|
| public static long rawCompress(long inputAddr, long inputSize, long destAddr) throws IOException Zero-copy compress using memory addresses.
| |
| rawCompress | back to summary |
|---|---|
| public static byte[] rawCompress(Object data, int byteSize) throws IOException Compress the input data and produce a byte array of the uncompressed data
| |
| rawCompress | back to summary |
|---|---|
| public static int rawCompress(Object input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException Compress the input buffer [offset,... ,offset+length) contents, then write the compressed data to the output buffer[offset, ...)
| |
| rawUncompress | back to summary |
|---|---|
| public static long rawUncompress(long inputAddr, long inputSize, long destAddr) throws IOException Zero-copy decompress using memory addresses.
| |
| rawUncompress | back to summary |
|---|---|
| public static int rawUncompress(byte[] input, int inputOffset, int inputLength, Object output, int outputOffset) throws IOException Uncompress the content in the input buffer. The uncompressed data is written to the output buffer.
Note that if you pass the wrong data or the range [inputOffset,
inputOffset + inputLength) that cannot be uncompressed, your JVM might
crash due to the access violation exception issued in the native code
written in C++. To avoid this type of crash, use
| |
| uncompress | back to summary |
|---|---|
| public static byte[] uncompress(byte[] input) throws IOException High-level API for uncompressing the input byte array.
| |
| uncompress | back to summary |
|---|---|
| public static int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException Uncompress the content in the input buffer. The uncompressed data is written to the output buffer.
Note that if you pass the wrong data or the range [inputOffset,
inputOffset + inputLength) that cannot be uncompressed, your JVM might
crash due to the access violation exception issued in the native code
written in C++. To avoid this type of crash, use
| |
| uncompress | back to summary |
|---|---|
| public static int uncompress(ByteBuffer compressed, ByteBuffer uncompressed) throws IOException Uncompress the content in the input buffer. The result is dumped to the specified output buffer.
Note that if you pass the wrong data or the range [pos(), limit()) that
cannot be uncompressed, your JVM might crash due to the access violation
exception issued in the native code written in C++. To avoid this type of
crash, use
| |
| uncompressCharArray | back to summary |
|---|---|
| public static char[] uncompressCharArray(byte[] input) throws IOException Uncompress the input data as char array
| |
| uncompressCharArray | back to summary |
|---|---|
| public static char[] uncompressCharArray(byte[] input, int offset, int length) throws IOException Uncompress the input[offset, .., offset+length) as a char array
| |
| uncompressDoubleArray | back to summary |
|---|---|
| public static double[] uncompressDoubleArray(byte[] input) throws IOException Uncompress the input as a double array
| |
| uncompressDoubleArray | back to summary |
|---|---|
| public static double[] uncompressDoubleArray(byte[] input, int offset, int length) throws IOException Uncompress the input as a double array
| |
| uncompressedLength | back to summary |
|---|---|
| public static int uncompressedLength(byte[] input) throws IOException Get the uncompressed byte size of the given compressed input. This operation takes O(1) time.
| |
| uncompressedLength | back to summary |
|---|---|
| public static int uncompressedLength(byte[] input, int offset, int length) throws IOException Get the uncompressed byte size of the given compressed input. This operation takes O(1) time.
| |
| uncompressedLength | back to summary |
|---|---|
| public static int uncompressedLength(ByteBuffer compressed) throws IOException Get the uncompressed byte size of the given compressed input. This operation takes O(1) time.
| |
| uncompressedLength | back to summary |
|---|---|
| public static long uncompressedLength(long inputAddr, long len) throws IOException Get the uncompressed byte size of the given compressed input. This operation takes O(1) time.
| |
| uncompressFloatArray | back to summary |
|---|---|
| public static float[] uncompressFloatArray(byte[] input) throws IOException Uncompress the input as a float array
| |
| uncompressFloatArray | back to summary |
|---|---|
| public static float[] uncompressFloatArray(byte[] input, int offset, int length) throws IOException Uncompress the input[offset, offset+length) as a float array
| |
| uncompressIntArray | back to summary |
|---|---|
| public static int[] uncompressIntArray(byte[] input) throws IOException Uncompress the input data as an int array
| |
| uncompressIntArray | back to summary |
|---|---|
| public static int[] uncompressIntArray(byte[] input, int offset, int length) throws IOException Uncompress the input[offset, offset+length) as an int array
| |
| uncompressLongArray | back to summary |
|---|---|
| public static long[] uncompressLongArray(byte[] input) throws IOException Uncompress the input data as a long array
| |
| uncompressLongArray | back to summary |
|---|---|
| public static long[] uncompressLongArray(byte[] input, int offset, int length) throws IOException Uncompress the input[offset, offset+length) as a long array
| |
| uncompressShortArray | back to summary |
|---|---|
| public static short[] uncompressShortArray(byte[] input) throws IOException Uncompress the input as a short array
| |
| uncompressShortArray | back to summary |
|---|---|
| public static short[] uncompressShortArray(byte[] input, int offset, int length) throws IOException Uncompress the input[offset, offset+length) as a short array
| |
| uncompressString | back to summary |
|---|---|
| public static String uncompressString(byte[] input) throws IOException Uncompress the input as a String
| |
| uncompressString | back to summary |
|---|---|
| public static String uncompressString(byte[] input, int offset, int length) throws IOException Uncompress the input[offset, offset+length) as a String
| |
| uncompressString | back to summary |
|---|---|
| public static String uncompressString(byte[] input, int offset, int length, String encoding) throws IOException, UnsupportedEncodingException Uncompress the input[offset, offset+length) as a String of the given encoding
| |
| uncompressString | back to summary |
|---|---|
| public static String uncompressString(byte[] input, int offset, int length, Charset encoding) throws IOException, UnsupportedEncodingException Uncompress the input[offset, offset+length) as a String of the given encoding
| |
| uncompressString | back to summary |
|---|---|
| public static String uncompressString(byte[] input, String encoding) throws IOException, UnsupportedEncodingException Uncompress the input as a String of the given encoding
| |
| uncompressString | back to summary |
|---|---|
| public static String uncompressString(byte[] input, Charset encoding) throws IOException, UnsupportedEncodingException Uncompress the input as a String of the given encoding
| |