Class CompressPacketOutputStream

    • Field Detail

      • logger

        private static final Logger logger
      • EMPTY_ARRAY

        private static final byte[] EMPTY_ARRAY
      • MIN_COMPRESSION_RATIO

        private static final float MIN_COMPRESSION_RATIO
        See Also:
        Constant Field Values
      • header

        private final byte[] header
      • subHeader

        private final byte[] subHeader
      • maxPacketLength

        private int maxPacketLength
      • compressSeqNo

        private int compressSeqNo
      • remainingData

        private byte[] remainingData
      • lastPacketExactMaxPacketLength

        private boolean lastPacketExactMaxPacketLength
    • Constructor Detail

      • CompressPacketOutputStream

        public CompressPacketOutputStream​(java.io.OutputStream out,
                                          int maxQuerySizeToLog)
    • Method Detail

      • initialPacketPos

        public int initialPacketPos()
      • flushBuffer

        protected void flushBuffer​(boolean commandEnd)
                            throws java.io.IOException
        Flush the internal buffer.

        Compression add a 7 header :

        1. 3 byte compression length
        2. 1 byte compress sequence number
        3. 3 bytes uncompress length

        in case packet isn't compressed (last 3 bytes == 0):

        1. 3 byte uncompress length
        2. 1 byte compress sequence number
        3. 3 bytes with 0 value

        Content correspond to standard content.

        1. 3 byte length
        2. 1 byte sequence number (!= than compress sequence number)
        3. sub-content

        Problem is when standard content is bigger than 16mb : content will not send 4byte standard header + 16mb content, since packet are limited to 16mb then 4 bytes standard header + 16mb - 4 bytes content. the ending 4 bytes are waiting to be send. next packet will then send the waiting data before next packet, putting more waiting data is needed. if ending data is exactly MAX_PACKET_LENGTH length, then an empty packet must be send.

        Specified by:
        flushBuffer in class AbstractPacketOutputStream
        Parameters:
        commandEnd - command end
        Throws:
        java.io.IOException - id connection error occur.