Class MicrobatchSource.Reader
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
MicrobatchSource<T,
CheckpointMarkT extends UnboundedSource.CheckpointMark>
BoundedReadFromUnboundedSource
's
UnboundedToBoundedSourceAdapter
, with some adjustments for Spark specifics.
This Reader reads until one of the following thresholds has been reached:
- max records (per batch)
- max read duration (per batch)
-
Method Summary
Modifier and TypeMethodDescriptionboolean
advance()
Advances the reader to the next valid record.void
close()
Closes the reader.Returns the value of the data item that was read by the lastSource.Reader.start()
orSource.Reader.advance()
call.Returns aSource
describing the same input that thisReader
currently reads (including items already read).Returns the timestamp associated with the current data item.boolean
start()
Initializes the reader and advances the reader to the first record.
-
Method Details
-
start
Description copied from class:Source.Reader
Initializes the reader and advances the reader to the first record.This method should be called exactly once. The invocation should occur prior to calling
Source.Reader.advance()
orSource.Reader.getCurrent()
. This method may perform expensive operations that are needed to initialize the reader.- Specified by:
start
in classSource.Reader<T>
- Returns:
true
if a record was read,false
if there is no more input available.- Throws:
IOException
-
advance
Description copied from class:Source.Reader
Advances the reader to the next valid record.It is an error to call this without having called
Source.Reader.start()
first.- Specified by:
advance
in classSource.Reader<T>
- Returns:
true
if a record was read,false
if there is no more input available.- Throws:
IOException
-
getCurrent
Description copied from class:Source.Reader
Returns the value of the data item that was read by the lastSource.Reader.start()
orSource.Reader.advance()
call. The returned value must be effectively immutable and remain valid indefinitely.Multiple calls to this method without an intervening call to
Source.Reader.advance()
should return the same result.- Specified by:
getCurrent
in classSource.Reader<T>
- Throws:
NoSuchElementException
- ifSource.Reader.start()
was never called, or if the lastSource.Reader.start()
orSource.Reader.advance()
returnedfalse
.
-
getCurrentTimestamp
Description copied from class:Source.Reader
Returns the timestamp associated with the current data item.If the source does not support timestamps, this should return
BoundedWindow.TIMESTAMP_MIN_VALUE
.Multiple calls to this method without an intervening call to
Source.Reader.advance()
should return the same result.- Specified by:
getCurrentTimestamp
in classSource.Reader<T>
- Throws:
NoSuchElementException
- if the reader is at the beginning of the input andSource.Reader.start()
orSource.Reader.advance()
wasn't called, or if the lastSource.Reader.start()
orSource.Reader.advance()
returnedfalse
.
-
close
Description copied from class:Source.Reader
Closes the reader. The reader cannot be used after this method is called.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in classSource.Reader<T>
- Throws:
IOException
-
getCurrentSource
Description copied from class:Source.Reader
Returns aSource
describing the same input that thisReader
currently reads (including items already read).Usually, an implementation will simply return the immutable
Source
object from which the currentSource.Reader
was constructed, or delegate to the base class. However, when using or implementing this method on aBoundedSource.BoundedReader
, special considerations apply, see documentation forBoundedSource.BoundedReader.getCurrentSource()
.- Specified by:
getCurrentSource
in classSource.Reader<T>
-
getCheckpointMark
-
getWatermark
-