目录
1.FileInputFormat的实现类
FileInputFormat常见的接口实现类包括:TextInputformat,KeyValueTextInputFormat,NLineInputFormat,CombineTextInputFormat和自定义的InputFormat等;
2.TextInputFormat
TextInputFormat时默认的FileInputFormat实现类。按行读取每条记录。键是存储该行在整个文件的起始字节偏移量,LongWritable类型。值是这行的内容,不包括任何终止符(换行符和回车符),Text类型。
2.1TextInputFormat实例
3.KeyValueTextInputFormat
每一行均为一条记录,被分割符分割为key,value.可以通过在驱动类中设置conf.set(KeyValueLineRecordReader.KEY_VALUE_SEPERATTOR,"\t");来设定分隔符。默认分隔符是tab(\t)。
3.1TextInputFormat实例
4.NLineInputFormat
使用NLineInputFormat,代表每个map进程处理的InputSplit不再按Block块去划分,而是按NLineInputFormat指定的行数来划分,即输入文件的总行数/N=切片数,如果不整除,切片数=商+1。