Class CompressPacketOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.mariadb.jdbc.internal.io.output.AbstractPacketOutputStream
org.mariadb.jdbc.internal.io.output.CompressPacketOutputStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, PacketOutputStream
-
Field Summary
Fields inherited from class AbstractPacketOutputStream
buf, cmdLength, maxAllowedPacket, maxQuerySizeToLog, permitTrace, pos, seqNo, serverThreadLog, threadId, traceCacheFields inherited from class FilterOutputStream
out -
Constructor Summary
ConstructorsConstructorDescriptionCompressPacketOutputStream(OutputStream out, int maxQuerySizeToLog, long threadId) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidflushBuffer(boolean commandEnd) Flush the internal buffer.intintvoidsetMaxAllowedPacket(int maxAllowedPacket) voidstartPacket(int compressSeqNo) voidWrite an empty packet.Methods inherited from class AbstractPacketOutputStream
bufferIsDataAfterMark, checkMaxAllowedLength, checkRemainingSize, exceedMaxLength, flush, flushBufferStopAtMark, getMaxAllowedPacket, getOutputStream, isMarked, mark, permitTrace, resetMark, setServerThreadId, setTraceCache, write, write, write, write, write, write, write, write, write, writeBytes, writeBytesEscaped, writeEmptyPacket, writeFieldLength, writeInt, writeLong, writeShortMethods inherited from class FilterOutputStream
closeMethods inherited from class OutputStream
nullOutputStreamMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PacketOutputStream
close
-
Constructor Details
-
CompressPacketOutputStream
-
-
Method Details
-
getMaxPacketLength
public int getMaxPacketLength()- Specified by:
getMaxPacketLengthin classAbstractPacketOutputStream
-
setMaxAllowedPacket
public void setMaxAllowedPacket(int maxAllowedPacket) - Specified by:
setMaxAllowedPacketin interfacePacketOutputStream- Specified by:
setMaxAllowedPacketin classAbstractPacketOutputStream
-
startPacket
public void startPacket(int compressSeqNo) - Specified by:
startPacketin interfacePacketOutputStream- Specified by:
startPacketin classAbstractPacketOutputStream
-
initialPacketPos
public int initialPacketPos() -
flushBuffer
Flush the internal buffer.Compression add a 7 header :
- 3 byte compression length
- 1 byte compress sequence number
- 3 bytes uncompress length
in case packet isn't compressed (last 3 bytes == 0):
- 3 byte uncompress length
- 1 byte compress sequence number
- 3 bytes with 0 value
Content correspond to standard content.
- 3 byte length
- 1 byte sequence number (!= than compress sequence number)
- 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:
flushBufferin classAbstractPacketOutputStream- Parameters:
commandEnd- command end- Throws:
IOException- id connection error occur.
-
writeEmptyPacket
Write an empty packet.- Specified by:
writeEmptyPacketin interfacePacketOutputStream- Specified by:
writeEmptyPacketin classAbstractPacketOutputStream- Throws:
IOException- if socket error occur.
-