| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buf |
protected MutableInt |
compressSequence |
protected int |
pos |
protected MutableInt |
sequence |
static int |
SMALL_BUFFER_SIZE |
| Constructor and Description |
|---|
PacketWriter(OutputStream out,
int maxQuerySizeToLog,
MutableInt sequence,
MutableInt compressSequence)
Common feature to write data into socket, creating SingleStore Packet.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
bufIsDataAfterMark() |
void |
close() |
void |
flush()
Send packet to socket.
|
void |
flushBufferStopAtMark()
Flush to last mark.
|
long |
getCmdLength() |
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.
|
boolean |
throwMaxAllowedLength(int length) |
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 MutableInt sequence
protected final MutableInt compressSequence
protected byte[] buf
protected int pos
public PacketWriter(OutputStream out, int maxQuerySizeToLog, MutableInt sequence, MutableInt compressSequence)
out - output streammaxQuerySizeToLog - maximum query size to logsequence - packet sequencecompressSequence - compressed packet sequencepublic void pos(int pos)
throws IOException
pos in interface WriterIOExceptionpublic long getCmdLength()
getCmdLength in interface Writerpublic void writeByte(int value)
throws IOException
writeByte in interface Writervalue - byte to sendIOException - if socket error occur.public void writeShort(short value)
throws IOException
writeShort in interface Writervalue - short valueIOException - if socket error occurpublic void writeInt(int value)
throws IOException
writeInt in interface Writervalue - int valueIOException - if socket error occurpublic void writeLong(long value)
throws IOException
writeLong in interface Writervalue - long valueIOException - if socket error occurpublic void writeDouble(double value)
throws IOException
writeDouble in interface WriterIOExceptionpublic void writeFloat(float value)
throws IOException
writeFloat in interface WriterIOExceptionpublic void writeBytes(byte[] arr)
throws IOException
writeBytes in interface WriterIOExceptionpublic void writeBytesAtPos(byte[] arr,
int pos)
writeBytesAtPos in interface Writerpublic void writeBytes(byte[] arr,
int off,
int len)
throws IOException
writeBytes in interface Writerarr - byte arrayoff - offsetlen - byte length to writeIOException - if socket error occurpublic void writeLength(long length)
throws IOException
writeLength in interface Writerlength - field lengthIOException - if socket error occur.public void writeAscii(String str) throws IOException
writeAscii in interface WriterIOExceptionpublic void writeString(String str) throws IOException
writeString in interface WriterIOExceptionpublic void writeStringEscaped(String str, boolean noBackslashEscapes) throws IOException
writeStringEscaped in interface Writerstr - stringnoBackslashEscapes - escape methodIOException - if socket error occurpublic void writeBytesEscaped(byte[] bytes,
int len,
boolean noBackslashEscapes)
throws IOException
writeBytesEscaped in interface Writerbytes - byteslen - len to writenoBackslashEscapes - escape methodIOException - if socket error occurpublic void writeEmptyPacket()
throws IOException
writeEmptyPacket in interface WriterIOException - if socket error occur.public void flush()
throws IOException
flush in interface WriterIOException - if socket error occur.public boolean throwMaxAllowedLength(int length)
throwMaxAllowedLength in interface Writerpublic void setMaxAllowedPacket(int maxAllowedPacket)
setMaxAllowedPacket in interface Writerpublic void permitTrace(boolean permitTrace)
permitTrace in interface Writerpublic void setServerThreadId(Long serverThreadId, HostAddress hostAddress)
setServerThreadId in interface WriterserverThreadId - current server thread id.hostAddress - host informationpublic boolean hasFlushed()
hasFlushed in interface Writerpublic void flushBufferStopAtMark()
throws IOException
flushBufferStopAtMark in interface WriterIOException - if flush fail.public boolean bufIsDataAfterMark()
bufIsDataAfterMark in interface Writerpublic byte[] resetMark()
public void initPacket()
initPacket in interface Writerprotected void writeSocket(boolean commandEnd)
throws IOException
commandEnd - command endIOException - id connection error occur.public void close()
throws IOException
close in interface WriterIOExceptionCopyright © 2023 SingleStore. All rights reserved.