Class ListStringRecordReader
- java.lang.Object
-
- org.datavec.api.records.reader.BaseRecordReader
-
- org.datavec.api.records.reader.impl.collection.ListStringRecordReader
-
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable,Configurable,RecordReader
public class ListStringRecordReader extends BaseRecordReader
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.datavec.api.records.reader.BaseRecordReader
inputSplit, listeners, streamCreatorFn
-
Fields inherited from interface org.datavec.api.records.reader.RecordReader
APPEND_LABEL, LABELS, NAME_SPACE
-
-
Constructor Summary
Constructors Constructor Description ListStringRecordReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this stream and releases any system resources associated with it.ConfigurationgetConf()Return the configuration used by this object.List<String>getLabels()List of label stringsbooleanhasNext()Check 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<Writable>next()Get the next recordRecordnextRecord()Similar toRecordReader.next(), 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 Unlikenext()the internal state of the RecordReader is not modified Implementations of this method should not close the DataInputStreamvoidreset()Reset record reader iteratorbooleanresetSupported()voidsetConf(Configuration conf)Set the configuration to be used by this object.-
Methods inherited from class org.datavec.api.records.reader.BaseRecordReader
batchesSupported, getListeners, invokeListeners, next, setListeners, setListeners
-
-
-
-
Method Detail
-
initialize
public void initialize(InputSplit split) throws IOException, InterruptedException
Called once at initialization.- Specified by:
initializein interfaceRecordReader- Overrides:
initializein classBaseRecordReader- 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
Called once at initialization.- Parameters:
conf- a configuration for initializationsplit- the split that defines the range of records to read- Throws:
IOExceptionInterruptedException
-
hasNext
public boolean hasNext()
Check whether there are anymore records- Returns:
- Whether there are more records
-
reset
public void reset()
Reset record reader iterator
-
resetSupported
public boolean resetSupported()
- 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
Load the record from the given DataInputStream Unlikenext()the internal state of the RecordReader is not modified Implementations of this method should not close the DataInputStream- Parameters:
uri-dataInputStream-- 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- 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)- 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- 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
-
close
public void close() throws IOExceptionCloses this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.As noted in
AutoCloseable.close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark theCloseableas closed, prior to throwing theIOException.- Throws:
IOException- if an I/O error occurs
-
setConf
public void setConf(Configuration conf)
Set the configuration to be used by this object.- Parameters:
conf-
-
getConf
public Configuration getConf()
Return the configuration used by this object.
-
-