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 TypeMethodDescriptionbooleanadvance()Advances the reader to the next valid record.voidclose()Closes the reader.Returns the value of the data item that was read by the lastSource.Reader.start()orSource.Reader.advance()call.Returns aSourcedescribing the same input that thisReadercurrently reads (including items already read).Returns the timestamp associated with the current data item.booleanstart()Initializes the reader and advances the reader to the first record.
-
Method Details
-
start
Description copied from class:Source.ReaderInitializes 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:
startin classSource.Reader<T>- Returns:
trueif a record was read,falseif there is no more input available.- Throws:
IOException
-
advance
Description copied from class:Source.ReaderAdvances the reader to the next valid record.It is an error to call this without having called
Source.Reader.start()first.- Specified by:
advancein classSource.Reader<T>- Returns:
trueif a record was read,falseif there is no more input available.- Throws:
IOException
-
getCurrent
Description copied from class:Source.ReaderReturns 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:
getCurrentin 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.ReaderReturns 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:
getCurrentTimestampin 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.ReaderCloses the reader. The reader cannot be used after this method is called.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classSource.Reader<T>- Throws:
IOException
-
getCurrentSource
Description copied from class:Source.ReaderReturns aSourcedescribing the same input that thisReadercurrently reads (including items already read).Usually, an implementation will simply return the immutable
Sourceobject from which the currentSource.Readerwas 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:
getCurrentSourcein classSource.Reader<T>
-
getCheckpointMark
-
getWatermark
-