E
- The type of events returned by the reader.IterT
- The type of the iterator that produces the events. This type exists to make the
conversion between iterator and IteratorSourceSplit
type safe.SplitT
- The concrete type of the IteratorSourceSplit
that creates and converts
the iterator that produces this reader's elements.public class IteratorSourceReader<E,IterT extends Iterator<E>,SplitT extends IteratorSourceSplit<E,IterT>> extends Object implements SourceReader<E,SplitT>
SourceReader
that returns the values of an iterator, supplied via an IteratorSourceSplit
.
The IteratorSourceSplit
is also responsible for taking the current iterator and
turning it back into a split for checkpointing.
Constructor and Description |
---|
IteratorSourceReader(SourceReaderContext context) |
Modifier and Type | Method and Description |
---|---|
void |
addSplits(List<SplitT> splits)
Adds a list of splits for this reader to read.
|
void |
close() |
CompletableFuture<Void> |
isAvailable() |
void |
notifyNoMoreSplits()
This method is called when the reader is notified that it will not receive any further
splits.
|
InputStatus |
pollNext(ReaderOutput<E> output)
Poll the next available record into the
SourceOutput . |
List<SplitT> |
snapshotState(long checkpointId)
Checkpoint on the state of the source.
|
void |
start()
Start the reader.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handleSourceEvents, notifyCheckpointAborted, notifyCheckpointComplete
public IteratorSourceReader(SourceReaderContext context)
public void start()
SourceReader
start
in interface SourceReader<E,SplitT extends IteratorSourceSplit<E,IterT>>
public InputStatus pollNext(ReaderOutput<E> output)
SourceReader
SourceOutput
.
The implementation must make sure this method is non-blocking.
Although the implementation can emit multiple records into the given SourceOutput, it is
recommended not doing so. Instead, emit one record into the SourceOutput and return a InputStatus.MORE_AVAILABLE
to let the caller thread know there are more records available.
pollNext
in interface SourceReader<E,SplitT extends IteratorSourceSplit<E,IterT>>
public CompletableFuture<Void> isAvailable()
isAvailable
in interface SourceReader<E,SplitT extends IteratorSourceSplit<E,IterT>>
public void addSplits(List<SplitT> splits)
SourceReader
addSplits
in interface SourceReader<E,SplitT extends IteratorSourceSplit<E,IterT>>
splits
- The splits assigned by the split enumerator.public void notifyNoMoreSplits()
SourceReader
It is triggered when the enumerator calls SplitEnumeratorContext.signalNoMoreSplits(int)
with the reader's parallel subtask.
notifyNoMoreSplits
in interface SourceReader<E,SplitT extends IteratorSourceSplit<E,IterT>>
public List<SplitT> snapshotState(long checkpointId)
SourceReader
snapshotState
in interface SourceReader<E,SplitT extends IteratorSourceSplit<E,IterT>>
public void close() throws Exception
close
in interface AutoCloseable
Exception
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.