Class FixedLengthInputFormat
java.lang.Object
org.apache.hadoop.mapreduce.InputFormat<K,V>
org.apache.hadoop.mapreduce.lib.input.FileInputFormat<LongWritable,BytesWritable>
org.apache.hadoop.mapreduce.lib.input.FixedLengthInputFormat
@Public
@Stable
public class FixedLengthInputFormat
extends FileInputFormat<LongWritable,BytesWritable>
FixedLengthInputFormat is an input format used to read input files
which contain fixed length records. The content of a record need not be
text. It can be arbitrary binary data. Users must configure the record
length property by calling:
FixedLengthInputFormat.setRecordLength(conf, recordLength);
or conf.setInt(FixedLengthInputFormat.FIXED_RECORD_LENGTH, recordLength);
or conf.setInt(FixedLengthInputFormat.FIXED_RECORD_LENGTH, recordLength);
- See Also:
-
FixedLengthRecordReader
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.mapreduce.lib.input.FileInputFormat
FileInputFormat.Counter -
Field Summary
FieldsFields inherited from class org.apache.hadoop.mapreduce.lib.input.FileInputFormat
DEFAULT_LIST_STATUS_NUM_THREADS, INPUT_DIR, INPUT_DIR_NONRECURSIVE_IGNORE_SUBDIRS, INPUT_DIR_RECURSIVE, LIST_STATUS_NUM_THREADS, NUM_INPUT_FILES, PATHFILTER_CLASS, SPLIT_MAXSIZE, SPLIT_MINSIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateRecordReader(InputSplit split, TaskAttemptContext context) Create a record reader for a given split.static intgetRecordLength(Configuration conf) Get record length valueprotected booleanisSplitable(JobContext context, Path file) Is the given filename splittable?static voidsetRecordLength(Configuration conf, int recordLength) Set the length of each recordMethods inherited from class org.apache.hadoop.mapreduce.lib.input.FileInputFormat
addInputPath, addInputPathRecursively, addInputPaths, computeSplitSize, getBlockIndex, getFormatMinSplitSize, getInputDirRecursive, getInputPathFilter, getInputPaths, getMaxSplitSize, getMinSplitSize, getSplits, listStatus, makeSplit, makeSplit, setInputDirRecursive, setInputPathFilter, setInputPaths, setInputPaths, setMaxInputSplitSize, setMinInputSplitSize, shrinkStatus
-
Field Details
-
FIXED_RECORD_LENGTH
- See Also:
-
-
Constructor Details
-
FixedLengthInputFormat
public FixedLengthInputFormat()
-
-
Method Details
-
setRecordLength
Set the length of each record- Parameters:
conf- configurationrecordLength- the length of a record
-
getRecordLength
Get record length value- Parameters:
conf- configuration- Returns:
- the record length, zero means none was set
-
createRecordReader
public RecordReader<LongWritable,BytesWritable> createRecordReader(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException Description copied from class:InputFormatCreate a record reader for a given split. The framework will callRecordReader.initialize(InputSplit, TaskAttemptContext)before the split is used.- Specified by:
createRecordReaderin classInputFormat<LongWritable,BytesWritable> - Parameters:
split- the split to be readcontext- the information about the task- Returns:
- a new record reader
- Throws:
IOExceptionInterruptedException
-
isSplitable
Description copied from class:FileInputFormatIs the given filename splittable? Usually, true, but if the file is stream compressed, it will not be. The default implementation inFileInputFormatalways returns true. Implementations that may deal with non-splittable files must override this method.FileInputFormatimplementations can override this and returnfalseto ensure that individual input files are never split-up so thatMappers process entire files.- Overrides:
isSplitablein classFileInputFormat<LongWritable,BytesWritable> - Parameters:
context- the job contextfile- the file name to check- Returns:
- is this file splitable?
-