Class AbstractMultiFileRecordReader<P>

  • Type Parameters:
    P - type of the record's payload
    All Implemented Interfaces:
    RecordReader<P>

    public abstract class AbstractMultiFileRecordReader<P>
    extends java.lang.Object
    implements RecordReader<P>
    Template class for multi-files record readers. Implementations should provide how to create the delegate reader in createReader() method. Using multi-files readers assumes all files have the same format.
    Author:
    Mahmoud Ben Hassine ([email protected])
    • Field Detail

      • files

        protected java.util.List<java.nio.file.Path> files
      • currentFile

        protected java.nio.file.Path currentFile
      • iterator

        protected java.util.Iterator<java.nio.file.Path> iterator
      • charset

        protected java.nio.charset.Charset charset
    • Constructor Detail

      • AbstractMultiFileRecordReader

        public AbstractMultiFileRecordReader​(java.util.List<java.nio.file.Path> files)
        Create a new multi-file record reader.
        Parameters:
        files - to read
      • AbstractMultiFileRecordReader

        public AbstractMultiFileRecordReader​(java.util.List<java.nio.file.Path> files,
                                             java.nio.charset.Charset charset)
        Create a new multi-file record reader.
        Parameters:
        files - to read
        charset - of the file
    • Method Detail

      • open

        public void open()
                  throws java.lang.Exception
        Description copied from interface: RecordReader
        Open the reader.
        Specified by:
        open in interface RecordReader<P>
        Throws:
        java.lang.Exception - if an error occurs during reader opening
      • readRecord

        public Record<P> readRecord()
                             throws java.lang.Exception
        Description copied from interface: RecordReader
        Read next record from the data source.
        Specified by:
        readRecord in interface RecordReader<P>
        Returns:
        the next record from the data source or null if the end of the data source is reached
        Throws:
        java.lang.Exception - if an error occurs during reading next record
      • close

        public void close()
                   throws java.lang.Exception
        Description copied from interface: RecordReader
        Close the reader.
        Specified by:
        close in interface RecordReader<P>
        Throws:
        java.lang.Exception - if an error occurs during reader closing
      • createReader

        protected abstract AbstractFileRecordReader<P> createReader()
                                                             throws java.lang.Exception
        Throws:
        java.lang.Exception