【问题标题】:Hdfs folder size in ClojureClojure 中的 hdfs 文件夹大小
【发布时间】:2016-07-01 06:12:14
【问题描述】:

我必须拥有来自 Clojure 的子目录的 HDFS 文件夹大小。如何在 Clojure 中使用 getContentSummary 和 getSpaceConsumed。我知道如何在 Java 中做到这一点。

 FileSystem fs = FileSystem.get(config);
 Path current = new Path(path);
 double size= fs.getContentSummary(current).getSpaceConsumed();

已经设置了配置并且路径被传递到这个函数中。所以 size 现在有作为路径提到的目录的大小。这是在 Java 中。我想知道如何在 Clojure 中做到这一点。

谢谢。

【问题讨论】:

  • 请添加更多信息和一些代码。向我们展示您已经尝试过的内容
  • 完成。我想知道如何在 Clojure 中实现我的第三行代码。
  • 你的意思是:(-> (.getContentSummary current) .getSpaceConsumed)

标签: java clojure hdfs clojurescript clojure-java-interop


【解决方案1】:

你“只是”需要关注java interop guide

(let [fs (FileSystem/get config)
      current (Path. path)
      size (.getSpaceConsumed (.getContentSummary fs current))]
  (println size))

或者使用“->”宏,让它读起来更像Java:

(let [fs (FileSystem/get config)
      current (Path. path)
      size (-> fs (.getContentSummary current) .getSpacedConsumed)]
  (println size))

【讨论】:

    猜你喜欢
    • 2018-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-24
    • 1970-01-01
    • 2014-11-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多