Snappy (Snappy for Java 1.0.4.1-SNAPSHOT API)
Date: 2011-09-26

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.xerial.snappy
Class Snappy

    java.lang.Object
      org.xerial.snappy.Snappy

    public class Snappy

extends Object

Snappy API for data compression/decompression

Author:
  leo

Constructor Summary
`Snappy()`

Method Summary
`static void` | `arrayCopy(Object src, int offset, int byteLength, Object dest, int dest_offset)` Copy bytes from source to destination
`static byte[]` | `compress(byte[] input)` High-level API for compressing the input byte array.
`static int` | `compress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset)` Compress the input buffer content in [inputOffset, ...inputOffset+inputLength) then output to the specified output buffer.
`static int` | `compress(ByteBuffer uncompressed, ByteBuffer compressed)` Compress the content in the given input buffer.
`static byte[]` | `compress(char[] input)` Compress the input char array
`static byte[]` | `compress(double[] input)` Compress the input double array
`static byte[]` | `compress(float[] input)` Compress the input float array
`static byte[]` | `compress(int[] input)` Compress the input int array
`static byte[]` | `compress(long[] input)` Compress the input long array
`static byte[]` | `compress(short[] input)` Compress the input short array
`static byte[]` | `compress(String s)` Compress the input String
`static byte[]` | `compress(String s, Charset encoding)` Compress the input string using the given encoding
`static byte[]` | `compress(String s, String encoding)` Compress the input string using the given encoding
`static String` | `getNativeLibraryVersion()` Get the native library version of the snappy
`static boolean` | `isValidCompressedBuffer(byte[] input)` Returns true iff the contents of compressed buffer [offset, offset+length) can be uncompressed successfully.
`static boolean` | `isValidCompressedBuffer(byte[] input, int offset, int length)` Returns true iff the contents of compressed buffer [offset, offset+length) can be uncompressed successfully.
`static boolean` | `isValidCompressedBuffer(ByteBuffer compressed)` Returns true iff the contents of compressed buffer [pos() ...
`static int` | `maxCompressedLength(int byteSize)` Get the maximum byte size needed for compressing data of the given byte size.
`static byte[]` | `rawCompress(Object data, int byteSize)` Compress the input data and produce a byte array of the uncompressed data
`static int` | `rawCompress(Object input, int inputOffset, int inputLength, byte[] output, int outputOffset)` Compress the input buffer [offset,...
`static int` | `rawUncompress(byte[] input, int inputOffset, int inputLength, Object output, int outputOffset)` Uncompress the content in the input buffer.
`static byte[]` | `uncompress(byte[] input)` High-level API for uncompressing the input byte array.
`static int` | `uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset)` Uncompress the content in the input buffer.
`static int` | `uncompress(ByteBuffer compressed, ByteBuffer uncompressed)` Uncompress the content in the input buffer.
`static char[]` | `uncompressCharArray(byte[] input)` Uncompress the input data as char array
`static char[]` | `uncompressCharArray(byte[] input, int offset, int length)` Uncompress the input[offset, .., offset+length) as a char array
`static double[]` | `uncompressDoubleArray(byte[] input)` Uncompress the input as a double array
`static int` | `uncompressedLength(byte[] input)` Get the uncompressed byte size of the given compressed input.
`static int` | `uncompressedLength(byte[] input, int offset, int length)` Get the uncompressed byte size of the given compressed input.
`static int` | `uncompressedLength(ByteBuffer compressed)` Get the uncompressed byte size of the given compressed input.
`static float[]` | `uncompressFloatArray(byte[] input)` Uncompress the input as a float array
`static float[]` | `uncompressFloatArray(byte[] input, int offset, int length)` Uncompress the input[offset, offset+length) as a float array
`static int[]` | `uncompressIntArray(byte[] input)` Uncompress the input data as an int array
`static int[]` | `uncompressIntArray(byte[] input, int offset, int length)` Uncompress the input[offset, offset+length) as an int array
`static long[]` | `uncompressLongArray(byte[] input)` Uncompress the input data as a long array
`static long[]` | `uncompressLongArray(byte[] input, int offset, int length)` Uncompress the input[offset, offset+length) as a long array
`static short[]` | `uncompressShortArray(byte[] input)` Uncompress the input as a short array
`static short[]` | `uncompressShortArray(byte[] input, int offset, int length)` Uncompress the input[offset, offset+length) as a short array
`static String` | `uncompressString(byte[] input)` Uncompress the input as a String
`static String` | `uncompressString(byte[] input, Charset encoding)` Uncompress the input as a String of the given encoding
`static String` | `uncompressString(byte[] input, int offset, int length)` Uncompress the input[offset, offset+length) as a String
`static String` | `uncompressString(byte[] input, int offset, int length, Charset encoding)` Uncompress the input[offset, offset+length) as a String of the given encoding
`static String` | `uncompressString(byte[] input, int offset, int length, String encoding)` Uncompress the input[offset, offset+length) as a String of the given encoding
`static String` | `uncompressString(byte[] input, String encoding)` Uncompress the input as a String of the given encoding

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Snappy

    public Snappy()

Method Detail

### arrayCopy

    public static void arrayCopy(Object src,
                                 int offset,
                                 int byteLength,
                                 Object dest,
                                 int dest_offset)
                          throws IOException

  Copy bytes from source to destination

  Parameters:
    `src` - pointer to the source array
    `offset` - byte offset in the source array
    `byteLength` - the number of bytes to copy
    `dest` - pointer to the destination array
    `dest_offset` - byte offset in the destination array
  Throws:
    `IOException`

### compress

    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(byte[], int, int, byte[], int)` or `compress(ByteBuffer, ByteBuffer)`.

  Parameters:
    `input` - the input data
  Returns:
    the compressed byte array
  Throws:
    `IOException`

### compress

    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.

  Parameters:
    `input` -
    `inputOffset` -
    `inputLength` -
    `output` -
    `outputOffset` -
  Returns:
    byte size of the compressed data
  Throws:
    `IOException` - when failed to access the input/output buffer

### compress

    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())

  Parameters:
    `uncompressed` - buffer[pos() ... limit()) containing the input data
    `compressed` - output of the compressed data. Uses range [pos()..].
  Returns:
    byte size of the compressed data.
  Throws:
    `SnappyError` - when the input is not a direct buffer
    `IOException`

### compress

    public static byte[] compress(char[] input)

  Compress the input char array

  Parameters:
    `input` -
  Returns:
    the compressed data

### compress

    public static byte[] compress(double[] input)

  Compress the input double array

  Parameters:
    `input` -
  Returns:
    the compressed data

### compress

    public static byte[] compress(float[] input)

  Compress the input float array

  Parameters:
    `input` -
  Returns:
    the compressed data

### compress

    public static byte[] compress(int[] input)

  Compress the input int array

  Parameters:
    `input` -
  Returns:
    the compressed data

### compress

    public static byte[] compress(long[] input)

  Compress the input long array

  Parameters:
    `input` -
  Returns:
    the compressed data

### compress

    public static byte[] compress(short[] input)

  Compress the input short array

  Parameters:
    `input` -
  Returns:
    the compressed data

### compress

    public static byte[] compress(String s)
                           throws IOException

  Compress the input String

  Parameters:
    `s` -
  Returns:
    the compressed data
  Throws:
    `IOException`

### compress

    public static byte[] compress(String s,
                                  String encoding)
                           throws UnsupportedEncodingException,
                                  IOException

  Compress the input string using the given encoding

  Parameters:
    `s` -
    `encoding` -
  Returns:
    the compressed data
  Throws:
    `UnsupportedEncodingException`
    `IOException`

### compress

    public static byte[] compress(String s,
                                  Charset encoding)
                           throws IOException

  Compress the input string using the given encoding

  Parameters:
    `s` -
    `encoding` -
  Returns:
    the compressed data
  Throws:
    `UnsupportedEncodingException`
    `IOException`

### getNativeLibraryVersion

    public static String getNativeLibraryVersion()

  Get the native library version of the snappy

  Returns:
    native library version

### isValidCompressedBuffer

    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.

  Throws:
    `IOException`

### isValidCompressedBuffer

    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.

  Throws:
    `IOException`

### isValidCompressedBuffer

    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.

  Throws:
    `IOException`

### maxCompressedLength

    public static int maxCompressedLength(int byteSize)

  Get the maximum byte size needed for compressing data of the given byte size.

  Parameters:
    `byteSize` - byte size of the data to compress
  Returns:
    maximum byte size of the compressed data

### rawCompress

    public static byte[] rawCompress(Object data,
                                     int byteSize)

  Compress the input data and produce a byte array of the uncompressed data

  Parameters:
    `data` - input array. The input MUST be an array type
    `byteSize` - the input byte size
  Returns:
    compressed data

### rawCompress

    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, ...)

  Parameters:
    `input` - input array. This MUST be a primitive array type
    `inputOffset` - byte offset at the output array
    `inputLength` - byte length of the input data
    `output` - output array. This MUST be a primitive array type
    `outputOffset` - byte offset at the output array
  Returns:
    byte size of the compressed data
  Throws:
    `IOException`

### rawUncompress

    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 `isValidCompressedBuffer(byte[], int, int)` first.

  Parameters:
    `input` - input byte array
    `inputOffset` - byte offset in the input byte array
    `inputLength` - byte length of the input data
    `output` - output buffer, MUST be a primitive type array
    `outputOffset` - byte offset in the output buffer
  Returns:
    the byte size of the uncompressed data
  Throws:
    `IOException` - when failed to uncompress the input data

### uncompress

    public static byte[] uncompress(byte[] input)
                             throws IOException

  High-level API for uncompressing the input byte array.

  Parameters:
    `input` -
  Returns:
    the uncompressed byte array
  Throws:
    `IOException`

### uncompress

    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 `isValidCompressedBuffer(byte[], int, int)` first.

  Parameters:
    `input` -
    `inputOffset` -
    `inputLength` -
    `output` -
    `outputOffset` -
  Returns:
    the byte size of the uncompressed data
  Throws:
    `IOException`

### uncompress

    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 `isValidCompressedBuffer(ByteBuffer)` first.

  Parameters:
    `compressed` - buffer[pos() ... limit()) containing the input data
    `uncompressed` - output of the the uncompressed data. It uses buffer[pos()..]
  Returns:
    uncompressed data size
  Throws:
    `IOException` - when failed to uncompress the given input
    `SnappyError` - when the input is not a direct buffer

### uncompressCharArray

    public static char[] uncompressCharArray(byte[] input)
                                      throws IOException

  Uncompress the input data as char array

  Parameters:
    `input` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`

### uncompressCharArray

    public static char[] uncompressCharArray(byte[] input,
                                             int offset,
                                             int length)
                                      throws IOException

  Uncompress the input[offset, .., offset+length) as a char array

  Parameters:
    `input` -
    `offset` -
    `length` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`

### uncompressDoubleArray

    public static double[] uncompressDoubleArray(byte[] input)
                                          throws IOException

  Uncompress the input as a double array

  Parameters:
    `input` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`

### uncompressedLength

    public static int uncompressedLength(byte[] input)
                                  throws IOException

  Get the uncompressed byte size of the given compressed input. This operation takes O(1) time.

  Parameters:
    `input` -
  Returns:
    uncompressed byte size of the the given input data
  Throws:
    `IOException` - when failed to uncompress the given input. The error code is `SnappyErrorCode.PARSING_ERROR`

### uncompressedLength

    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.

  Parameters:
    `input` -
    `offset` -
    `length` -
  Returns:
    uncompressed byte size of the the given input data
  Throws:
    `IOException` - when failed to uncompress the given input. The error code is `SnappyErrorCode.PARSING_ERROR`

### uncompressedLength

    public static int uncompressedLength(ByteBuffer compressed)
                                  throws IOException

  Get the uncompressed byte size of the given compressed input. This operation taks O(1) time.

  Parameters:
    `compressed` - input data [pos() ... limit())
  Returns:
    uncompressed byte length of the given input
  Throws:
    `IOException` - when failed to uncompress the given input. The error code is `SnappyErrorCode.PARSING_ERROR`
    `SnappyError` - when the input is not a direct buffer

### uncompressFloatArray

    public static float[] uncompressFloatArray(byte[] input)
                                        throws IOException

  Uncompress the input as a float array

  Parameters:
    `input` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`

### uncompressFloatArray

    public static float[] uncompressFloatArray(byte[] input,
                                               int offset,
                                               int length)
                                        throws IOException

  Uncompress the input[offset, offset+length) as a float array

  Parameters:
    `input` -
    `offset` -
    `length` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`

### uncompressIntArray

    public static int[] uncompressIntArray(byte[] input)
                                    throws IOException

  Uncompress the input data as an int array

  Parameters:
    `input` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`

### uncompressIntArray

    public static int[] uncompressIntArray(byte[] input,
                                           int offset,
                                           int length)
                                    throws IOException

  Uncompress the input[offset, offset+length) as an int array

  Parameters:
    `input` -
    `offset` -
    `length` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`

### uncompressLongArray

    public static long[] uncompressLongArray(byte[] input)
                                      throws IOException

  Uncompress the input data as a long array

  Parameters:
    `input` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`

### uncompressLongArray

    public static long[] uncompressLongArray(byte[] input,
                                             int offset,
                                             int length)
                                      throws IOException

  Uncompress the input[offset, offset+length) as a long array

  Parameters:
    `input` -
    `offset` -
    `length` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`

### uncompressShortArray

    public static short[] uncompressShortArray(byte[] input)
                                        throws IOException

  Uncompress the input as a short array

  Parameters:
    `input` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`

### uncompressShortArray

    public static short[] uncompressShortArray(byte[] input,
                                               int offset,
                                               int length)
                                        throws IOException

  Uncompress the input[offset, offset+length) as a short array

  Parameters:
    `input` -
    `offset` -
    `length` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`

### uncompressString

    public static String uncompressString(byte[] input)
                                   throws IOException

  Uncompress the input as a String

  Parameters:
    `input` -
  Returns:
    the uncompressed dasta
  Throws:
    `IOException`

### uncompressString

    public static String uncompressString(byte[] input,
                                          int offset,
                                          int length)
                                   throws IOException

  Uncompress the input[offset, offset+length) as a String

  Parameters:
    `input` -
    `offset` -
    `length` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`

### uncompressString

    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

  Parameters:
    `input` -
    `offset` -
    `length` -
    `encoding` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`
    `UnsupportedEncodingException`

### uncompressString

    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

  Parameters:
    `input` -
    `offset` -
    `length` -
    `encoding` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`
    `UnsupportedEncodingException`

### uncompressString

    public static String uncompressString(byte[] input,
                                          String encoding)
                                   throws IOException,
                                          UnsupportedEncodingException

  Uncompress the input as a String of the given encoding

  Parameters:
    `input` -
    `encoding` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`
    `UnsupportedEncodingException`

### uncompressString

    public static String uncompressString(byte[] input,
                                          Charset encoding)
                                   throws IOException,
                                          UnsupportedEncodingException

  Uncompress the input as a String of the given encoding

  Parameters:
    `input` -
    `encoding` -
  Returns:
    the uncompressed data
  Throws:
    `IOException`
    `UnsupportedEncodingException`

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2011 xerial.org. All Rights Reserved.