Interface DataClayByteBuffer
-
- All Known Implementing Classes:
DirectNettyBuffer,GrpcByteBuffer,HeapNettyBuffer,JavaByteBuffer
public interface DataClayByteBufferDataClay Byte buffer.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclear()Clear the buffervoiddiscardSomeReadBytes()Discard the bytes available to be read.byte[]getArray()Gets the byte array used by this bufferio.grpc.netty.shaded.io.netty.buffer.ByteBufgetBuffer()Gets the netty buffervoidincreaseBufferSize(int newBufferSize)Increase the buffer size to a new size providedbooleanisReadable()Check if the buffer has some bytes to readintmaxCapacity()Gets the maximum capacity of the bufferintreadableBytes()Get the number of bytes available to be read.booleanreadBoolean()Get a boolean from the byte bufferboolean[]readBooleans(int size)Get an array of booleans.bytereadByte()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.voidreadBytes(byte[] values)Get an array of bytes into the variable provided.byte[]readBytes(int size)Get an array of bytes.charreadChar()Get a char from the byte bufferchar[]readChars(int size)Get an array of chars.doublereadDouble()Get a double from the byte bufferdouble[]readDoubles(int size)Get an array of doubles.intreaderIndex()Get the index in buffer of the reader pointerfloatreadFloat()Get a float from the byte bufferfloat[]readFloats(int size)Get an array of floats.intreadInt()Get an integer from the byte bufferint[]readInts(int size)Get an array of integers from the byte bufferlongreadLong()Get a long from the byte bufferlong[]readLongs(int size)Get an array of longs.shortreadShort()Get a short from the byte buffershort[]readShorts(int size)Get an array of shorts.StringreadString()Get a string from the byte bufferString[]readStrings(int size)Get an array of strings.intreadVLQInt()Get a variable length integer from the byte buffer.voidrelease()Release the buffervoidrewind()Rewind the buffer.voidsetBuffer(io.grpc.netty.shaded.io.netty.buffer.ByteBuf byteBuf)Sets the netty buffervoidsetReaderIndex(int index)Sets the reader index to the position with index providedvoidsetWriterIndex(int index)Sets the writer index to the position with index providedvoidwrapBytes(byte[] newBuffer)Wrap bytes to avoid copying them.voidwriteBoolean(boolean value)Put a boolean into the byte buffer.voidwriteBooleans(boolean[] values)Put an array of booleans into the byte buffer.voidwriteByte(byte value)Put a byte into the byte buffer.voidwriteByteArray(byte[] value)Put a byte array into the byte buffer.voidwriteByteArrays(byte[][] values)Put an array of byte arrays into the byte buffer.voidwriteBytes(byte[] values)Put an array of bytes into the byte buffer.voidwriteBytes(DataClayByteBuffer binBuffer)Copy all bytes from the buffer providedvoidwriteChar(char value)Put a char into the byte buffer.voidwriteChars(char[] values)Put an array of chars into the byte buffer.voidwriteDouble(double value)Put a double into the byte buffer.voidwriteDoubles(double[] values)Put an array of doubles into the byte buffer.voidwriteFloat(float value)Put a float into the byte buffer.voidwriteFloats(float[] values)Put an array of floats into the byte buffer.voidwriteInt(int value)Put an integer into the byte buffer.voidwriteInts(int[] values)Put an array of integers into the byte buffervoidwriteLong(long value)Put a long into the byte buffer.voidwriteLongs(long[] values)Put an array of longs into the byte buffer.intwriterIndex()Get the index in buffer of the writer pointervoidwriteShort(short value)Put a short into the byte buffer.voidwriteShorts(short[] values)Put an array of shorts into the byte buffer.voidwriteString(String value)Put a string into the byte buffer.voidwriteStrings(String[] values)Put an array of strings into the byte buffer.voidwriteVLQInt(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.
-
-