public class Snappy
extends java.lang.Object
| Constructor and Description |
|---|
Snappy() |
| Modifier and Type | Method and Description |
|---|---|
static void |
arrayCopy(java.lang.Object src,
int offset,
int byteLength,
java.lang.Object dest,
int dest_offset)
Copy bytes from source to destination
|
static void |
cleanUp()
Clean up a temporary file (native lib) generated by snappy-java.
|
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(java.nio.ByteBuffer uncompressed,
java.nio.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(java.lang.String s)
Compress the input String
|
static byte[] |
compress(java.lang.String s,
java.nio.charset.Charset encoding)
Compress the input string using the given encoding
|
static byte[] |
compress(java.lang.String s,
java.lang.String encoding)
Compress the input string using the given encoding
|
static java.lang.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(java.nio.ByteBuffer compressed)
Returns true iff the contents of compressed buffer [pos() ...
|
static boolean |
isValidCompressedBuffer(long inputAddr,
long offset,
long length)
Returns true iff the contents of compressed buffer [offset,
offset+length) can be uncompressed successfully.
|
static int |
maxCompressedLength(int byteSize)
Get the maximum byte size needed for compressing data of the given byte
size.
|
static long |
rawCompress(long inputAddr,
long inputSize,
long destAddr)
Zero-copy compress using memory addresses.
|
static byte[] |
rawCompress(java.lang.Object data,
int byteSize)
Compress the input data and produce a byte array of the uncompressed data
|
static int |
rawCompress(java.lang.Object input,
int inputOffset,
int inputLength,
byte[] output,
int outputOffset)
Compress the input buffer [offset,...
|
static int |
rawUncompress(byte[] input,
int inputOffset,
int inputLength,
java.lang.Object output,
int outputOffset)
Uncompress the content in the input buffer.
|
static long |
rawUncompress(long inputAddr,
long inputSize,
long destAddr)
Zero-copy decompress using memory addresses.
|
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(java.nio.ByteBuffer compressed,
java.nio.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(java.nio.ByteBuffer compressed)
Get the uncompressed byte size of the given compressed input.
|
static long |
uncompressedLength(long inputAddr,
long len)
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 java.lang.String |
uncompressString(byte[] input)
Uncompress the input as a String
|
static java.lang.String |
uncompressString(byte[] input,
java.nio.charset.Charset encoding)
Uncompress the input as a String of the given encoding
|
static java.lang.String |
uncompressString(byte[] input,
int offset,
int length)
Uncompress the input[offset, offset+length) as a String
|
static java.lang.String |
uncompressString(byte[] input,
int offset,
int length,
java.nio.charset.Charset encoding)
Uncompress the input[offset, offset+length) as a String of the given
encoding
|
static java.lang.String |
uncompressString(byte[] input,
int offset,
int length,
java.lang.String encoding)
Uncompress the input[offset, offset+length) as a String of the given
encoding
|
static java.lang.String |
uncompressString(byte[] input,
java.lang.String encoding)
Uncompress the input as a String of the given encoding
|
public static void cleanUp()
public static void arrayCopy(java.lang.Object src,
int offset,
int byteLength,
java.lang.Object dest,
int dest_offset)
throws java.io.IOException
src - pointer to the source arrayoffset - byte offset in the source arraybyteLength - the number of bytes to copydest - pointer to the destination arraydest_offset - byte offset in the destination arrayjava.io.IOExceptionpublic static byte[] compress(byte[] input)
throws java.io.IOException
compress(byte[], int, int, byte[], int) or
compress(ByteBuffer, ByteBuffer).input - the input datajava.io.IOExceptionpublic static int compress(byte[] input,
int inputOffset,
int inputLength,
byte[] output,
int outputOffset)
throws java.io.IOException
input - inputOffset - inputLength - output - outputOffset - java.io.IOException - when failed to access the input/output bufferpublic static int compress(java.nio.ByteBuffer uncompressed,
java.nio.ByteBuffer compressed)
throws java.io.IOException
uncompressed - buffer[pos() ... limit()) containing the input datacompressed - output of the compressed data. Uses range [pos()..].SnappyError - when the input is not a direct bufferjava.io.IOExceptionpublic static byte[] compress(char[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static byte[] compress(double[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static byte[] compress(float[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static byte[] compress(int[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static byte[] compress(long[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static byte[] compress(short[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static byte[] compress(java.lang.String s)
throws java.io.IOException
s - java.io.IOExceptionpublic static byte[] compress(java.lang.String s,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException,
java.io.IOException
s - encoding - java.io.UnsupportedEncodingExceptionjava.io.IOExceptionpublic static byte[] compress(java.lang.String s,
java.nio.charset.Charset encoding)
throws java.io.IOException
s - encoding - java.io.UnsupportedEncodingExceptionjava.io.IOExceptionpublic static java.lang.String getNativeLibraryVersion()
public static boolean isValidCompressedBuffer(byte[] input,
int offset,
int length)
throws java.io.IOException
java.io.IOExceptionpublic static boolean isValidCompressedBuffer(byte[] input)
throws java.io.IOException
java.io.IOExceptionpublic static boolean isValidCompressedBuffer(java.nio.ByteBuffer compressed)
throws java.io.IOException
java.io.IOExceptionpublic static boolean isValidCompressedBuffer(long inputAddr,
long offset,
long length)
throws java.io.IOException
java.io.IOExceptionpublic static int maxCompressedLength(int byteSize)
byteSize - byte size of the data to compresspublic static long rawCompress(long inputAddr,
long inputSize,
long destAddr)
throws java.io.IOException
inputAddr - input memory addressinputSize - input byte sizedestAddr - destination address of the compressed datajava.io.IOExceptionpublic static long rawUncompress(long inputAddr,
long inputSize,
long destAddr)
throws java.io.IOException
inputAddr - input memory addressinputSize - input byte sizedestAddr - destination address of the uncompressed datajava.io.IOExceptionpublic static byte[] rawCompress(java.lang.Object data,
int byteSize)
throws java.io.IOException
data - input array. The input MUST be an array typebyteSize - the input byte sizejava.io.IOExceptionpublic static int rawCompress(java.lang.Object input,
int inputOffset,
int inputLength,
byte[] output,
int outputOffset)
throws java.io.IOException
input - input array. This MUST be a primitive array typeinputOffset - byte offset at the output arrayinputLength - byte length of the input dataoutput - output array. This MUST be a primitive array typeoutputOffset - byte offset at the output arrayjava.io.IOExceptionpublic static int rawUncompress(byte[] input,
int inputOffset,
int inputLength,
java.lang.Object output,
int outputOffset)
throws java.io.IOException
isValidCompressedBuffer(byte[], int, int) first.input - input byte arrayinputOffset - byte offset in the input byte arrayinputLength - byte length of the input dataoutput - output buffer, MUST be a primitive type arrayoutputOffset - byte offset in the output bufferjava.io.IOException - when failed to uncompress the input datapublic static byte[] uncompress(byte[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static int uncompress(byte[] input,
int inputOffset,
int inputLength,
byte[] output,
int outputOffset)
throws java.io.IOException
isValidCompressedBuffer(byte[], int, int) first.input - inputOffset - inputLength - output - outputOffset - java.io.IOExceptionpublic static int uncompress(java.nio.ByteBuffer compressed,
java.nio.ByteBuffer uncompressed)
throws java.io.IOException
isValidCompressedBuffer(ByteBuffer) first.compressed - buffer[pos() ... limit()) containing the input datauncompressed - output of the the uncompressed data. It uses buffer[pos()..]java.io.IOException - when failed to uncompress the given inputSnappyError - when the input is not a direct bufferpublic static char[] uncompressCharArray(byte[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static char[] uncompressCharArray(byte[] input,
int offset,
int length)
throws java.io.IOException
input - offset - length - java.io.IOExceptionpublic static double[] uncompressDoubleArray(byte[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static int uncompressedLength(byte[] input)
throws java.io.IOException
input - java.io.IOException - when failed to uncompress the given input. The error code is
SnappyErrorCode.PARSING_ERRORpublic static int uncompressedLength(byte[] input,
int offset,
int length)
throws java.io.IOException
input - offset - length - java.io.IOException - when failed to uncompress the given input. The error code is
SnappyErrorCode.PARSING_ERRORpublic static int uncompressedLength(java.nio.ByteBuffer compressed)
throws java.io.IOException
compressed - input data [pos() ... limit())java.io.IOException - when failed to uncompress the given input. The error code is
SnappyErrorCode.PARSING_ERRORSnappyError - when the input is not a direct bufferpublic static long uncompressedLength(long inputAddr,
long len)
throws java.io.IOException
inputAddr - compressed data addresslen - byte length of the inputjava.io.IOException - when failed to uncompress the given input. The error code is
SnappyErrorCode.PARSING_ERRORpublic static float[] uncompressFloatArray(byte[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static float[] uncompressFloatArray(byte[] input,
int offset,
int length)
throws java.io.IOException
input - offset - length - java.io.IOExceptionpublic static int[] uncompressIntArray(byte[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static int[] uncompressIntArray(byte[] input,
int offset,
int length)
throws java.io.IOException
input - offset - length - java.io.IOExceptionpublic static long[] uncompressLongArray(byte[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static long[] uncompressLongArray(byte[] input,
int offset,
int length)
throws java.io.IOException
input - offset - length - java.io.IOExceptionpublic static short[] uncompressShortArray(byte[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static short[] uncompressShortArray(byte[] input,
int offset,
int length)
throws java.io.IOException
input - offset - length - java.io.IOExceptionpublic static java.lang.String uncompressString(byte[] input)
throws java.io.IOException
input - java.io.IOExceptionpublic static java.lang.String uncompressString(byte[] input,
int offset,
int length)
throws java.io.IOException
input - offset - length - java.io.IOExceptionpublic static java.lang.String uncompressString(byte[] input,
int offset,
int length,
java.lang.String encoding)
throws java.io.IOException,
java.io.UnsupportedEncodingException
input - offset - length - encoding - java.io.IOExceptionjava.io.UnsupportedEncodingExceptionpublic static java.lang.String uncompressString(byte[] input,
int offset,
int length,
java.nio.charset.Charset encoding)
throws java.io.IOException,
java.io.UnsupportedEncodingException
input - offset - length - encoding - java.io.IOExceptionjava.io.UnsupportedEncodingExceptionpublic static java.lang.String uncompressString(byte[] input,
java.lang.String encoding)
throws java.io.IOException,
java.io.UnsupportedEncodingException
input - encoding - java.io.IOExceptionjava.io.UnsupportedEncodingExceptionpublic static java.lang.String uncompressString(byte[] input,
java.nio.charset.Charset encoding)
throws java.io.IOException,
java.io.UnsupportedEncodingException
input - encoding - java.io.IOExceptionjava.io.UnsupportedEncodingException