Class BlockResettableMutableObjectIterator<T>
- java.lang.Object
-
- org.apache.flink.runtime.operators.resettable.BlockResettableMutableObjectIterator<T>
-
- All Implemented Interfaces:
MemoryBlockIterator,ResettableMutableObjectIterator<T>,org.apache.flink.util.MutableObjectIterator<T>
public class BlockResettableMutableObjectIterator<T> extends Object implements ResettableMutableObjectIterator<T>
Implementation of an iterator that fetches a block of data into main memory and offers resettable access to the data in that block.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanclosedprotected SimpleCollectingOutputViewcollectingViewprotected ArrayList<org.apache.flink.core.memory.MemorySegment>emptySegmentsprotected ArrayList<org.apache.flink.core.memory.MemorySegment>fullSegmentsstatic org.slf4j.LoggerLOGprotected intnumRecordsInBufferprotected intnumRecordsReturnedprotected RandomAccessInputViewreadViewprotected org.apache.flink.api.common.typeutils.TypeSerializer<T>serializer
-
Constructor Summary
Constructors Constructor Description BlockResettableMutableObjectIterator(MemoryManager memoryManager, org.apache.flink.util.MutableObjectIterator<T> input, org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer, int numMemoryPages, AbstractInvokable ownerTask)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()This method closes the iterator and releases all resources.protected TgetNextRecord()protected TgetNextRecord(T reuse)booleanhasFurtherInput()Checks, whether the input that is blocked by this iterator, has further elements available.Tnext()Tnext(T target)booleannextBlock()Move the iterator to the next memory block.voidopen()voidreset()Resets the iterator.protected booleanwriteNextRecord(T record)
-
-
-
Field Detail
-
LOG
public static final org.slf4j.Logger LOG
-
readView
protected final RandomAccessInputView readView
-
collectingView
protected final SimpleCollectingOutputView collectingView
-
serializer
protected final org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer
-
numRecordsInBuffer
protected int numRecordsInBuffer
-
numRecordsReturned
protected int numRecordsReturned
-
emptySegments
protected final ArrayList<org.apache.flink.core.memory.MemorySegment> emptySegments
-
fullSegments
protected final ArrayList<org.apache.flink.core.memory.MemorySegment> fullSegments
-
closed
protected volatile boolean closed
-
-
Constructor Detail
-
BlockResettableMutableObjectIterator
public BlockResettableMutableObjectIterator(MemoryManager memoryManager, org.apache.flink.util.MutableObjectIterator<T> input, org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer, int numMemoryPages, AbstractInvokable ownerTask) throws MemoryAllocationException
- Throws:
MemoryAllocationException
-
-
Method Detail
-
next
public T next(T target) throws IOException
- Specified by:
nextin interfaceorg.apache.flink.util.MutableObjectIterator<T>- Throws:
IOException
-
next
public T next() throws IOException
- Specified by:
nextin interfaceorg.apache.flink.util.MutableObjectIterator<T>- Throws:
IOException
-
reset
public void reset()
Description copied from interface:ResettableMutableObjectIteratorResets the iterator.- Specified by:
resetin interfaceResettableMutableObjectIterator<T>
-
nextBlock
public boolean nextBlock() throws IOExceptionDescription copied from interface:MemoryBlockIteratorMove the iterator to the next memory block. The next memory block starts at the first element that was not in the block before. A special case is when no record was in the block before, which happens when this function is invoked two times directly in a sequence, without calling hasNext() or next in between. Then the block moves one element.- Specified by:
nextBlockin interfaceMemoryBlockIterator- Returns:
- True if a new memory block was loaded, false if there were no further records and hence no further memory block.
- Throws:
IOException- Thrown, when advancing to the next block failed.
-
hasFurtherInput
public boolean hasFurtherInput()
Checks, whether the input that is blocked by this iterator, has further elements available. This method may be used to forecast (for example at the point where a block is full) whether there will be more data (possibly in another block).- Returns:
- True, if there will be more data, false otherwise.
-
close
public void close()
This method closes the iterator and releases all resources. This method works both as a regular shutdown and as a canceling method. The method may be called multiple times and will not produce an error.
-
open
public void open()
-
writeNextRecord
protected boolean writeNextRecord(T record) throws IOException- Throws:
IOException
-
getNextRecord
protected T getNextRecord(T reuse) throws IOException- Throws:
IOException
-
getNextRecord
protected T getNextRecord() throws IOException- Throws:
IOException
-
-