ファイルをinputSlipt(キーとしての行番号と値としての行)を読み取る標準的な方法としてではなく、キーと値のペアとして読み取りたいと思います。あなたが尋ねたのであれば、以下のKeyValueTextInputFormatを使用できます。説明は Hadoop で見つけることができます: 決定的なガイド
KeyValueTextInputFormat
TextInputFormat’s keys, being simply the offset within the file, are not normally
very useful. It is common for each line in a file to be a key-value pair,
separated by a delimiter such as a tab character. For example, this is the output
produced by TextOutputFormat, Hadoop’s default OutputFormat. To interpret such
files correctly, KeyValueTextInputFormat is appropriate.
You can specify the separator via the key.value.separator.in.input.line property.
It is a tab character by default. Consider the following input file,
where → represents a (horizontal) tab character:
line1→On the top of the Crumpetty Tree
line2→The Quangle Wangle sat,
line3→But his face you could not see,
line4→On account of his Beaver Hat.
Like in the TextInputFormat case, the input is in a single split comprising four
records, although this time the keys are the Text sequences before the tab in
each line:
(line1, On the top of the Crumpetty Tree)
(line2, The Quangle Wangle sat,)
(line3, But his face you could not see,)
(line4, On account of his Beaver Hat.)