Class FileBatchSequenceRecordReader
- java.lang.Object
-
- org.datavec.api.records.reader.impl.filebatch.FileBatchSequenceRecordReader
-
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable,Configurable,RecordReader,SequenceRecordReader
public class FileBatchSequenceRecordReader extends Object implements SequenceRecordReader
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.datavec.api.records.reader.RecordReader
APPEND_LABEL, LABELS, NAME_SPACE
-
-
Constructor Summary
Constructors Constructor Description FileBatchSequenceRecordReader(SequenceRecordReader seqRR, FileBatch fileBatch)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanbatchesSupported()This method returns true, if next(int) signature is supported by this RecordReader implementation.voidclose()ConfigurationgetConf()Return the configuration used by this object.List<String>getLabels()List of label stringsList<RecordListener>getListeners()Get the record listeners for this record reader.booleanhasNext()Whether there are anymore recordsvoidinitialize(Configuration conf, InputSplit split)Called once at initialization.voidinitialize(InputSplit split)Called once at initialization.List<Record>loadFromMetaData(List<RecordMetaData> recordMetaDatas)Load multiple records from the given a list ofRecordMetaDatainstancesRecordloadFromMetaData(RecordMetaData recordMetaData)Load a single record from the givenRecordMetaDatainstance
Note: that for data that isn't splittable (i.e., text data that needs to be scanned/split), it is more efficient to load multiple records at once usingRecordReader.loadFromMetaData(List)List<SequenceRecord>loadSequenceFromMetaData(List<RecordMetaData> recordMetaDatas)Load multiple sequence records from the given a list ofRecordMetaDatainstancesSequenceRecordloadSequenceFromMetaData(RecordMetaData recordMetaData)Load a single sequence record from the givenRecordMetaDatainstance
Note: that for data that isn't splittable (i.e., text data that needs to be scanned/split), it is more efficient to load multiple records at once usingSequenceRecordReader.loadSequenceFromMetaData(List)List<Writable>next()Get the next recordList<List<Writable>>next(int num)This method will be used, if batchesSupported() returns true.RecordnextRecord()Similar toRecordReader.next(), but returns aRecordobject, that may include metadata such as the source of the dataSequenceRecordnextSequence()Similar toSequenceRecordReader.sequenceRecord(), but returns aRecordobject, that may include metadata such as the source of the dataList<Writable>record(URI uri, DataInputStream dataInputStream)Load the record from the given DataInputStream UnlikeRecordReader.next()the internal state of the RecordReader is not modified Implementations of this method should not close the DataInputStreamvoidreset()Reset record reader iteratorbooleanresetSupported()List<List<Writable>>sequenceRecord()Returns a sequence record.List<List<Writable>>sequenceRecord(URI uri, DataInputStream dataInputStream)Load a sequence record from the given DataInputStream UnlikeRecordReader.next()the internal state of the RecordReader is not modified Implementations of this method should not close the DataInputStreamvoidsetConf(Configuration conf)Set the configuration to be used by this object.voidsetListeners(Collection<RecordListener> listeners)Set the record listeners for this record reader.voidsetListeners(RecordListener... listeners)Set the record listeners for this record reader.
-
-
-
Constructor Detail
-
FileBatchSequenceRecordReader
public FileBatchSequenceRecordReader(SequenceRecordReader seqRR, FileBatch fileBatch)
- Parameters:
seqRR- Underlying record reader to read files fromfileBatch- File batch to read files from
-
-
Method Detail
-
sequenceRecord
public List<List<Writable>> sequenceRecord()
Description copied from interface:SequenceRecordReaderReturns a sequence record.- Specified by:
sequenceRecordin interfaceSequenceRecordReader- Returns:
- a sequence of records
-
sequenceRecord
public List<List<Writable>> sequenceRecord(URI uri, DataInputStream dataInputStream) throws IOException
Description copied from interface:SequenceRecordReaderLoad a sequence record from the given DataInputStream UnlikeRecordReader.next()the internal state of the RecordReader is not modified Implementations of this method should not close the DataInputStream- Specified by:
sequenceRecordin interfaceSequenceRecordReader- Throws:
IOException- if error occurs during reading from the input stream
-
nextSequence
public SequenceRecord nextSequence()
Description copied from interface:SequenceRecordReaderSimilar toSequenceRecordReader.sequenceRecord(), but returns aRecordobject, that may include metadata such as the source of the data- Specified by:
nextSequencein interfaceSequenceRecordReader- Returns:
- next sequence record
-
loadSequenceFromMetaData
public SequenceRecord loadSequenceFromMetaData(RecordMetaData recordMetaData) throws IOException
Description copied from interface:SequenceRecordReaderLoad a single sequence record from the givenRecordMetaDatainstance
Note: that for data that isn't splittable (i.e., text data that needs to be scanned/split), it is more efficient to load multiple records at once usingSequenceRecordReader.loadSequenceFromMetaData(List)- Specified by:
loadSequenceFromMetaDatain interfaceSequenceRecordReader- Parameters:
recordMetaData- Metadata for the sequence record that we want to load from- Returns:
- Single sequence record for the given RecordMetaData instance
- Throws:
IOException- If I/O error occurs during loading
-
loadSequenceFromMetaData
public List<SequenceRecord> loadSequenceFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException
Description copied from interface:SequenceRecordReaderLoad multiple sequence records from the given a list ofRecordMetaDatainstances- Specified by:
loadSequenceFromMetaDatain interfaceSequenceRecordReader- Parameters:
recordMetaDatas- Metadata for the records that we want to load from- Returns:
- Multiple sequence record for the given RecordMetaData instances
- Throws:
IOException- If I/O error occurs during loading
-
initialize
public void initialize(InputSplit split) throws IOException, InterruptedException
Description copied from interface:RecordReaderCalled once at initialization.- Specified by:
initializein interfaceRecordReader- Parameters:
split- the split that defines the range of records to read- Throws:
IOExceptionInterruptedException
-
initialize
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException
Description copied from interface:RecordReaderCalled once at initialization.- Specified by:
initializein interfaceRecordReader- Parameters:
conf- a configuration for initializationsplit- the split that defines the range of records to read- Throws:
IOExceptionInterruptedException
-
batchesSupported
public boolean batchesSupported()
Description copied from interface:RecordReaderThis method returns true, if next(int) signature is supported by this RecordReader implementation.- Specified by:
batchesSupportedin interfaceRecordReader- Returns:
-
next
public List<List<Writable>> next(int num)
Description copied from interface:RecordReaderThis method will be used, if batchesSupported() returns true.- Specified by:
nextin interfaceRecordReader- Returns:
-
next
public List<Writable> next()
Description copied from interface:RecordReaderGet the next record- Specified by:
nextin interfaceRecordReader- Returns:
-
hasNext
public boolean hasNext()
Description copied from interface:RecordReaderWhether there are anymore records- Specified by:
hasNextin interfaceRecordReader- Returns:
-
getLabels
public List<String> getLabels()
Description copied from interface:RecordReaderList of label strings- Specified by:
getLabelsin interfaceRecordReader- Returns:
-
reset
public void reset()
Description copied from interface:RecordReaderReset record reader iterator- Specified by:
resetin interfaceRecordReader
-
resetSupported
public boolean resetSupported()
- Specified by:
resetSupportedin interfaceRecordReader- Returns:
- True if the record reader can be reset, false otherwise. Note that some record readers cannot be reset - for example, if they are backed by a non-resettable input split (such as certain types of streams)
-
record
public List<Writable> record(URI uri, DataInputStream dataInputStream) throws IOException
Description copied from interface:RecordReaderLoad the record from the given DataInputStream UnlikeRecordReader.next()the internal state of the RecordReader is not modified Implementations of this method should not close the DataInputStream- Specified by:
recordin interfaceRecordReader- Throws:
IOException- if error occurs during reading from the input stream
-
nextRecord
public Record nextRecord()
Description copied from interface:RecordReaderSimilar toRecordReader.next(), but returns aRecordobject, that may include metadata such as the source of the data- Specified by:
nextRecordin interfaceRecordReader- Returns:
- next record
-
loadFromMetaData
public Record loadFromMetaData(RecordMetaData recordMetaData) throws IOException
Description copied from interface:RecordReaderLoad a single record from the givenRecordMetaDatainstance
Note: that for data that isn't splittable (i.e., text data that needs to be scanned/split), it is more efficient to load multiple records at once usingRecordReader.loadFromMetaData(List)- Specified by:
loadFromMetaDatain interfaceRecordReader- Parameters:
recordMetaData- Metadata for the record that we want to load from- Returns:
- Single record for the given RecordMetaData instance
- Throws:
IOException- If I/O error occurs during loading
-
loadFromMetaData
public List<Record> loadFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException
Description copied from interface:RecordReaderLoad multiple records from the given a list ofRecordMetaDatainstances- Specified by:
loadFromMetaDatain interfaceRecordReader- Parameters:
recordMetaDatas- Metadata for the records that we want to load from- Returns:
- Multiple records for the given RecordMetaData instances
- Throws:
IOException- If I/O error occurs during loading
-
getListeners
public List<RecordListener> getListeners()
Description copied from interface:RecordReaderGet the record listeners for this record reader.- Specified by:
getListenersin interfaceRecordReader
-
setListeners
public void setListeners(RecordListener... listeners)
Description copied from interface:RecordReaderSet the record listeners for this record reader.- Specified by:
setListenersin interfaceRecordReader
-
setListeners
public void setListeners(Collection<RecordListener> listeners)
Description copied from interface:RecordReaderSet the record listeners for this record reader.- Specified by:
setListenersin interfaceRecordReader
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
setConf
public void setConf(Configuration conf)
Description copied from interface:ConfigurableSet the configuration to be used by this object.- Specified by:
setConfin interfaceConfigurable
-
getConf
public Configuration getConf()
Description copied from interface:ConfigurableReturn the configuration used by this object.- Specified by:
getConfin interfaceConfigurable
-
-