org.xerial.snappy
クラス Snappy

java.lang.Object
  上位を拡張 org.xerial.snappy.Snappy

public class Snappy
extends Object

Snappy API for data compression/decompression

作成者:
leo

コンストラクタの概要
Snappy()
           
 
メソッドの概要
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)
           
static byte[] compress(double[] input)
           
static byte[] compress(float[] input)
           
static byte[] compress(int[] input)
           
static byte[] compress(long[] input)
           
static byte[] compress(short[] input)
           
static byte[] compress(String s)
           
static byte[] compress(String s, String 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() ... limit()) can be uncompressed successfully.
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)
           
static char[] uncompressCharArray(byte[] input, int offset, int length)
           
static double[] uncompressDoubleArray(byte[] input)
           
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)
           
static float[] uncompressFloatArray(byte[] input, int offset, int length)
           
static int[] uncompressIntArray(byte[] input)
           
static int[] uncompressIntArray(byte[] input, int offset, int length)
           
static long[] uncompressLongArray(byte[] input)
           
static long[] uncompressLongArray(byte[] input, int offset, int length)
           
static short[] uncompressShortArray(byte[] input)
           
static short[] uncompressShortArray(byte[] input, int offset, int length)
           
static String uncompressString(byte[] input)
           
static String uncompressString(byte[] input, int offset, int length)
           
static String uncompressString(byte[] input, int offset, int length, String encoding)
           
static String uncompressString(byte[] input, String encoding)
           
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

Snappy

public Snappy()
メソッドの詳細

arrayCopy

public static void arrayCopy(Object src,
                             int offset,
                             int byteLength,
                             Object dest,
                             int dest_offset)
                      throws IOException
Copy bytes from source to destination

パラメータ:
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
例外:
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).

パラメータ:
input - the input data
戻り値:
the compressed byte array
例外:
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.

パラメータ:
input -
inputOffset -
inputLength -
output -
outputOffset -
戻り値:
byte size of the compressed data
例外:
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())

パラメータ:
uncompressed - buffer[pos() ... limit()) containing the input data
compressed - output of the compressed data. Uses range [pos()..].
戻り値:
byte size of the compressed data.
例外:
SnappyError - when the input is not a direct buffer
IOException

compress

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

compress

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

compress

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

compress

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

compress

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

compress

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

compress

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

compress

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

getNativeLibraryVersion

public static String getNativeLibraryVersion()
Get the native library version of the snappy

戻り値:
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.

例外:
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.

例外:
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.

例外:
IOException

maxCompressedLength

public static int maxCompressedLength(int byteSize)
Get the maximum byte size needed for compressing data of the given byte size.

パラメータ:
byteSize - byte size of the data to compress
戻り値:
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

パラメータ:
data - input array. The input MUST be an array type
byteSize - the input byte size
戻り値:
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, ...)

パラメータ:
input - input array. This MUST be primitive array type
inputOffset - byte offset at the output array
inputLength - byte length of the input data
output - output array. This MUST be primitive array type
outputOffset - byte offset at the output array
戻り値:
byte size of the compressed data
例外:
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.

パラメータ:
input - input byte array
inputOffset - byte offset
inputLength - byte length of the input data
output - output buffer, MUST be a primitive type array
outputOffset - byte offset
戻り値:
the byte size of the uncompressed data
例外:
IOException

uncompress

public static byte[] uncompress(byte[] input)
                         throws IOException
High-level API for uncompressing the input byte array.

パラメータ:
input -
戻り値:
the uncompressed byte array
例外:
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.

パラメータ:
input -
inputOffset -
inputLength -
output -
outputOffset -
戻り値:
the byte size of the uncompressed data
例外:
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.

パラメータ:
compressed - buffer[pos() ... limit()) containing the input data
uncompressed - output of the the uncompressed data. It uses buffer[pot()..]
戻り値:
uncompressed data size
例外:
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
例外:
IOException

uncompressCharArray

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

uncompressDoubleArray

public static double[] uncompressDoubleArray(byte[] input)
                                      throws IOException
例外:
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.

パラメータ:
input -
戻り値:
umcompressed byte size of the the given input data
例外:
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.

パラメータ:
input -
offset -
length -
戻り値:
umcompressed byte size of the the given input data
例外:
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.

パラメータ:
compressed - input data [pos() ... limit())
戻り値:
uncompressed byte length of the given input
例外:
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
例外:
IOException

uncompressFloatArray

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

uncompressIntArray

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

uncompressIntArray

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

uncompressLongArray

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

uncompressLongArray

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

uncompressShortArray

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

uncompressShortArray

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

uncompressString

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

uncompressString

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

uncompressString

public static String uncompressString(byte[] input,
                                      int offset,
                                      int length,
                                      String encoding)
                               throws IOException,
                                      UnsupportedEncodingException
例外:
IOException
UnsupportedEncodingException

uncompressString

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


Copyright © 2011. All Rights Reserved.