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 theDataInputinterface.- 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 intavailable()intgetPosition()intread(byte[] b)Tries to fill the given byte arrayb.intread(byte[] b, int off, int len)Reads up tolenbytes of memory and stores it intobstarting at offsetoff.booleanreadBoolean()bytereadByte()charreadChar()doublereadDouble()floatreadFloat()voidreadFully(byte[] b)voidreadFully(byte[] b, int off, int len)intreadInt()StringreadLine()longreadLong()StringreadLongUTF()Similar toreadUTF().shortreadShort()intreadUnsignedByte()intreadUnsignedShort()StringreadUTF()voidreleaseArrays()voidsetBuffer(byte[] buffer)voidsetBuffer(byte[] buffer, int start, int len)voidsetBuffer(ByteBuffer buffer)intskipBytes(int n)voidskipBytesToRead(int numBytes)SkipsnumBytesbytes 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:
readBooleanin interfaceDataInput- Throws:
IOException
-
readByte
public byte readByte() throws IOException- Specified by:
readBytein interfaceDataInput- Throws:
IOException
-
readChar
public char readChar() throws IOException- Specified by:
readCharin interfaceDataInput- Throws:
IOException
-
readDouble
public double readDouble() throws IOException- Specified by:
readDoublein interfaceDataInput- Throws:
IOException
-
readFloat
public float readFloat() throws IOException- Specified by:
readFloatin interfaceDataInput- Throws:
IOException
-
readFully
public void readFully(@Nonnull byte[] b) throws IOException
- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
readFully
public void readFully(@Nonnull byte[] b, int off, int len) throws IOException
- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
readInt
public int readInt() throws IOException- Specified by:
readIntin interfaceDataInput- Throws:
IOException
-
readLine
@Nullable public String readLine() throws IOException
- Specified by:
readLinein interfaceDataInput- Throws:
IOException
-
readLong
public long readLong() throws IOException- Specified by:
readLongin interfaceDataInput- Throws:
IOException
-
readShort
public short readShort() throws IOException- Specified by:
readShortin interfaceDataInput- Throws:
IOException
-
readUTF
@Nonnull public String readUTF() throws IOException
- Specified by:
readUTFin 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:
readUnsignedBytein interfaceDataInput- Throws:
IOException
-
readUnsignedShort
public int readUnsignedShort() throws IOException- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
IOException
-
skipBytesToRead
public void skipBytesToRead(int numBytes) throws IOExceptionDescription copied from interface:DataInputViewSkipsnumBytesbytes of memory. In contrast to theDataInput.skipBytes(int)method, this method always skips the desired number of bytes or throws anEOFException.- Specified by:
skipBytesToReadin 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:DataInputViewReads up tolenbytes of memory and stores it intobstarting at offsetoff.If
lenis zero, then no bytes are read and0is returned; otherwise, there is an attempt to read at least one byte. If there is no more data left, the value-1is returned; otherwise, at least one byte is read and stored intob.- Specified by:
readin 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:DataInputViewTries to fill the given byte arrayb. Returns the actually number of read bytes or -1 if there is no more data.- Specified by:
readin 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()
-
-