public class PacketWriter extends Object
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buf |
protected com.singlestore.jdbc.util.MutableInt |
compressSequence |
protected int |
pos |
protected com.singlestore.jdbc.util.MutableInt |
sequence |
static int |
SMALL_BUFFER_SIZE |
| Constructor and Description |
|---|
PacketWriter(OutputStream out,
int maxQuerySizeToLog,
com.singlestore.jdbc.util.MutableInt sequence,
com.singlestore.jdbc.util.MutableInt compressSequence)
Common feature to write data into socket, creating SingleStore Packet.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
bufIsDataAfterMark() |
void |
checkMaxAllowedLength(int length)
Count query size.
|
void |
close() |
void |
flush()
Send packet to socket.
|
void |
flushBufferStopAtMark()
Flush to last mark.
|
boolean |
hasFlushed() |
void |
initPacket() |
boolean |
isMarked() |
void |
mark() |
void |
permitTrace(boolean permitTrace) |
int |
pos() |
void |
pos(int pos) |
byte[] |
resetMark()
Reset mark flag and send bytes after mark flag.
|
void |
setMaxAllowedPacket(int maxAllowedPacket) |
void |
setServerThreadId(Long serverThreadId,
HostAddress hostAddress)
Set server thread id.
|
void |
writeAscii(String str) |
void |
writeByte(int value)
Write byte into buf, flush buf to socket if needed.
|
void |
writeBytes(byte[] arr) |
void |
writeBytes(byte[] arr,
int off,
int len)
Write byte array to buf.
|
void |
writeBytesAtPos(byte[] arr,
int pos) |
void |
writeBytesEscaped(byte[] bytes,
int len,
boolean noBackslashEscapes)
Write escape bytes to socket.
|
void |
writeDouble(double value) |
void |
writeEmptyPacket()
Send empty packet.
|
void |
writeFloat(float value) |
void |
writeInt(int value)
Write int value into buf.
|
void |
writeLength(long length)
Write field length into buf, flush socket if needed.
|
void |
writeLong(long value)
Write long value into buf.
|
void |
writeShort(short value)
Write short value into buf.
|
protected void |
writeSocket(boolean commandEnd)
Flush the internal buf.
|
void |
writeString(String str) |
void |
writeStringEscaped(String str,
boolean noBackslashEscapes)
Write string to socket.
|
public static final int SMALL_BUFFER_SIZE
protected final com.singlestore.jdbc.util.MutableInt sequence
protected final com.singlestore.jdbc.util.MutableInt compressSequence
protected byte[] buf
protected int pos
public PacketWriter(OutputStream out, int maxQuerySizeToLog, com.singlestore.jdbc.util.MutableInt sequence, com.singlestore.jdbc.util.MutableInt compressSequence)
out - output streammaxQuerySizeToLog - maximum query size to logsequence - packet sequencecompressSequence - compressed packet sequencepublic int pos()
public void pos(int pos)
throws IOException
IOExceptionpublic void writeByte(int value)
throws IOException
value - byte to sendIOException - if socket error occur.public void writeShort(short value)
throws IOException
value - short valueIOException - if socket error occurpublic void writeInt(int value)
throws IOException
value - int valueIOException - if socket error occurpublic void writeLong(long value)
throws IOException
value - long valueIOException - if socket error occurpublic void writeDouble(double value)
throws IOException
IOExceptionpublic void writeFloat(float value)
throws IOException
IOExceptionpublic void writeBytes(byte[] arr)
throws IOException
IOExceptionpublic void writeBytesAtPos(byte[] arr,
int pos)
public void writeBytes(byte[] arr,
int off,
int len)
throws IOException
arr - byte arrayoff - offsetlen - byte length to writeIOException - if socket error occurpublic void writeLength(long length)
throws IOException
length - field lengthIOException - if socket error occur.public void writeAscii(String str) throws IOException
IOExceptionpublic void writeString(String str) throws IOException
IOExceptionpublic void writeStringEscaped(String str, boolean noBackslashEscapes) throws IOException
str - stringnoBackslashEscapes - escape methodIOException - if socket error occurpublic void writeBytesEscaped(byte[] bytes,
int len,
boolean noBackslashEscapes)
throws IOException
bytes - byteslen - len to writenoBackslashEscapes - escape methodIOException - if socket error occurpublic void writeEmptyPacket()
throws IOException
IOException - if socket error occur.public void flush()
throws IOException
IOException - if socket error occur.public void checkMaxAllowedLength(int length)
throws MaxAllowedPacketException
length - additional length to query sizeMaxAllowedPacketException - if query has not to be send.public void setMaxAllowedPacket(int maxAllowedPacket)
public void permitTrace(boolean permitTrace)
public void setServerThreadId(Long serverThreadId, HostAddress hostAddress)
serverThreadId - current server thread id.hostAddress - host informationpublic void mark()
public boolean isMarked()
public boolean hasFlushed()
public void flushBufferStopAtMark()
throws IOException
IOException - if flush fail.public boolean bufIsDataAfterMark()
public byte[] resetMark()
public void initPacket()
protected void writeSocket(boolean commandEnd)
throws IOException
commandEnd - command endIOException - id connection error occur.public void close()
throws IOException
IOExceptionCopyright © 2022 SingleStore. All rights reserved.