Class ChunkEncoderFactory


  • public class ChunkEncoderFactory
    extends java.lang.Object
    Simple helper class used for loading ChunkEncoder implementations, based on criteria such as "fastest available" or "safe to run anywhere".
    • Constructor Detail

      • ChunkEncoderFactory

        public ChunkEncoderFactory()
    • 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 use safeInstance().

        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 use safeInstance().
        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
        bufferRecycler - 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 tables
        bufferRecycler - 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.