Class SnappyFrameEncoder

    • Field Detail

      • SNAPPY_SLICE_JUMBO_SIZE

        private static final int SNAPPY_SLICE_JUMBO_SIZE
        Both 32767 and 65535 are valid lengths for the Snappy framing format
        See Also:
        Constant Field Values
      • MIN_COMPRESSIBLE_LENGTH

        private static final int MIN_COMPRESSIBLE_LENGTH
        The minimum amount that we'll consider actually attempting to compress. This value is preamble + the minimum length our Snappy service will compress (instead of just emitting a literal).
        See Also:
        Constant Field Values
      • STREAM_START

        private static final byte[] STREAM_START
        All streams should start with the "Stream identifier", containing chunk type 0xff, a length field of 0x6, and 'sNaPpY' in ASCII.
      • snappy

        private final Snappy snappy
      • started

        private boolean started
      • sliceSize

        private final int sliceSize
    • Constructor Detail

      • SnappyFrameEncoder

        public SnappyFrameEncoder()
      • SnappyFrameEncoder

        private SnappyFrameEncoder​(int sliceSize)
    • Method Detail

      • snappyEncoderWithJumboFrames

        public static SnappyFrameEncoder snappyEncoderWithJumboFrames()
        Create a new instance with a 65535 chunk size.
      • writeUnencodedChunk

        private static void writeUnencodedChunk​(ByteBuf in,
                                                ByteBuf out,
                                                int dataLength)
      • setChunkLength

        private static void setChunkLength​(ByteBuf out,
                                           int lengthIdx)
      • writeChunkLength

        private static void writeChunkLength​(ByteBuf out,
                                             int chunkLength)
        Writes the 2-byte chunk length to the output buffer.
        Parameters:
        out - The buffer to write to
        chunkLength - The length to write
      • calculateAndWriteChecksum

        private static void calculateAndWriteChecksum​(ByteBuf slice,
                                                      ByteBuf out)
        Calculates and writes the 4-byte checksum to the output buffer
        Parameters:
        slice - The data to calculate the checksum for
        out - The output buffer to write the checksum to