我想在HDFS中创建一个文件并在其中写入数据.我用过这段代码:
Configuration config = new Configuration();
FileSystem fs = FileSystem.get(config);
Path filenamePath = new Path("input.txt");
try {
if (fs.exists(filenamePath)) {
fs.delete(filenamePath, true);
}
FSDataOutputStream fin = fs.create(filenamePath);
fin.writeUTF("hello");
fin.close();
}
Run Code Online (Sandbox Code Playgroud)
它会创建文件,但不会在其中写入任何内容.我搜索了很多但没有找到任何东西.我的问题是什么?我是否需要获得HDFS写入权限?
谢谢.
我是hadoop的新手,我正在使用wordcount示例中的大量小文件.它需要大量的地图任务并导致我的执行速度变慢.
我怎样才能减少地图任务的数量?
如果我的问题的最佳解决方案是将小文件捕获到更大的文件,我该如何捕捉它们?
我的问题是在文件中排序值.键和值是整数,需要维护排序值的键.
key value
1 24
3 4
4 12
5 23
Run Code Online (Sandbox Code Playgroud)
输出:
1 24
5 23
4 12
3 4
Run Code Online (Sandbox Code Playgroud)
我正在处理大量数据,必须在hadoop机器集群中运行代码.我怎么能用mapreduce做到这一点?
我想使用lzo来压缩地图输出,但我无法运行它!我使用的Hadoop版本是0.20.2
.我设置:
conf.set("mapred.compress.map.output", "true")
conf.set("mapred.map.output.compression.codec",
"org.apache.hadoop.io.compress.LzoCodec");
Run Code Online (Sandbox Code Playgroud)
当我在Hadoop中运行jar文件时,它显示一个无法写入地图输出的异常.
我必须安装lzo吗?使用lzo我该怎么办?