Class ChunkEncoderFactory
java.lang.Object
com.ning.compress.lzf.util.ChunkEncoderFactory
Simple helper class used for loading
ChunkEncoder implementations, based on criteria
such as "fastest available" or "safe to run anywhere".-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ChunkEncoderConvenience method, equivalent to:return optimalInstance(LZFChunk.MAX_CHUNK_LEN);static ChunkEncoderoptimalInstance(int totalLength) Method to use for getting compressor instance that uses the most optimal available methods for underlying data access.static ChunkEncoderoptimalInstance(int totalLength, BufferRecycler bufferRecycler) Method to use for getting compressor instance that uses the most optimal available methods for underlying data access.static ChunkEncoderoptimalInstance(BufferRecycler bufferRecycler) Convenience method, equivalent to:return optimalInstance(LZFChunk.MAX_CHUNK_LEN, bufferRecycler);static ChunkEncoderoptimalNonAllocatingInstance(int totalLength) Factory method for constructing encoder that is always passed buffer externally, so that it will not (nor need) allocate encoding buffer.static ChunkEncoderoptimalNonAllocatingInstance(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 ChunkEncoderConvenience method, equivalent to:return safeInstance(LZFChunk.MAX_CHUNK_LEN);static ChunkEncodersafeInstance(int totalLength) Method that can be used to ensure that a "safe" compressor instance is loaded.static ChunkEncodersafeInstance(int totalLength, BufferRecycler bufferRecycler) Method that can be used to ensure that a "safe" compressor instance is loaded.static ChunkEncodersafeInstance(BufferRecycler bufferRecycler) Convenience method, equivalent to:return safeInstance(LZFChunk.MAX_CHUNK_LEN, bufferRecycler);static ChunkEncodersafeNonAllocatingInstance(int totalLength) Factory method for constructing encoder that is always passed buffer externally, so that it will not (nor need) allocate encoding buffer.static ChunkEncodersafeNonAllocatingInstance(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.
-
Constructor Details
-
ChunkEncoderFactory
public ChunkEncoderFactory()
-
-
Method Details
-
optimalInstance
Convenience method, equivalent to:return optimalInstance(LZFChunk.MAX_CHUNK_LEN);- Returns:
- ChunkEncoder constructed
-
optimalInstance
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
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
Convenience method, equivalent to:return safeInstance(LZFChunk.MAX_CHUNK_LEN);- Returns:
- ChunkEncoder constructed
-
safeInstance
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
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
Convenience method, equivalent to:return optimalInstance(LZFChunk.MAX_CHUNK_LEN, bufferRecycler);- Returns:
- ChunkEncoder constructed
-
optimalInstance
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
Convenience method, equivalent to:return safeInstance(LZFChunk.MAX_CHUNK_LEN, bufferRecycler);- Returns:
- ChunkEncoder constructed
-
safeInstance
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.
-