appendtofile和hadoop-put有什么区别

0s7z1bwu  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(489)

根据hadoop源代码,从类中提取以下描述-
附加文件

"Appends the contents of all the given local files to the
given dst file. The dst file will be created if it does not exist."

"Copy files from the local file system into fs. Copying fails if the file already exists, unless the -f flag is given.
Flags:
-p : Preserves access and modification times, ownership and the mode.
-f : Overwrites the destination if it already exists.
-l : Allow DataNode to lazily persist the file to disk. Forces
replication factor of 1. This flag will result in reduced
durability. Use with care.
-d : Skip creation of temporary file(<dst>._COPYING_)."

我正在尝试定期将文件更新到hdfs中,因为它是从本地文件系统中的流源动态更新的。
我应该用哪一个在appendtofile和put之外,为什么?

inn6fuwd

inn6fuwd1#

appendToFile 修改hdfs中的现有文件,因此只需要将新数据流式传输/写入文件系统。 put 重写整个文件,因此需要将文件的整个新版本流式传输/写入文件系统。
你应该帮我个忙 appendToFile 如果您只是附加到文件(即在文件末尾添加日志)。如果这是你的用例,这个函数会更快。如果文件的变化不仅仅是简单的附加到结尾,那么应该使用 put (速度较慢,但不会丢失数据或损坏文件)。

相关问题