public abstract class AbstractPagedInputView extends Object implements org.apache.flink.core.memory.DataInputView
| Modifier and Type | Field and Description |
|---|---|
protected int |
headerLength |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractPagedInputView(int headerLength)
Creates a new view that is initially not bound to a memory segment.
|
protected |
AbstractPagedInputView(org.apache.flink.core.memory.MemorySegment initialSegment,
int initialLimit,
int headerLength)
Creates a new view that starts with the given segment.
|
| Modifier and Type | Method and Description |
|---|---|
void |
advance()
Advances the view to the next memory segment.
|
protected void |
clear()
Clears the internal state of the view.
|
protected void |
doAdvance() |
int |
getCurrentPositionInSegment()
Gets the position from which the next byte will be read.
|
org.apache.flink.core.memory.MemorySegment |
getCurrentSegment()
Gets the memory segment that will be used to read the next bytes from.
|
int |
getCurrentSegmentLimit()
Gets the current limit in the memory segment.
|
int |
getHeaderLength() |
protected abstract int |
getLimitForSegment(org.apache.flink.core.memory.MemorySegment segment)
Gets the limit for reading bytes from the given memory segment.
|
protected abstract org.apache.flink.core.memory.MemorySegment |
nextSegment(org.apache.flink.core.memory.MemorySegment current)
The method by which concrete subclasses realize page crossing.
|
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
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() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
String |
readUTF() |
protected void |
seekInput(org.apache.flink.core.memory.MemorySegment segment,
int positionInSegment,
int limitInSegment)
Sets the internal state of the view such that the next bytes will be read from the given memory segment,
starting at the given position.
|
int |
skipBytes(int n) |
void |
skipBytesToRead(int numBytes) |
protected AbstractPagedInputView(org.apache.flink.core.memory.MemorySegment initialSegment,
int initialLimit,
int headerLength)
initialSegment - The memory segment to start reading from.initialLimit - The position one after the last valid byte in the initial segment.headerLength - The number of bytes to skip at the beginning of each segment for the header. This
length must be the same for all memory segments.protected AbstractPagedInputView(int headerLength)
WARNING: The view is not readable until the first call to either advance(),
or to seekInput(MemorySegment, int, int).
headerLength - The number of bytes to skip at the beginning of each segment for the header.public org.apache.flink.core.memory.MemorySegment getCurrentSegment()
nextSegment(MemorySegment) method.public int getCurrentPositionInSegment()
getCurrentSegmentLimit()public int getCurrentSegmentLimit()
getCurrentPositionInSegment()protected abstract org.apache.flink.core.memory.MemorySegment nextSegment(org.apache.flink.core.memory.MemorySegment current)
throws EOFException,
IOException
EOFException.current - The current page that was read to its limit. May be null, if this method is
invoked for the first time.null. If the input is
exhausted, an EOFException must be thrown instead.EOFException - Thrown, if no further segment is available.IOException - Thrown, if the method cannot provide the next page due to an I/O related problem.protected abstract int getLimitForSegment(org.apache.flink.core.memory.MemorySegment segment)
segment - The segment to determine the limit for.public void advance()
throws IOException
nextSegment(MemorySegment) and getLimitForSegment(MemorySegment)
to get the next segment and set its limit.IOException - Thrown, if the next segment could not be obtained.nextSegment(MemorySegment),
getLimitForSegment(MemorySegment)protected void doAdvance()
throws IOException
IOExceptionpublic int getHeaderLength()
protected void seekInput(org.apache.flink.core.memory.MemorySegment segment,
int positionInSegment,
int limitInSegment)
segment - The segment to read the next bytes from.positionInSegment - The position in the segment to start reading from.limitInSegment - The limit in the segment. When reached, the view will attempt to switch to
the next segment.protected void clear()
advance() or seekInput(MemorySegment, int, int) method have been invoked.public int read(byte[] b)
throws IOException
read in interface org.apache.flink.core.memory.DataInputViewIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in interface org.apache.flink.core.memory.DataInputViewIOExceptionpublic void readFully(byte[] b)
throws IOException
readFully in interface DataInputIOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws IOException
readFully in interface DataInputIOExceptionpublic boolean readBoolean()
throws IOException
readBoolean in interface DataInputIOExceptionpublic byte readByte()
throws IOException
readByte in interface DataInputIOExceptionpublic int readUnsignedByte()
throws IOException
readUnsignedByte in interface DataInputIOExceptionpublic short readShort()
throws IOException
readShort in interface DataInputIOExceptionpublic int readUnsignedShort()
throws IOException
readUnsignedShort in interface DataInputIOExceptionpublic char readChar()
throws IOException
readChar in interface DataInputIOExceptionpublic int readInt()
throws IOException
readInt in interface DataInputIOExceptionpublic long readLong()
throws IOException
readLong in interface DataInputIOExceptionpublic float readFloat()
throws IOException
readFloat in interface DataInputIOExceptionpublic double readDouble()
throws IOException
readDouble in interface DataInputIOExceptionpublic String readLine() throws IOException
readLine in interface DataInputIOExceptionpublic String readUTF() throws IOException
readUTF in interface DataInputIOExceptionpublic int skipBytes(int n)
throws IOException
skipBytes in interface DataInputIOExceptionpublic void skipBytesToRead(int numBytes)
throws IOException
skipBytesToRead in interface org.apache.flink.core.memory.DataInputViewIOExceptionCopyright © 2014–2019 The Apache Software Foundation. All rights reserved.