我正在尝试设置一个利用 dynamodb 的并行扫描功能的 MapReduce 任务。
基本上,我希望每个 Mapper 类都将一个元组作为输入值。
到目前为止,我看到的每个示例都设置了这一点:
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
我可以将作业的输入格式设置为 hashMap 吗?
我认为您希望将文件作为键值对读取,而不是作为读取 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.)