In Hadoop, Input files stores the data for a MapReducejob. Input files which stores data typically reside in HDFS. Thus, in MapReduce, InputFormat defines how these input files split and read. InputFormat creates Inputsplit.
Most common InputFormat are:
FileInputFormat- It is the base class for all file-based InputFormat. It specifies input directory where data files are present. FileInputFormat also read all files. And, then divides these files into one or more InputSplits.
TextInputFormat- It is the default InputFormat of MapReduce. It uses each line of each input file as separate record. Thus, performs no parsing.
Key- byte offset.
Value- It is the contents of the line, excluding line terminators.
Example content of file- is john may which katty
Value- is john may which katty
KeyValueTextInputFormat- It is similar to TextInputFormat. Hence, it treats each line of input as a separate record. But the main difference is that TextInputFormat treats entire line as the value. While the KeyValueTextInputFormat breaks the line itself into key and value by the tab character (‘/t’).
Key- Everything up to tab character.
Value- Remaining part of the line after tab character.
Example content of file- is -> john may which katty
Value- john may which katty
Tab character “->”
SequenceFileInputFormat- It is the InputFormat which reads sequence files. Key & Value- Both are user-defined.
3. Sequence File Input Format
a. As Binary Input
b. As text Input
Among them Text Input Format is the Hadoop default one.
Other than these there are some more input formats based on requirements as follows:-
10. FileInputFormat, etc.