public abstract class BaseImageRecordReader extends BaseRecordReader
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<java.lang.String> |
allPaths |
protected boolean |
appendLabel |
protected int |
channels |
static java.lang.String |
CHANNELS |
protected Configuration |
conf |
static java.lang.String |
CROP_IMAGE |
protected boolean |
cropImage |
protected java.io.File |
currentFile |
protected java.util.Map<java.lang.String,java.lang.String> |
fileNameMap |
protected int |
height |
static java.lang.String |
HEIGHT |
protected boolean |
hitImage |
static java.lang.String |
IMAGE_LOADER |
protected BaseImageLoader |
imageLoader |
protected ImageTransform |
imageTransform |
protected InputSplit |
inputSplit |
protected java.util.Iterator<java.io.File> |
iter |
protected PathLabelGenerator |
labelGenerator |
protected java.util.List<java.lang.String> |
labels |
protected java.lang.String |
pattern |
protected int |
patternPosition |
protected java.util.List<Writable> |
record |
protected int |
width |
static java.lang.String |
WIDTH |
listenersAPPEND_LABEL, LABELS, NAME_SPACE| Constructor and Description |
|---|
BaseImageRecordReader() |
BaseImageRecordReader(int height,
int width,
int channels,
PathLabelGenerator labelGenerator) |
BaseImageRecordReader(int height,
int width,
int channels,
PathLabelGenerator labelGenerator,
ImageTransform imageTransform) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
accumulateLabel(java.lang.String path)
Accumulate the label from the path
|
void |
close() |
protected boolean |
containsFormat(java.lang.String format) |
Configuration |
getConf()
Return the configuration used by this object.
|
java.io.File |
getCurrentFile()
Returns the file loaded last by
next(). |
java.lang.String |
getLabel(java.lang.String path)
Get the label from the given path
|
java.util.List<java.lang.String> |
getLabels()
List of label strings
|
boolean |
hasNext()
Whether there are anymore records
|
void |
initialize(Configuration conf,
InputSplit split)
Called once at initialization.
|
void |
initialize(Configuration conf,
InputSplit split,
ImageTransform imageTransform)
Called once at initialization.
|
void |
initialize(InputSplit split)
Called once at initialization.
|
void |
initialize(InputSplit split,
ImageTransform imageTransform)
Called once at initialization.
|
java.util.List<Record> |
loadFromMetaData(java.util.List<RecordMetaData> recordMetaDatas)
Load multiple records from the given a list of
RecordMetaData instances |
Record |
loadFromMetaData(RecordMetaData recordMetaData)
Load a single record from the given
RecordMetaData instanceNote: 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 using RecordReader.loadFromMetaData(List) |
java.util.List<Writable> |
next()
Get the next record
|
Record |
nextRecord()
Similar to
RecordReader.next(), but returns a Record object, that may include metadata such as the source
of the data |
int |
numLabels()
Returns
getLabels().size(). |
java.util.List<Writable> |
record(java.net.URI uri,
java.io.DataInputStream dataInputStream)
Load the record from the given DataInputStream
Unlike
RecordReader.next() the internal state of the RecordReader is not modified
Implementations of this method should not close the DataInputStream |
void |
reset()
Reset record reader iterator
|
void |
setConf(Configuration conf)
Set the configuration to be used by this object.
|
void |
setCurrentFile(java.io.File currentFile)
Sets manually the file returned by
getCurrentFile(). |
void |
setLabels(java.util.List<java.lang.String> labels) |
getListeners, invokeListeners, setListeners, setListenersprotected java.util.List<java.lang.String> allPaths
protected java.util.Iterator<java.io.File> iter
protected Configuration conf
protected java.io.File currentFile
protected PathLabelGenerator labelGenerator
protected java.util.List<java.lang.String> labels
protected boolean appendLabel
protected java.util.List<Writable> record
protected boolean hitImage
protected int height
protected int width
protected int channels
protected boolean cropImage
protected ImageTransform imageTransform
protected BaseImageLoader imageLoader
protected InputSplit inputSplit
protected java.util.Map<java.lang.String,java.lang.String> fileNameMap
protected java.lang.String pattern
protected int patternPosition
public static final java.lang.String HEIGHT
public static final java.lang.String WIDTH
public static final java.lang.String CHANNELS
public static final java.lang.String CROP_IMAGE
public static final java.lang.String IMAGE_LOADER
public BaseImageRecordReader()
public BaseImageRecordReader(int height,
int width,
int channels,
PathLabelGenerator labelGenerator)
public BaseImageRecordReader(int height,
int width,
int channels,
PathLabelGenerator labelGenerator,
ImageTransform imageTransform)
protected boolean containsFormat(java.lang.String format)
public void initialize(InputSplit split) throws java.io.IOException
RecordReadersplit - the split that defines the range of records to readjava.io.IOExceptionpublic void initialize(Configuration conf, InputSplit split) throws java.io.IOException, java.lang.InterruptedException
RecordReaderconf - a configuration for initializationsplit - the split that defines the range of records to readjava.io.IOExceptionjava.lang.InterruptedExceptionpublic void initialize(InputSplit split, ImageTransform imageTransform) throws java.io.IOException
split - the split that defines the range of records to readimageTransform - the image transform to use to transform images while loading themjava.io.IOExceptionpublic void initialize(Configuration conf, InputSplit split, ImageTransform imageTransform) throws java.io.IOException, java.lang.InterruptedException
conf - a configuration for initializationsplit - the split that defines the range of records to readimageTransform - the image transform to use to transform images while loading themjava.io.IOExceptionjava.lang.InterruptedExceptionpublic java.util.List<Writable> next()
RecordReaderpublic boolean hasNext()
RecordReaderpublic void close()
throws java.io.IOException
java.io.IOExceptionpublic void setConf(Configuration conf)
Configurablepublic Configuration getConf()
Configurablepublic java.lang.String getLabel(java.lang.String path)
path - the path to get the label fromprotected void accumulateLabel(java.lang.String path)
path - the path to get the label frompublic java.io.File getCurrentFile()
next().public void setCurrentFile(java.io.File currentFile)
getCurrentFile().public java.util.List<java.lang.String> getLabels()
RecordReaderpublic void setLabels(java.util.List<java.lang.String> labels)
public void reset()
RecordReaderpublic int numLabels()
getLabels().size().public java.util.List<Writable> record(java.net.URI uri, java.io.DataInputStream dataInputStream) throws java.io.IOException
RecordReaderRecordReader.next() the internal state of the RecordReader is not modified
Implementations of this method should not close the DataInputStreamjava.io.IOException - if error occurs during reading from the input streampublic Record nextRecord()
RecordReaderRecordReader.next(), but returns a Record object, that may include metadata such as the source
of the datapublic Record loadFromMetaData(RecordMetaData recordMetaData) throws java.io.IOException
RecordReaderRecordMetaData instanceRecordReader.loadFromMetaData(List)recordMetaData - Metadata for the record that we want to load fromjava.io.IOException - If I/O error occurs during loadingpublic java.util.List<Record> loadFromMetaData(java.util.List<RecordMetaData> recordMetaDatas) throws java.io.IOException
RecordReaderRecordMetaData instancesrecordMetaDatas - Metadata for the records that we want to load fromjava.io.IOException - If I/O error occurs during loading