Class RecordMapperWrapperRecordIterator<I,O>
- java.lang.Object
-
- org.apache.flink.connector.file.src.util.RecordMapperWrapperRecordIterator<I,O>
-
- Type Parameters:
I
- Input typeO
- Mapped output type
- All Implemented Interfaces:
BulkFormat.RecordIterator<O>
public class RecordMapperWrapperRecordIterator<I,O> extends Object implements BulkFormat.RecordIterator<O>
Implementation ofBulkFormat.RecordIterator
that wraps another iterator and performs the mapping of the records. You can usewrapReader(BulkFormat.Reader, RecordMapper)
to wrap a whole reader.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RecordMapperWrapperRecordIterator.RecordMapper<I,O>
Record mapper definition.
-
Constructor Summary
Constructors Constructor Description RecordMapperWrapperRecordIterator(BulkFormat.RecordIterator<I> wrapped, RecordMapperWrapperRecordIterator.RecordMapper<I,O> mapper)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RecordAndPosition<O>
next()
Gets the next record from the file, together with its position.void
releaseBatch()
Releases the batch that this iterator iterated over.static <I,O>
BulkFormat.Reader<O>wrapReader(BulkFormat.Reader<I> wrappedReader, RecordMapperWrapperRecordIterator.RecordMapper<I,O> recordMapper)
Wrap aBulkFormat.Reader
applying aRecordMapperWrapperRecordIterator.RecordMapper
on the returned iterator.
-
-
-
Constructor Detail
-
RecordMapperWrapperRecordIterator
public RecordMapperWrapperRecordIterator(BulkFormat.RecordIterator<I> wrapped, RecordMapperWrapperRecordIterator.RecordMapper<I,O> mapper)
-
-
Method Detail
-
next
public RecordAndPosition<O> next()
Description copied from interface:BulkFormat.RecordIterator
Gets the next record from the file, together with its position.The position information returned with the record point to the record AFTER the returned record, because it defines the point where the reading should resume once the current record is emitted. The position information is put in the source's state when the record is emitted. If a checkpoint is taken directly after the record is emitted, the checkpoint must to describe where to resume the source reading from after that record.
Objects returned by this method may be reused by the iterator. By the time that this method is called again, no object returned from the previous call will be referenced any more. That makes it possible to have a single
MutableRecordAndPosition
object and return the same instance (with updated record and position) on every call.- Specified by:
next
in interfaceBulkFormat.RecordIterator<I>
-
releaseBatch
public void releaseBatch()
Description copied from interface:BulkFormat.RecordIterator
Releases the batch that this iterator iterated over. This is not supposed to close the reader and its resources, but is simply a signal that this iterator is no used any more. This method can be used as a hook to recycle/reuse heavyweight object structures.- Specified by:
releaseBatch
in interfaceBulkFormat.RecordIterator<I>
-
wrapReader
public static <I,O> BulkFormat.Reader<O> wrapReader(BulkFormat.Reader<I> wrappedReader, RecordMapperWrapperRecordIterator.RecordMapper<I,O> recordMapper)
Wrap aBulkFormat.Reader
applying aRecordMapperWrapperRecordIterator.RecordMapper
on the returned iterator.- Type Parameters:
I
- Input typeO
- Mapped output type
-
-