Top Description Fields Constructors Methods
com.ning.compress.lzf

public Class LZFEncoder

extends Object
Class Inheritance
Imports
com.ning.compress.BufferRecycler, com.ning.compress.lzf.util.ChunkEncoderFactory

Encoder that handles splitting of input into chunks to encode, calls ChunkEncoder to compress individual chunks and combines resulting chunks into contiguous output byte array.
Author
Tatu Saloranta

Field Summary

Modifier and TypeField and Description
private static final int
public static final int
private static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static int
appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr)

Alternate version that accepts pre-allocated output buffer.

public static int
appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr, BufferRecycler bufferRecycler)

Alternate version that accepts pre-allocated output buffer.

public static int
appendEncoded(ChunkEncoder enc, byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr)

Alternate version that accepts pre-allocated output buffer.

public static byte[]
encode(byte[] data)

Method for compressing given input data using LZF encoding and block structure (compatible with lzf command line utility).

public static byte[]
encode(byte[] data, int offset, int length)

Method for compressing given input data using LZF encoding and block structure (compatible with lzf command line utility).

public static byte[]
encode(byte[] data, int offset, int length, BufferRecycler bufferRecycler)

Method for compressing given input data using LZF encoding and block structure (compatible with lzf command line utility).

public static byte[]
encode(ChunkEncoder enc, byte[] data, int length)

Compression method that uses specified ChunkEncoder for actual encoding.

public static byte[]
encode(ChunkEncoder enc, byte[] data, int offset, int length)

Method that encodes given input using provided ChunkEncoder, and aggregating it into a single byte array and returning that.

public static int
estimateMaxWorkspaceSize(int inputSize)

Helper method that can be used to estimate maximum space needed to try compression of given amount of data.

public static int
safeAppendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr)

Alternate version that accepts pre-allocated output buffer.

public static int
safeAppendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr, BufferRecycler bufferRecycler)

Alternate version that accepts pre-allocated output buffer.

public static byte[]
safeEncode(byte[] data)

Method that will use "safe" ChunkEncoder, as produced by ChunkEncoderFactory#safeInstance, for encoding.

public static byte[]
safeEncode(byte[] data, int offset, int length)

Method that will use "safe" ChunkEncoder, as produced by ChunkEncoderFactory#safeInstance, for encoding.

public static byte[]
safeEncode(byte[] data, int offset, int length, BufferRecycler bufferRecycler)

Method that will use "safe" ChunkEncoder, as produced by ChunkEncoderFactory#safeInstance, for encoding.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FULL_UNCOMP_ENCODED_CHUNKback to summary
private static final int FULL_UNCOMP_ENCODED_CHUNK
MAX_CHUNK_RESULT_SIZEback to summary
public static final int MAX_CHUNK_RESULT_SIZE
MAX_CHUNK_WORKSPACE_SIZEback to summary
private static final int MAX_CHUNK_WORKSPACE_SIZE

Constructor Detail

LZFEncoderback to summary
private LZFEncoder()

Method Detail

appendEncodedback to summary
public static int appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr)

Alternate version that accepts pre-allocated output buffer.

Note that ChunkEncoder instance used is one produced by ChunkEncoderFactory#optimalNonAllocatingInstance, which typically is "unsafe" instance if one can be used on current JVM.

appendEncodedback to summary
public static int appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr, BufferRecycler bufferRecycler)

Alternate version that accepts pre-allocated output buffer.

Note that ChunkEncoder instance used is one produced by ChunkEncoderFactory#optimalNonAllocatingInstance, which typically is "unsafe" instance if one can be used on current JVM.

appendEncodedback to summary
public static int appendEncoded(ChunkEncoder enc, byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr)

Alternate version that accepts pre-allocated output buffer.

encodeback to summary
public static byte[] encode(byte[] data)

Method for compressing given input data using LZF encoding and block structure (compatible with lzf command line utility). Result consists of a sequence of chunks.

Note that ChunkEncoder instance used is one produced by ChunkEncoderFactory#optimalInstance, which typically is "unsafe" instance if one can be used on current JVM.

encodeback to summary
public static byte[] encode(byte[] data, int offset, int length)

Method for compressing given input data using LZF encoding and block structure (compatible with lzf command line utility). Result consists of a sequence of chunks.

Note that ChunkEncoder instance used is one produced by ChunkEncoderFactory#optimalInstance, which typically is "unsafe" instance if one can be used on current JVM.

encodeback to summary
public static byte[] encode(byte[] data, int offset, int length, BufferRecycler bufferRecycler)

Method for compressing given input data using LZF encoding and block structure (compatible with lzf command line utility). Result consists of a sequence of chunks.

Note that ChunkEncoder instance used is one produced by ChunkEncoderFactory#optimalInstance, which typically is "unsafe" instance if one can be used on current JVM.

encodeback to summary
public static byte[] encode(ChunkEncoder enc, byte[] data, int length)

Compression method that uses specified ChunkEncoder for actual encoding.

encodeback to summary
public static byte[] encode(ChunkEncoder enc, byte[] data, int offset, int length)

Method that encodes given input using provided ChunkEncoder, and aggregating it into a single byte array and returning that.

Note

method does NOT call ChunkEncoder#close; caller is responsible for doing that after it is done using the encoder.

estimateMaxWorkspaceSizeback to summary
public static int estimateMaxWorkspaceSize(int inputSize)

Helper method that can be used to estimate maximum space needed to try compression of given amount of data. This is slightly larger than maximum resulting content since compressor has a choice of uncompressed chunks to use, but that is only done after compression fails to reduce size; and this temporary expansion of up to 3.3% or so (1 indicator for every 31 bytes of uncompressed data) is more than what eventual expansion would be (5 bytes header per each uncompressed chunk, usually 0.01%).

safeAppendEncodedback to summary
public static int safeAppendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr)

Alternate version that accepts pre-allocated output buffer.

Method that will use "safe" ChunkEncoder, as produced by ChunkEncoderFactory#safeInstance, for encoding. Safe here means that it does not use any non-compliant features beyond core JDK.

safeAppendEncodedback to summary
public static int safeAppendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr, BufferRecycler bufferRecycler)

Alternate version that accepts pre-allocated output buffer.

Method that will use "safe" ChunkEncoder, as produced by ChunkEncoderFactory#safeInstance, for encoding. Safe here means that it does not use any non-compliant features beyond core JDK.

safeEncodeback to summary
public static byte[] safeEncode(byte[] data)

Method that will use "safe" ChunkEncoder, as produced by ChunkEncoderFactory#safeInstance, for encoding. Safe here means that it does not use any non-compliant features beyond core JDK.

safeEncodeback to summary
public static byte[] safeEncode(byte[] data, int offset, int length)

Method that will use "safe" ChunkEncoder, as produced by ChunkEncoderFactory#safeInstance, for encoding. Safe here means that it does not use any non-compliant features beyond core JDK.

safeEncodeback to summary
public static byte[] safeEncode(byte[] data, int offset, int length, BufferRecycler bufferRecycler)

Method that will use "safe" ChunkEncoder, as produced by ChunkEncoderFactory#safeInstance, for encoding. Safe here means that it does not use any non-compliant features beyond core JDK.