我们如何比较 localfile 和 hdfs 文件的一致性

发布于 2024-12-13 03:06:02 字数 698 浏览 2 评论 0原文

    public String getDirs() throws IOException{
        fs=FileSystem.get(conf);
        fs.copyFromLocalFile(new Path("/private/tmp/as"), new Path("/test"));
        LocalFileSystem lfs=LocalFileSystem.getLocal(conf);

//      System.out.println(new LocalFileSystem().ge (conf.getLocalPath("/private/tmp/as")));
        System.out.println("Local Path : "+lfs.getFileChecksum(new Path("/private/tmp/as")));   
        System.out.println("HDFS PATH : "+ fs.getFileChecksum(new Path("/test/as")));
        return "done";
    }

输出是

本地路径:空 HDFS 路径:MD5-of-0MD5-of-512CRC32:a575c5e99b2e08605dc7c6723889519c

不确定为什么本地文件的校验和为空

    public String getDirs() throws IOException{
        fs=FileSystem.get(conf);
        fs.copyFromLocalFile(new Path("/private/tmp/as"), new Path("/test"));
        LocalFileSystem lfs=LocalFileSystem.getLocal(conf);

//      System.out.println(new LocalFileSystem().ge (conf.getLocalPath("/private/tmp/as")));
        System.out.println("Local Path : "+lfs.getFileChecksum(new Path("/private/tmp/as")));   
        System.out.println("HDFS PATH : "+ fs.getFileChecksum(new Path("/test/as")));
        return "done";
    }

Output is

Local Path : null
HDFS PATH : MD5-of-0MD5-of-512CRC32:a575c5e99b2e08605dc7c6723889519c

Not sure why the checksum is null for local file

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱的十字路口 2024-12-20 03:06:02

Hadoop 依赖文件系统来准备匹配的校验和。它不会即时生成一个。

默认情况下,LocalFileSystem(或用于 file:// 路径的特定实现)不会为通过它创建的所有文件创建/存储校验和。您可以通过 FileSystem#setWriteChecksum API 调用,随后检索写入后的校验和即可工作。

Hadoop relies on the FileSystem to have a checksum ready to match against. It does not generate one on-the-fly.

By default, the LocalFileSystem (or the specific implementation used for file:// paths) does not create/store checksums for all files created through it. You can toggle this behavior via the FileSystem#setWriteChecksum API call, and subsequently retrieving the checksum post-write will then work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文