If you want to merge multiple files into single file then here is two ans :
getmerge
Run Code Online (Sandbox Code Playgroud)
Usage: hadoop fs -getmerge <src> <localdst>
Takes a source directory and a destination file as input and concatenates files in src into the destination local file. Optionally addnl can be set to enable adding a newline character at the end of each file.
org.apache.hadoop.fs.FileUtil.copyMerge(FileSystem srcFS, Path srcDir, FileSystem dstFS, Path dstFile, boolean deleteSource, Configuration conf, String addString);
Run Code Online (Sandbox Code Playgroud)
Copy all files in a directory to one output file (merge)
put
Run Code Online (Sandbox Code Playgroud)
Usage: hadoop dfs -put <localsrc> ... <dst>
将单个 src 或多个 src 从本地文件系统复制到目标文件系统。还从 stdin 读取输入并写入目标文件系统。
copyFromLocal
Run Code Online (Sandbox Code Playgroud)
用法: hadoop dfs -copyFromLocal <localsrc> URI
类似于 put 命令,除了源被限制为本地文件引用。
如果您正在处理大量序列文件,我建议编写一个 MapReduce 作业,将其用作Mapper映射器和Reducer化简器。对于 I/O 格式,使用SequenceFileInputFormat和SequenceFileOutputFormat。将减速器的数量设置为 1。这些都是您在驱动程序/主代码的配置和作业对象中设置的内容。了解如何设置输出格式、如何设置输入格式、如何设置映射器以及如何设置化简器。
Mapper请注意,和的默认行为Reducer是不对数据执行任何操作 - 只是将其传递。这就是为什么你不在这里编写map函数或reduce函数。
这样做的作用是加载序列文件,不对映射器中的数据执行任何操作,将所有记录混洗到减速器,然后将它们全部输出到一个文件。这确实会对输出序列文件中的键进行排序产生副作用。
| 归档时间: |
|
| 查看次数: |
11421 次 |
| 最近记录: |