public class Compressor
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Compressor.ByteBufferBackedInputStream
Use this class when decompressing GZIP data from a ByteBuffer.
|
Modifier | Constructor and Description |
---|---|
protected |
Compressor()
Constructor to defeat instantiation.
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
compressGZIP(byte[] ungzipped)
GZIP compression.
|
static byte[] |
compressGZIP(byte[] ungzipped,
int offset,
int length)
GZIP compression.
|
static int |
compressLZ4(byte[] src,
int srcOff,
int srcSize,
byte[] dst,
int dstOff,
int maxSize)
Fastest LZ4 compression.
|
static int |
compressLZ4(java.nio.ByteBuffer src,
int srcSize,
java.nio.ByteBuffer dst,
int maxSize)
Fastest LZ4 compression.
|
static int |
compressLZ4(java.nio.ByteBuffer src,
int srcOff,
int srcSize,
java.nio.ByteBuffer dst,
int dstOff,
int maxSize)
Fastest LZ4 compression.
|
static int |
compressLZ4Best(byte[] src,
int srcOff,
int srcSize,
byte[] dst,
int dstOff,
int maxSize)
Highest LZ4 compression.
|
static int |
compressLZ4Best(java.nio.ByteBuffer src,
int srcSize,
java.nio.ByteBuffer dst,
int maxSize)
Highest LZ4 compression.
|
static int |
compressLZ4Best(java.nio.ByteBuffer src,
int srcOff,
int srcSize,
java.nio.ByteBuffer dst,
int dstOff,
int maxSize)
Highest LZ4 compression.
|
static byte[] |
getCompressedBuffer(CompressionType compressionType,
byte[] buffer)
Returns compressed buffer.
|
static Compressor |
getInstance()
Get the single instance of this class.
|
static int |
getMaxCompressedLength(CompressionType compressionType,
int uncompressedLength)
Returns the maximum number of bytes needed to compress the given length
of uncompressed data.
|
static byte[] |
getUnCompressedBuffer(CompressionType compressionType,
byte[] compressedBuffer)
Returns uncompressed buffer.
|
static byte[] |
uncompressGZIP(byte[] gzipped)
GZIP decompression.
|
static byte[] |
uncompressGZIP(byte[] gzipped,
int off,
int length)
GZIP decompression.
|
static byte[] |
uncompressGZIP(java.nio.ByteBuffer gzipped)
GZIP decompression.
|
static int |
uncompressLZ4(byte[] src,
int srcOff,
int srcSize,
byte[] dst,
int dstOff)
LZ4 decompression.
|
static byte[] |
uncompressLZ4(byte[] src,
int srcOff,
int srcSize,
int maxDestLen)
LZ4 decompression.
|
static int |
uncompressLZ4(java.nio.ByteBuffer src,
int srcSize,
java.nio.ByteBuffer dst)
LZ4 decompression.
|
static int |
uncompressLZ4(java.nio.ByteBuffer src,
int srcOff,
int srcSize,
java.nio.ByteBuffer dst)
LZ4 decompression.
|
public static Compressor getInstance()
public static int getMaxCompressedLength(CompressionType compressionType, int uncompressedLength)
compressionType
- type of data compression to do
(0=none, 1=lz4 fast, 2=lz4 best, 3=gzip).
Default to none.uncompressedLength
- uncompressed data length in bytes.public static byte[] getCompressedBuffer(CompressionType compressionType, byte[] buffer)
compressionType
- type of data compression to do
(0=none, 1=lz4 fast, 2=lz4 best, 3=gzip).
Default to none.buffer
- uncompressed buffer.public static byte[] getUnCompressedBuffer(CompressionType compressionType, byte[] compressedBuffer) throws net.jpountz.lz4.LZ4Exception
compressionType
- type of data compression to undo
(0=none, 1=lz4 fast, 2=lz4 best, 3=gzip).
Default to none.compressedBuffer
- uncompressed array.net.jpountz.lz4.LZ4Exception
- if not enough room in allocated array
(3x compressed) to hold LZ4 uncompressed data.public static byte[] compressGZIP(byte[] ungzipped)
ungzipped
- uncompressed data.public static byte[] compressGZIP(byte[] ungzipped, int offset, int length)
ungzipped
- uncompressed data.offset
- offset into ungzipped arraylength
- length of valid data in bytespublic static byte[] uncompressGZIP(byte[] gzipped)
gzipped
- compressed data.public static byte[] uncompressGZIP(byte[] gzipped, int off, int length)
gzipped
- compressed data.off
- offset into gzipped array.length
- max number of bytes to read from gzipped.public static byte[] uncompressGZIP(java.nio.ByteBuffer gzipped)
gzipped
- compressed data.public static int compressLZ4(java.nio.ByteBuffer src, int srcSize, java.nio.ByteBuffer dst, int maxSize) throws HipoException
src
- source of uncompressed data.srcSize
- number of bytes to compress.dst
- destination buffer.maxSize
- maximum number of bytes to write in dst.HipoException
- if maxSize < max # of compressed bytespublic static int compressLZ4(byte[] src, int srcOff, int srcSize, byte[] dst, int dstOff, int maxSize) throws HipoException
src
- source of uncompressed data.srcOff
- start offset in src.srcSize
- number of bytes to compress.dst
- destination array.dstOff
- start offset in dst.maxSize
- maximum number of bytes to write in dst.HipoException
- if maxSize < max # of compressed bytespublic static int compressLZ4(java.nio.ByteBuffer src, int srcOff, int srcSize, java.nio.ByteBuffer dst, int dstOff, int maxSize) throws HipoException
src
- source of uncompressed data.srcOff
- start offset in src.srcSize
- number of bytes to compress.dst
- destination array.dstOff
- start offset in dst.maxSize
- maximum number of bytes to write in dst.HipoException
- if maxSize < max # of compressed bytespublic static int compressLZ4Best(java.nio.ByteBuffer src, int srcSize, java.nio.ByteBuffer dst, int maxSize) throws HipoException
src
- source of uncompressed data.srcSize
- number of bytes to compress.dst
- destination buffer.maxSize
- maximum number of bytes to write in dst.HipoException
- if maxSize < max # of compressed bytespublic static int compressLZ4Best(byte[] src, int srcOff, int srcSize, byte[] dst, int dstOff, int maxSize) throws HipoException
src
- source of uncompressed data.srcOff
- start offset in src.srcSize
- number of bytes to compress.dst
- destination array.dstOff
- start offset in dst.maxSize
- maximum number of bytes to write in dst.HipoException
- if maxSize < max # of compressed bytespublic static int compressLZ4Best(java.nio.ByteBuffer src, int srcOff, int srcSize, java.nio.ByteBuffer dst, int dstOff, int maxSize) throws HipoException
src
- source of uncompressed data.srcOff
- start offset in src.srcSize
- number of bytes to compress.dst
- destination array.dstOff
- start offset in dst.maxSize
- maximum number of bytes to write in dst.HipoException
- if maxSize < max # of compressed bytespublic static int uncompressLZ4(java.nio.ByteBuffer src, int srcSize, java.nio.ByteBuffer dst) throws HipoException
src
- source of compressed data.srcSize
- number of compressed bytes.dst
- destination array.HipoException
- if dst is too small to hold uncompressed datapublic static int uncompressLZ4(java.nio.ByteBuffer src, int srcOff, int srcSize, java.nio.ByteBuffer dst) throws HipoException
src
- source of compressed data.srcOff
- start offset in src.srcSize
- number of compressed bytes.dst
- destination array.HipoException
- if dst is too small to hold uncompressed datapublic static int uncompressLZ4(byte[] src, int srcOff, int srcSize, byte[] dst, int dstOff) throws HipoException
src
- source of compressed data.srcOff
- start offset in src.srcSize
- number of compressed bytes.dst
- destination array.dstOff
- start offset in dst.HipoException
- if (dst.length - dstOff) is too small
to hold uncompressed datapublic static byte[] uncompressLZ4(byte[] src, int srcOff, int srcSize, int maxDestLen)
src
- source of compressed data.srcOff
- start offset in src.srcSize
- number of compressed bytes.maxDestLen
- max available bytes to hold uncompressed data.