简体   繁体   English

Clojure中的HDFS文件夹大小

[英]Hdfs folder size in Clojure

I have to HDFS folder size which is having sub directories from Clojure. 我必须使用具有Cloclore子目录的HDFS文件夹大小。 How to use getContentSummary and getSpaceConsumed in Clojure. 如何在Clojure中使用getContentSummary和getSpaceConsumed。 I know how to do this in Java. 我知道如何用Java做到这一点。

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

Configuration has been set already and path is passed into this function. 已经设置好配置,并将路径传递到此函数中。 So size now has has the size of the directory mentioned as path. 所以size现在具有提到的目录大小(称为路径)。 This is in Java. 这是用Java编写的。 I want to know how to do this in Clojure. 我想知道如何在Clojure中执行此操作。

Thanks. 谢谢。

you "just" need to follow the java interop guide : 您“只是”需要遵循Java互操作指南

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

Or using the "->" macro, to make it read more like Java: 或使用“->”宏,使其更像Java:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM