Interface DataClayByteBuffer
-
- All Known Implementing Classes:
DirectNettyBuffer
,GrpcByteBuffer
,HeapNettyBuffer
,JavaByteBuffer
public interface DataClayByteBuffer
DataClay Byte buffer.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Clear the buffervoid
discardSomeReadBytes()
Discard the bytes available to be read.byte[]
getArray()
Gets the byte array used by this bufferio.grpc.netty.shaded.io.netty.buffer.ByteBuf
getBuffer()
Gets the netty buffervoid
increaseBufferSize(int newBufferSize)
Increase the buffer size to a new size providedboolean
isReadable()
Check if the buffer has some bytes to readint
maxCapacity()
Gets the maximum capacity of the bufferint
readableBytes()
Get the number of bytes available to be read.boolean
readBoolean()
Get a boolean from the byte bufferboolean[]
readBooleans(int size)
Get an array of booleans.byte
readByte()
Get a byte from the byte bufferbyte[]
readByteArray()
Get a byte array from the byte bufferbyte[][]
readByteArrays(int size)
Get an array of byte arrays.void
readBytes(byte[] values)
Get an array of bytes into the variable provided.byte[]
readBytes(int size)
Get an array of bytes.char
readChar()
Get a char from the byte bufferchar[]
readChars(int size)
Get an array of chars.double
readDouble()
Get a double from the byte bufferdouble[]
readDoubles(int size)
Get an array of doubles.int
readerIndex()
Get the index in buffer of the reader pointerfloat
readFloat()
Get a float from the byte bufferfloat[]
readFloats(int size)
Get an array of floats.int
readInt()
Get an integer from the byte bufferint[]
readInts(int size)
Get an array of integers from the byte bufferlong
readLong()
Get a long from the byte bufferlong[]
readLongs(int size)
Get an array of longs.short
readShort()
Get a short from the byte buffershort[]
readShorts(int size)
Get an array of shorts.String
readString()
Get a string from the byte bufferString[]
readStrings(int size)
Get an array of strings.int
readVLQInt()
Get a variable length integer from the byte buffer.void
release()
Release the buffervoid
rewind()
Rewind the buffer.void
setBuffer(io.grpc.netty.shaded.io.netty.buffer.ByteBuf byteBuf)
Sets the netty buffervoid
setReaderIndex(int index)
Sets the reader index to the position with index providedvoid
setWriterIndex(int index)
Sets the writer index to the position with index providedvoid
wrapBytes(byte[] newBuffer)
Wrap bytes to avoid copying them.void
writeBoolean(boolean value)
Put a boolean into the byte buffer.void
writeBooleans(boolean[] values)
Put an array of booleans into the byte buffer.void
writeByte(byte value)
Put a byte into the byte buffer.void
writeByteArray(byte[] value)
Put a byte array into the byte buffer.void
writeByteArrays(byte[][] values)
Put an array of byte arrays into the byte buffer.void
writeBytes(byte[] values)
Put an array of bytes into the byte buffer.void
writeBytes(DataClayByteBuffer binBuffer)
Copy all bytes from the buffer providedvoid
writeChar(char value)
Put a char into the byte buffer.void
writeChars(char[] values)
Put an array of chars into the byte buffer.void
writeDouble(double value)
Put a double into the byte buffer.void
writeDoubles(double[] values)
Put an array of doubles into the byte buffer.void
writeFloat(float value)
Put a float into the byte buffer.void
writeFloats(float[] values)
Put an array of floats into the byte buffer.void
writeInt(int value)
Put an integer into the byte buffer.void
writeInts(int[] values)
Put an array of integers into the byte buffervoid
writeLong(long value)
Put a long into the byte buffer.void
writeLongs(long[] values)
Put an array of longs into the byte buffer.int
writerIndex()
Get the index in buffer of the writer pointervoid
writeShort(short value)
Put a short into the byte buffer.void
writeShorts(short[] values)
Put an array of shorts into the byte buffer.void
writeString(String value)
Put a string into the byte buffer.void
writeStrings(String[] values)
Put an array of strings into the byte buffer.void
writeVLQInt(int value)
Put a variable length integer into the byte buffer.
-
-
-
Method Detail
-
wrapBytes
void wrapBytes(byte[] newBuffer)
Wrap bytes to avoid copying them.- Parameters:
newBuffer
- The byte array to deserialize
-
isReadable
boolean isReadable()
Check if the buffer has some bytes to read- Returns:
- TRUE if the buffer has some bytes to read. FALSE otherwise.
-
readableBytes
int readableBytes()
Get the number of bytes available to be read.- Returns:
- The number of bytes available to be read.
-
readerIndex
int readerIndex()
Get the index in buffer of the reader pointer- Returns:
- The index in buffer of the reader pointer
-
writerIndex
int writerIndex()
Get the index in buffer of the writer pointer- Returns:
- The index in buffer of the writer pointer
-
setReaderIndex
void setReaderIndex(int index)
Sets the reader index to the position with index provided- Parameters:
index
- the new reader position
-
setWriterIndex
void setWriterIndex(int index)
Sets the writer index to the position with index provided- Parameters:
index
- the new writer position
-
maxCapacity
int maxCapacity()
Gets the maximum capacity of the buffer- Returns:
- the maximum capacity of the buffer
-
clear
void clear()
Clear the buffer
-
release
void release()
Release the buffer
-
increaseBufferSize
void increaseBufferSize(int newBufferSize)
Increase the buffer size to a new size provided- Parameters:
newBufferSize
- The new buffer size
-
discardSomeReadBytes
void discardSomeReadBytes()
Discard the bytes available to be read.
-
getBuffer
io.grpc.netty.shaded.io.netty.buffer.ByteBuf getBuffer()
Gets the netty buffer- Returns:
- The netty buffer
-
setBuffer
void setBuffer(io.grpc.netty.shaded.io.netty.buffer.ByteBuf byteBuf)
Sets the netty buffer- Parameters:
byteBuf
- the netty buffer to set
-
getArray
byte[] getArray()
Gets the byte array used by this buffer- Returns:
- the byte array used by this buffer
-
writeInt
void writeInt(int value)
Put an integer into the byte buffer.- Parameters:
value
- Integer to add.
-
readInt
int readInt()
Get an integer from the byte buffer- Returns:
- integer from the array.
-
writeVLQInt
void writeVLQInt(int value)
Put a variable length integer into the byte buffer.- Parameters:
value
- Integer to represent.
-
readVLQInt
int readVLQInt()
Get a variable length integer from the byte buffer.- Returns:
- integer represented in byte array.
-
writeInts
void writeInts(int[] values)
Put an array of integers into the byte buffer- Parameters:
values
- Array of integers to add.
-
readInts
int[] readInts(int size)
Get an array of integers from the byte buffer- Parameters:
size
- Number of ints to read- Returns:
- Array of integers read
-
writeByte
void writeByte(byte value)
Put a byte into the byte buffer.- Parameters:
value
- Integer to add.
-
writeBytes
void writeBytes(byte[] values)
Put an array of bytes into the byte buffer.- Parameters:
values
- Array of bytes to add.
-
writeBytes
void writeBytes(DataClayByteBuffer binBuffer)
Copy all bytes from the buffer provided- Parameters:
binBuffer
- Binary buffer from which to copy bytes
-
readByte
byte readByte()
Get a byte from the byte buffer- Returns:
- byte from the arrray.
-
readBytes
void readBytes(byte[] values)
Get an array of bytes into the variable provided.- Parameters:
values
- destination byte array.
-
readBytes
byte[] readBytes(int size)
Get an array of bytes.- Parameters:
size
- number of bytes to read- Returns:
- An array of bytes.
-
writeLong
void writeLong(long value)
Put a long into the byte buffer.- Parameters:
value
- Long to add.
-
readLong
long readLong()
Get a long from the byte buffer- Returns:
- long from the array.
-
writeLongs
void writeLongs(long[] values)
Put an array of longs into the byte buffer.- Parameters:
values
- Array of longs to add.
-
readLongs
long[] readLongs(int size)
Get an array of longs.- Parameters:
size
- number of longs to read- Returns:
- An array of longs.
-
writeFloat
void writeFloat(float value)
Put a float into the byte buffer.- Parameters:
value
- float to add.
-
readFloat
float readFloat()
Get a float from the byte buffer- Returns:
- float from the array.
-
writeFloats
void writeFloats(float[] values)
Put an array of floats into the byte buffer.- Parameters:
values
- Array of floats to add.
-
readFloats
float[] readFloats(int size)
Get an array of floats.- Parameters:
size
- number of floats to read- Returns:
- An array of floats.
-
writeDouble
void writeDouble(double value)
Put a double into the byte buffer.- Parameters:
value
- double to add.
-
readDouble
double readDouble()
Get a double from the byte buffer- Returns:
- double from the array.
-
writeDoubles
void writeDoubles(double[] values)
Put an array of doubles into the byte buffer.- Parameters:
values
- Array of doubles to add.
-
readDoubles
double[] readDoubles(int size)
Get an array of doubles.- Parameters:
size
- number of doubles to read- Returns:
- An array of doubles.
-
writeBoolean
void writeBoolean(boolean value)
Put a boolean into the byte buffer.- Parameters:
value
- boolean to add.
-
readBoolean
boolean readBoolean()
Get a boolean from the byte buffer- Returns:
- boolean from the array.
-
writeBooleans
void writeBooleans(boolean[] values)
Put an array of booleans into the byte buffer.- Parameters:
values
- Array of booleans to add.
-
readBooleans
boolean[] readBooleans(int size)
Get an array of booleans.- Parameters:
size
- number of booleans to read- Returns:
- An array of booleans.
-
writeChar
void writeChar(char value)
Put a char into the byte buffer.- Parameters:
value
- char to add.
-
readChar
char readChar()
Get a char from the byte buffer- Returns:
- char from the array.
-
writeChars
void writeChars(char[] values)
Put an array of chars into the byte buffer.- Parameters:
values
- Array of chars to add.
-
readChars
char[] readChars(int size)
Get an array of chars.- Parameters:
size
- number of chars to read- Returns:
- An array of chars.
-
writeShort
void writeShort(short value)
Put a short into the byte buffer.- Parameters:
value
- short to add.
-
readShort
short readShort()
Get a short from the byte buffer- Returns:
- short from the array.
-
writeShorts
void writeShorts(short[] values)
Put an array of shorts into the byte buffer.- Parameters:
values
- Array of shorts to add.
-
readShorts
short[] readShorts(int size)
Get an array of shorts.- Parameters:
size
- number of shorts to read- Returns:
- An array of shorts.
-
writeString
void writeString(String value)
Put a string into the byte buffer.- Parameters:
value
- string to add.
-
readString
String readString()
Get a string from the byte buffer- Returns:
- string from the array.
-
writeStrings
void writeStrings(String[] values)
Put an array of strings into the byte buffer.- Parameters:
values
- Array of strings to add.
-
readStrings
String[] readStrings(int size)
Get an array of strings.- Parameters:
size
- number of strings to read- Returns:
- An array of strings.
-
writeByteArray
void writeByteArray(byte[] value)
Put a byte array into the byte buffer.- Parameters:
value
- byte array to add.
-
readByteArray
byte[] readByteArray()
Get a byte array from the byte buffer- Returns:
- byte array from the array.
-
writeByteArrays
void writeByteArrays(byte[][] values)
Put an array of byte arrays into the byte buffer.- Parameters:
values
- Array of byte arrays to add.
-
readByteArrays
byte[][] readByteArrays(int size)
Get an array of byte arrays.- Parameters:
size
- number of byte arrays to read- Returns:
- An array of byte arrays.
-
rewind
void rewind()
Rewind the buffer.
-
-