Class SnappyCompressor


  • final class SnappyCompressor
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static int bytesBetweenHashLookups​(int skip)  
      static int compress​(byte[] uncompressed, int uncompressedOffset, int uncompressedLength, byte[] compressed, int compressedOffset)  
      private static int compressFragment​(byte[] input, int inputOffset, int inputSize, byte[] output, int outputIndex, short[] table)  
      private static int[] emitCopies​(byte[] input, int inputOffset, int inputSize, int ipIndex, byte[] output, int outputIndex, short[] table, int shift, int candidateIndex)  
      private static int emitCopy​(byte[] output, int outputIndex, int offset, int length)  
      private static int emitCopyLessThan64​(byte[] output, int outputIndex, int offset, int length)  
      private static int emitLiteral​(byte[] output, int outputIndex, byte[] literal, int literalIndex, int length, boolean allowFastPath)  
      private static int[] findCandidate​(byte[] input, int ipIndex, int ipLimit, int inputOffset, int shift, short[] table, int skip)  
      private static int findMatchLength​(byte[] s1, int s1Index, byte[] s2, int s2Index, int s2Limit)  
      private static int getHashTableSize​(int inputSize)  
      private static int hashBytes​(int bytes, int shift)  
      private static int log2Floor​(int n)  
      static int maxCompressedLength​(int sourceLength)  
      private static int writeUncompressedLength​(byte[] compressed, int compressedOffset, int uncompressedLength)
      Writes the uncompressed length as variable length integer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SnappyCompressor

        SnappyCompressor()
    • Method Detail

      • maxCompressedLength

        public static int maxCompressedLength​(int sourceLength)
      • compress

        public static int compress​(byte[] uncompressed,
                                   int uncompressedOffset,
                                   int uncompressedLength,
                                   byte[] compressed,
                                   int compressedOffset)
      • compressFragment

        private static int compressFragment​(byte[] input,
                                            int inputOffset,
                                            int inputSize,
                                            byte[] output,
                                            int outputIndex,
                                            short[] table)
      • findCandidate

        private static int[] findCandidate​(byte[] input,
                                           int ipIndex,
                                           int ipLimit,
                                           int inputOffset,
                                           int shift,
                                           short[] table,
                                           int skip)
      • bytesBetweenHashLookups

        private static int bytesBetweenHashLookups​(int skip)
      • emitCopies

        private static int[] emitCopies​(byte[] input,
                                        int inputOffset,
                                        int inputSize,
                                        int ipIndex,
                                        byte[] output,
                                        int outputIndex,
                                        short[] table,
                                        int shift,
                                        int candidateIndex)
      • emitLiteral

        private static int emitLiteral​(byte[] output,
                                       int outputIndex,
                                       byte[] literal,
                                       int literalIndex,
                                       int length,
                                       boolean allowFastPath)
      • emitCopyLessThan64

        private static int emitCopyLessThan64​(byte[] output,
                                              int outputIndex,
                                              int offset,
                                              int length)
      • emitCopy

        private static int emitCopy​(byte[] output,
                                    int outputIndex,
                                    int offset,
                                    int length)
      • findMatchLength

        private static int findMatchLength​(byte[] s1,
                                           int s1Index,
                                           byte[] s2,
                                           int s2Index,
                                           int s2Limit)
      • getHashTableSize

        private static int getHashTableSize​(int inputSize)
      • hashBytes

        private static int hashBytes​(int bytes,
                                     int shift)
      • log2Floor

        private static int log2Floor​(int n)
      • writeUncompressedLength

        private static int writeUncompressedLength​(byte[] compressed,
                                                   int compressedOffset,
                                                   int uncompressedLength)
        Writes the uncompressed length as variable length integer.