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 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 String getNativeLibraryVersion()
          Get the native library version of the snappy
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 a data of the given byte size.
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 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.
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

Snappy

public Snappy()
メソッドの詳細

getNativeLibraryVersion

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

戻り値:
native library version

compress

public static byte[] compress(byte[] input)
                       throws SnappyException
High-level API for compressing the input byte array. This method performs array copy to generate the result. If you want to save this cost, use compress(byte[], int, int, byte[], int) or compress(ByteBuffer, ByteBuffer).

パラメータ:
input - the input data
戻り値:
the compressed byte array
例外:
SnappyException

uncompress

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

パラメータ:
input -
戻り値:
the uncompressed byte array
例外:
SnappyException

compress

public static int compress(ByteBuffer uncompressed,
                           ByteBuffer compressed)
                    throws SnappyException
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
SnappyException

compress

public static int compress(byte[] input,
                           int inputOffset,
                           int inputLength,
                           byte[] output,
                           int outputOffset)
                    throws SnappyException
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
例外:
SnappyException - when failed to access the input/output buffer

uncompress

public static int uncompress(ByteBuffer compressed,
                             ByteBuffer uncompressed)
                      throws SnappyException
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
例外:
SnappyException - when failed to uncompress the given input
SnappyError - when the input is not a direct buffer

uncompress

public static int uncompress(byte[] input,
                             int inputOffset,
                             int inputLength,
                             byte[] output,
                             int outputOffset)
                      throws SnappyException
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
例外:
SnappyException

uncompressedLength

public static int uncompressedLength(ByteBuffer compressed)
                              throws SnappyException
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
例外:
SnappyException - when failed to uncompress the given input. The error code is SnappyErrorCode.PARSING_ERROR
SnappyError - when the input is not a direct buffer

uncompressedLength

public static int uncompressedLength(byte[] input,
                                     int offset,
                                     int length)
                              throws SnappyException
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
例外:
SnappyException - when failed to uncompress the given input. The error code is SnappyErrorCode.PARSING_ERROR

maxCompressedLength

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

パラメータ:
byteSize - byte size of the data to compress
戻り値:
maximum byte size of the compressed data

isValidCompressedBuffer

public static boolean isValidCompressedBuffer(ByteBuffer compressed)
                                       throws SnappyException
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.

例外:
SnappyException

isValidCompressedBuffer

public static boolean isValidCompressedBuffer(byte[] input,
                                              int offset,
                                              int length)
                                       throws SnappyException
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.

例外:
SnappyException


Copyright © 2011. All Rights Reserved.