Package com.ning.compress.lzf.util
Class ChunkEncoderFactory
- java.lang.Object
-
- com.ning.compress.lzf.util.ChunkEncoderFactory
-
public class ChunkEncoderFactory extends java.lang.Object
Simple helper class used for loadingChunkEncoder
implementations, based on criteria such as "fastest available" or "safe to run anywhere".
-
-
Constructor Summary
Constructors Constructor Description ChunkEncoderFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ChunkEncoder
optimalInstance()
Convenience method, equivalent to:return optimalInstance(LZFChunk.MAX_CHUNK_LEN);
static ChunkEncoder
optimalInstance(int totalLength)
Method to use for getting compressor instance that uses the most optimal available methods for underlying data access.static ChunkEncoder
optimalInstance(int totalLength, BufferRecycler bufferRecycler)
Method to use for getting compressor instance that uses the most optimal available methods for underlying data access.static ChunkEncoder
optimalInstance(BufferRecycler bufferRecycler)
Convenience method, equivalent to:return optimalInstance(LZFChunk.MAX_CHUNK_LEN, bufferRecycler);
static ChunkEncoder
optimalNonAllocatingInstance(int totalLength)
Factory method for constructing encoder that is always passed buffer externally, so that it will not (nor need) allocate encoding buffer.static ChunkEncoder
optimalNonAllocatingInstance(int totalLength, BufferRecycler bufferRecycler)
Factory method for constructing encoder that is always passed buffer externally, so that it will not (nor need) allocate encoding buffer.static ChunkEncoder
safeInstance()
Convenience method, equivalent to:return safeInstance(LZFChunk.MAX_CHUNK_LEN);
static ChunkEncoder
safeInstance(int totalLength)
Method that can be used to ensure that a "safe" compressor instance is loaded.static ChunkEncoder
safeInstance(int totalLength, BufferRecycler bufferRecycler)
Method that can be used to ensure that a "safe" compressor instance is loaded.static ChunkEncoder
safeInstance(BufferRecycler bufferRecycler)
Convenience method, equivalent to:return safeInstance(LZFChunk.MAX_CHUNK_LEN, bufferRecycler);
static ChunkEncoder
safeNonAllocatingInstance(int totalLength)
Factory method for constructing encoder that is always passed buffer externally, so that it will not (nor need) allocate encoding buffer.static ChunkEncoder
safeNonAllocatingInstance(int totalLength, BufferRecycler bufferRecycler)
Factory method for constructing encoder that is always passed buffer externally, so that it will not (nor need) allocate encoding buffer.
-
-
-
Method Detail
-
optimalInstance
public static ChunkEncoder optimalInstance()
Convenience method, equivalent to:return optimalInstance(LZFChunk.MAX_CHUNK_LEN);
- Returns:
- ChunkEncoder constructed
-
optimalInstance
public static ChunkEncoder optimalInstance(int totalLength)
Method to use for getting compressor instance that uses the most optimal available methods for underlying data access. It should be safe to call this method as implementations are dynamically loaded; however, on some non-standard platforms it may be necessary to either directly load instances, or usesafeInstance()
.Uses a ThreadLocal soft-referenced BufferRecycler instance.
- Parameters:
totalLength
- Expected total length of content to compress; only matters for content that is smaller than maximum chunk size (64k), to optimize encoding hash tables- Returns:
- ChunkEncoder constructed
-
optimalNonAllocatingInstance
public static ChunkEncoder optimalNonAllocatingInstance(int totalLength)
Factory method for constructing encoder that is always passed buffer externally, so that it will not (nor need) allocate encoding buffer.Uses a ThreadLocal soft-referenced BufferRecycler instance.
- Returns:
- ChunkEncoder constructed
-
safeInstance
public static ChunkEncoder safeInstance()
Convenience method, equivalent to:return safeInstance(LZFChunk.MAX_CHUNK_LEN);
- Returns:
- ChunkEncoder constructed
-
safeInstance
public static ChunkEncoder safeInstance(int totalLength)
Method that can be used to ensure that a "safe" compressor instance is loaded. Safe here means that it should work on any and all Java platforms.Uses a ThreadLocal soft-referenced BufferRecycler instance.
- Parameters:
totalLength
- Expected total length of content to compress; only matters for content that is smaller than maximum chunk size (64k), to optimize encoding hash tables- Returns:
- ChunkEncoder constructed
-
safeNonAllocatingInstance
public static ChunkEncoder safeNonAllocatingInstance(int totalLength)
Factory method for constructing encoder that is always passed buffer externally, so that it will not (nor need) allocate encoding buffer.Uses a ThreadLocal soft-referenced BufferRecycler instance.
- Returns:
- ChunkEncoder constructed
-
optimalInstance
public static ChunkEncoder optimalInstance(BufferRecycler bufferRecycler)
Convenience method, equivalent to:return optimalInstance(LZFChunk.MAX_CHUNK_LEN, bufferRecycler);
- Returns:
- ChunkEncoder constructed
-
optimalInstance
public static ChunkEncoder optimalInstance(int totalLength, BufferRecycler bufferRecycler)
Method to use for getting compressor instance that uses the most optimal available methods for underlying data access. It should be safe to call this method as implementations are dynamically loaded; however, on some non-standard platforms it may be necessary to either directly load instances, or usesafeInstance()
.- Parameters:
totalLength
- Expected total length of content to compress; only matters for content that is smaller than maximum chunk size (64k), to optimize encoding hash tablesbufferRecycler
- The BufferRecycler instance- Returns:
- ChunkEncoder constructed
-
optimalNonAllocatingInstance
public static ChunkEncoder optimalNonAllocatingInstance(int totalLength, BufferRecycler bufferRecycler)
Factory method for constructing encoder that is always passed buffer externally, so that it will not (nor need) allocate encoding buffer.- Returns:
- ChunkEncoder constructed
-
safeInstance
public static ChunkEncoder safeInstance(BufferRecycler bufferRecycler)
Convenience method, equivalent to:return safeInstance(LZFChunk.MAX_CHUNK_LEN, bufferRecycler);
- Returns:
- ChunkEncoder constructed
-
safeInstance
public static ChunkEncoder safeInstance(int totalLength, BufferRecycler bufferRecycler)
Method that can be used to ensure that a "safe" compressor instance is loaded. Safe here means that it should work on any and all Java platforms.- Parameters:
totalLength
- Expected total length of content to compress; only matters for content that is smaller than maximum chunk size (64k), to optimize encoding hash tablesbufferRecycler
- The BufferRecycler instance- Returns:
- ChunkEncoder constructed
-
safeNonAllocatingInstance
public static ChunkEncoder safeNonAllocatingInstance(int totalLength, BufferRecycler bufferRecycler)
Factory method for constructing encoder that is always passed buffer externally, so that it will not (nor need) allocate encoding buffer.
-
-