Package org.apache.flink.core.memory
Class DataInputDeserializer
- java.lang.Object
-
- org.apache.flink.core.memory.DataInputDeserializer
-
- All Implemented Interfaces:
DataInput
,Serializable
,DataInputView
public class DataInputDeserializer extends Object implements DataInputView, Serializable
A simple and efficient deserializer for theDataInput
interface.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DataInputDeserializer()
DataInputDeserializer(byte[] buffer)
DataInputDeserializer(byte[] buffer, int start, int len)
DataInputDeserializer(ByteBuffer buffer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
int
getPosition()
int
read(byte[] b)
Tries to fill the given byte arrayb
.int
read(byte[] b, int off, int len)
Reads up tolen
bytes of memory and stores it intob
starting at offsetoff
.boolean
readBoolean()
byte
readByte()
char
readChar()
double
readDouble()
float
readFloat()
void
readFully(byte[] b)
void
readFully(byte[] b, int off, int len)
int
readInt()
String
readLine()
long
readLong()
String
readLongUTF()
Similar toreadUTF()
.short
readShort()
int
readUnsignedByte()
int
readUnsignedShort()
String
readUTF()
void
releaseArrays()
void
setBuffer(byte[] buffer)
void
setBuffer(byte[] buffer, int start, int len)
void
setBuffer(ByteBuffer buffer)
int
skipBytes(int n)
void
skipBytesToRead(int numBytes)
SkipsnumBytes
bytes of memory.
-
-
-
Constructor Detail
-
DataInputDeserializer
public DataInputDeserializer()
-
DataInputDeserializer
public DataInputDeserializer(@Nonnull byte[] buffer)
-
DataInputDeserializer
public DataInputDeserializer(@Nonnull byte[] buffer, int start, int len)
-
DataInputDeserializer
public DataInputDeserializer(@Nonnull ByteBuffer buffer)
-
-
Method Detail
-
setBuffer
public void setBuffer(@Nonnull ByteBuffer buffer)
-
setBuffer
public void setBuffer(@Nonnull byte[] buffer, int start, int len)
-
setBuffer
public void setBuffer(@Nonnull byte[] buffer)
-
releaseArrays
public void releaseArrays()
-
available
public int available()
-
readBoolean
public boolean readBoolean() throws IOException
- Specified by:
readBoolean
in interfaceDataInput
- Throws:
IOException
-
readByte
public byte readByte() throws IOException
- Specified by:
readByte
in interfaceDataInput
- Throws:
IOException
-
readChar
public char readChar() throws IOException
- Specified by:
readChar
in interfaceDataInput
- Throws:
IOException
-
readDouble
public double readDouble() throws IOException
- Specified by:
readDouble
in interfaceDataInput
- Throws:
IOException
-
readFloat
public float readFloat() throws IOException
- Specified by:
readFloat
in interfaceDataInput
- Throws:
IOException
-
readFully
public void readFully(@Nonnull byte[] b) throws IOException
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readFully
public void readFully(@Nonnull byte[] b, int off, int len) throws IOException
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readInt
public int readInt() throws IOException
- Specified by:
readInt
in interfaceDataInput
- Throws:
IOException
-
readLine
@Nullable public String readLine() throws IOException
- Specified by:
readLine
in interfaceDataInput
- Throws:
IOException
-
readLong
public long readLong() throws IOException
- Specified by:
readLong
in interfaceDataInput
- Throws:
IOException
-
readShort
public short readShort() throws IOException
- Specified by:
readShort
in interfaceDataInput
- Throws:
IOException
-
readUTF
@Nonnull public String readUTF() throws IOException
- Specified by:
readUTF
in interfaceDataInput
- Throws:
IOException
-
readLongUTF
public String readLongUTF() throws IOException
Similar toreadUTF()
. The size is stored in the manner of thereadInt()
method, the character conversion is the same.- Returns:
- a Unicode string.
- Throws:
EOFException
- – if this stream reaches the end before reading all the bytes.IOException
- – if an I/O error occurs.UTFDataFormatException
- – if the bytes do not represent a valid modified UTF-8 encoding of a string.
-
readUnsignedByte
public int readUnsignedByte() throws IOException
- Specified by:
readUnsignedByte
in interfaceDataInput
- Throws:
IOException
-
readUnsignedShort
public int readUnsignedShort() throws IOException
- Specified by:
readUnsignedShort
in interfaceDataInput
- Throws:
IOException
-
skipBytesToRead
public void skipBytesToRead(int numBytes) throws IOException
Description copied from interface:DataInputView
SkipsnumBytes
bytes of memory. In contrast to theDataInput.skipBytes(int)
method, this method always skips the desired number of bytes or throws anEOFException
.- Specified by:
skipBytesToRead
in interfaceDataInputView
- Parameters:
numBytes
- The number of bytes to skip.- Throws:
IOException
- Thrown, if any I/O related problem occurred such that the input could not be advanced to the desired position.
-
read
public int read(@Nonnull byte[] b, int off, int len) throws IOException
Description copied from interface:DataInputView
Reads up tolen
bytes of memory and stores it intob
starting at offsetoff
.If
len
is zero, then no bytes are read and0
is returned; otherwise, there is an attempt to read at least one byte. If there is no more data left, the value-1
is returned; otherwise, at least one byte is read and stored intob
.- Specified by:
read
in interfaceDataInputView
- Parameters:
b
- byte array to store the data tooff
- offset into byte arraylen
- byte length to read- Returns:
- the number of actually read bytes of -1 if there is no more data left
- Throws:
IOException
-
read
public int read(@Nonnull byte[] b) throws IOException
Description copied from interface:DataInputView
Tries to fill the given byte arrayb
. Returns the actually number of read bytes or -1 if there is no more data.- Specified by:
read
in interfaceDataInputView
- Parameters:
b
- byte array to store the data to- Returns:
- the number of read bytes or -1 if there is no more data left
- Throws:
IOException
-
getPosition
public int getPosition()
-
-