Class VanillaChunkEncoder

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class VanillaChunkEncoder
    extends ChunkEncoder
    • Constructor Detail

      • VanillaChunkEncoder

        public VanillaChunkEncoder​(int totalLength)
        Parameters:
        totalLength - Total encoded length; used for calculating size of hash table to use
      • VanillaChunkEncoder

        protected VanillaChunkEncoder​(int totalLength,
                                      boolean bogus)
        Alternate constructor used when we want to avoid allocation encoding buffer, in cases where caller wants full control over allocations.
      • VanillaChunkEncoder

        public VanillaChunkEncoder​(int totalLength,
                                   BufferRecycler bufferRecycler)
        Parameters:
        totalLength - Total encoded length; used for calculating size of hash table to use
        bufferRecycler - The BufferRecycler instance
      • VanillaChunkEncoder

        protected VanillaChunkEncoder​(int totalLength,
                                      BufferRecycler bufferRecycler,
                                      boolean bogus)
        Alternate constructor used when we want to avoid allocation encoding buffer, in cases where caller wants full control over allocations.
    • Method Detail

      • nonAllocatingEncoder

        public static VanillaChunkEncoder nonAllocatingEncoder​(int totalLength)
      • tryCompress

        protected int tryCompress​(byte[] in,
                                  int inPos,
                                  int inEnd,
                                  byte[] out,
                                  int outPos)
        Main workhorse method that will try to compress given chunk, and return end position (offset to byte after last included byte)
        Specified by:
        tryCompress in class ChunkEncoder
        Returns:
        Output pointer after handling content, such that result - originalOutPost is the actual length of compressed chunk (without header)
      • _handleTail

        private final int _handleTail​(byte[] in,
                                      int inPos,
                                      int inEnd,
                                      byte[] out,
                                      int outPos,
                                      int literals)
      • first

        private final int first​(byte[] in,
                                int inPos)