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 |
listeners
APPEND_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, setListeners
protected 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
RecordReader
split
- the split that defines the range of records to readjava.io.IOException
public void initialize(Configuration conf, InputSplit split) throws java.io.IOException, java.lang.InterruptedException
RecordReader
conf
- a configuration for initializationsplit
- the split that defines the range of records to readjava.io.IOException
java.lang.InterruptedException
public 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.IOException
public 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.IOException
java.lang.InterruptedException
public java.util.List<Writable> next()
RecordReader
public boolean hasNext()
RecordReader
public void close() throws java.io.IOException
java.io.IOException
public void setConf(Configuration conf)
Configurable
public Configuration getConf()
Configurable
public 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()
RecordReader
public void setLabels(java.util.List<java.lang.String> labels)
public void reset()
RecordReader
public int numLabels()
getLabels().size()
.public java.util.List<Writable> record(java.net.URI uri, java.io.DataInputStream dataInputStream) throws java.io.IOException
RecordReader
RecordReader.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()
RecordReader
RecordReader.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
RecordReader
RecordMetaData
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
RecordReader
RecordMetaData
instancesrecordMetaDatas
- Metadata for the records that we want to load fromjava.io.IOException
- If I/O error occurs during loading