question: public void sendDirect ( byte [ ] sqlBytes , int offset , int sqlLength , byte commandType ) throws IOException , QueryException { if ( isClosed ( ) ) throw new IOException ( "Stream has already closed" ) ; int seqNo = 0 ; setCompressSeqNo ( 0 ) ; if ( sqlLength + ( useCompression ? 5 : 1 ) > getMaxAllowedPacket ( ) ) { throw new QueryException ( "Could not send query: query size " + ( sqlLength + ( useCompression ? 5 : 1 ) ) + " is >= to max_allowed_packet (" + maxAllowedPacket + ")" , - 1 , INTERRUPTED_EXCEPTION ) ; } if ( ! isUseCompression ( ) ) { if ( sqlLength + 1 <= maxPacketSize ) { byte [ ] packetBuffer = new byte [ sqlLength + 5 ] ; packetBuffer [ 0 ] = ( byte ) ( ( sqlLength + 1 ) & 0xff ) ; packetBuffer [ 1 ] = ( byte ) ( ( sqlLength + 1 ) > > > 8 ) ; packetBuffer [ 2 ] = ( byte ) ( ( sqlLength + 1 ) > > > 16 ) ; packetBuffer [ 3 ] = ( byte ) seqNo ++ ; packetBuffer [ 4 ] = commandType ; System . arraycopy ( sqlBytes , offset , packetBuffer , 5 , sqlLength ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "send packet seq:" + seqNo + " length:" + ( sqlLength + 1 ) + " data:" + Utils . hexdump ( packetBuffer , maxQuerySizeToLog , 4 , sqlLength + 1 ) ) ; } outputStream . write ( packetBuffer ) ; } else { byte [ ] packetBuffer = new byte [ maxPacketSize + 4 ] ; packetBuffer [ 0 ] = ( byte ) ( maxPacketSize & 0xff ) ; packetBuffer [ 1 ] = ( byte ) ( maxPacketSize > > > 8 ) ; packetBuffer [ 2 ] = ( byte ) ( maxPacketSize > > > 16 ) ; packetBuffer [ 3 ] = ( byte ) seqNo ++ ; packetBuffer [ 4 ] = commandType ; System . arraycopy ( sqlBytes , offset , packetBuffer , 5 , maxPacketSize - 1 ) ; int lengthAlreadySend = maxPacketSize - 1 ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "send packet seq:" + seqNo + " length:" + maxPacketSize + " data:" + Utils . hexdump ( packetBuffer , maxQuerySizeToLog , 4 , maxPacketSize ) ) ; } outputStream . write ( packetBuffer ) ; int length ; while ( ( length = sqlLength - lengthAlreadySend ) > 0 ) { if ( length > maxPacketSize ) { packetBuffer [ 0 ] = ( byte ) ( maxPacketSize & 0xff ) ; packetBuffer [ 1 ] = ( byte ) ( maxPacketSize > > > 8 ) ; packetBuffer [ 2 ] = ( byte ) ( maxPacketSize > > > 16 ) ; packetBuffer [ 3 ] = ( byte ) seqNo ++ ; System . arraycopy ( sqlBytes , offset + lengthAlreadySend , packetBuffer , 4 , maxPacketSize ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "send packet seq:" + seqNo + " length:" + maxPacketSize + " data:" + Utils . hexdump ( packetBuffer , maxQuerySizeToLog , 4 , maxPacketSize ) ) ; } outputStream . write ( packetBuffer ) ; lengthAlreadySend += maxPacketSize ; } else { packetBuffer [ 0 ] = ( byte ) ( length & 0xff ) ; packetBuffer [ 1 ] = ( byte ) ( length > > > 8 ) ; packetBuffer [ 2 ] = ( byte ) ( length > > > 16 ) ; packetBuffer [ 3 ] = ( byte ) seqNo ++ ; System . arraycopy ( sqlBytes , offset + lengthAlreadySend , packetBuffer , 4 , length ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "send packet seq:" + seqNo + " length:" + length + " data:" + Utils . hexdump ( packetBuffer , maxQuerySizeToLog , 4 , length ) ) ; } outputStream . write ( packetBuffer , 0 , length + 4 ) ; break ; } } } } else { if ( sqlLength < maxPacketSize ) { byte [ ] packetBuffer = new byte [ sqlLength + 5 ] ; packetBuffer [ 0 ] = ( byte ) ( ( sqlLength + 1 ) & 0xff ) ; packetBuffer [ 1 ] = ( byte ) ( ( sqlLength + 1 ) > > > 8 ) ; packetBuffer [ 2 ] = ( byte ) ( ( sqlLength + 1 ) > > > 16 ) ; packetBuffer [ 3 ] = ( byte ) 0 ; packetBuffer [ 4 ] = commandType ; System . arraycopy ( sqlBytes , offset , packetBuffer , 5 , sqlLength ) ; compressedAndSend ( sqlLength + 5 , packetBuffer , true ) ; } else { final int expectedPacketSize = sqlLength + 1 + 4 * ( ( ( sqlLength + 1 ) / maxPacketSize ) + 1 ) ; byte [ ] packetBuffer = new byte [ expectedPacketSize ] ; packetBuffer [ 0 ] = ( byte ) ( maxPacketSize & 0xff ) ; packetBuffer [ 1 ] = ( byte ) ( maxPacketSize > > > 8 ) ; packetBuffer [ 2 ] = ( byte ) ( maxPacketSize > > > 16 ) ; packetBuffer [ 3 ] = ( byte ) seqNo ++ ; packetBuffer [ 4 ] = commandType ; System . arraycopy ( sqlBytes , offset , packetBuffer , 5 , maxPacketSize - 1 ) ; int sqlBytesPosition = maxPacketSize - 1 ; int positionDest = maxPacketSize + 4 ; int length ; while ( ( length = sqlLength - sqlBytesPosition ) > 0 ) { if ( length > maxPacketSize ) { packetBuffer [ positionDest ++ ] = ( byte ) ( maxPacketSize & 0xff ) ; packetBuffer [ positionDest ++ ] = ( byte ) ( maxPacketSize > > > 8 ) ; packetBuffer [ positionDest ++ ] = ( byte ) ( maxPacketSize > > > 16 ) ; packetBuffer [ positionDest ++ ] = ( byte ) seqNo ++ ; System . arraycopy ( sqlBytes , offset + sqlBytesPosition , packetBuffer , positionDest , maxPacketSize ) ; sqlBytesPosition += maxPacketSize ; positionDest += maxPacketSize ; } else { packetBuffer [ positionDest ++ ] = ( byte ) ( length & 0xff ) ; packetBuffer [ positionDest ++ ] = ( byte ) ( length > > > 8 ) ; packetBuffer [ positionDest ++ ] = ( byte ) ( length > > > 16 ) ; packetBuffer [ positionDest ++ ] = ( byte ) seqNo ++ ; System . arraycopy ( sqlBytes , offset + sqlBytesPosition , packetBuffer , positionDest , length ) ; break ; } } compressedAndSend ( expectedPacketSize , packetBuffer , true ) ; } } }
target:  Send buffer to outputStream.