Class StandardPacketInputStream

java.lang.Object
org.mariadb.jdbc.internal.io.input.StandardPacketInputStream
All Implemented Interfaces:
PacketInputStream

public class StandardPacketInputStream extends Object implements PacketInputStream
  • Field Details

    • REUSABLE_BUFFER_LENGTH

      private static final int REUSABLE_BUFFER_LENGTH
      See Also:
    • MAX_PACKET_SIZE

      private static final int MAX_PACKET_SIZE
      See Also:
    • logger

      private static final Logger logger
    • reusableArray

      private final byte[] reusableArray
    • inputStream

      private final InputStream inputStream
    • maxQuerySizeToLog

      private final int maxQuerySizeToLog
    • packetSeq

      private int packetSeq
    • lastPacketLength

      private int lastPacketLength
    • serverThreadLog

      private String serverThreadLog
    • traceCache

      private LruTraceCache traceCache
  • Constructor Details

    • StandardPacketInputStream

      public StandardPacketInputStream(InputStream in, Options options)
      Constructor of standard socket MySQL packet stream reader.
      Parameters:
      in - stream
      options - connection options
  • Method Details

    • create

      public static byte[] create(byte[] value)
      Constructor for single Data (using text format).
      Parameters:
      value - value
      Returns:
      Buffer
    • create

      public static byte[] create(byte[][] rowDatas, ColumnType[] columnTypes)
      Create Buffer with Text protocol values.
      Parameters:
      rowDatas - datas
      columnTypes - column types
      Returns:
      Buffer
    • getPacket

      public Buffer getPacket(boolean reUsable) throws IOException
      Specified by:
      getPacket in interface PacketInputStream
      Throws:
      IOException
    • getInputStream

      public InputStream getInputStream()
      Get current input stream for creating compress input stream, to avoid losing already read bytes in case of pipelining.
      Returns:
      input stream.
    • getPacketArray

      public byte[] getPacketArray(boolean reUsable) throws IOException
      Get next packet. If packet is more than 16M, read as many packet needed to finish packet. (first that has not length = 16Mb)
      Specified by:
      getPacketArray in interface PacketInputStream
      Parameters:
      reUsable - if can use existing reusable buffer to avoid creating array
      Returns:
      array packet.
      Throws:
      IOException - if socket exception occur.
    • getLastPacketSeq

      public int getLastPacketSeq()
      Specified by:
      getLastPacketSeq in interface PacketInputStream
    • getCompressLastPacketSeq

      public int getCompressLastPacketSeq()
      Specified by:
      getCompressLastPacketSeq in interface PacketInputStream
    • close

      public void close() throws IOException
      Specified by:
      close in interface PacketInputStream
      Throws:
      IOException
    • setServerThreadId

      public void setServerThreadId(long serverThreadId, Boolean isMaster)
      Set server thread id.
      Specified by:
      setServerThreadId in interface PacketInputStream
      Parameters:
      serverThreadId - current server thread id.
      isMaster - is server master
    • setTraceCache

      public void setTraceCache(LruTraceCache traceCache)
      Specified by:
      setTraceCache in interface PacketInputStream