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 |
---|---|
protected void |
advance()
Advances the view to the next memory segment.
|
protected void |
clear()
Clears the internal state of the view.
|
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.
|
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.protected final 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 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.DataInputView
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in interface org.apache.flink.core.memory.DataInputView
IOException
public void readFully(byte[] b) throws IOException
readFully
in interface DataInput
IOException
public void readFully(byte[] b, int off, int len) throws IOException
readFully
in interface DataInput
IOException
public boolean readBoolean() throws IOException
readBoolean
in interface DataInput
IOException
public byte readByte() throws IOException
readByte
in interface DataInput
IOException
public int readUnsignedByte() throws IOException
readUnsignedByte
in interface DataInput
IOException
public short readShort() throws IOException
readShort
in interface DataInput
IOException
public int readUnsignedShort() throws IOException
readUnsignedShort
in interface DataInput
IOException
public char readChar() throws IOException
readChar
in interface DataInput
IOException
public int readInt() throws IOException
readInt
in interface DataInput
IOException
public long readLong() throws IOException
readLong
in interface DataInput
IOException
public float readFloat() throws IOException
readFloat
in interface DataInput
IOException
public double readDouble() throws IOException
readDouble
in interface DataInput
IOException
public String readLine() throws IOException
readLine
in interface DataInput
IOException
public String readUTF() throws IOException
readUTF
in interface DataInput
IOException
public int skipBytes(int n) throws IOException
skipBytes
in interface DataInput
IOException
public void skipBytesToRead(int numBytes) throws IOException
skipBytesToRead
in interface org.apache.flink.core.memory.DataInputView
IOException
Copyright © 2014–2016 The Apache Software Foundation. All rights reserved.