[英]Hdfs folder size in Clojure
我必須使用具有Cloclore子目錄的HDFS文件夾大小。 如何在Clojure中使用getContentSummary和getSpaceConsumed。 我知道如何用Java做到這一點。
FileSystem fs = FileSystem.get(config);
Path current = new Path(path);
double size= fs.getContentSummary(current).getSpaceConsumed();
已經設置好配置,並將路徑傳遞到此函數中。 所以size現在具有提到的目錄大小(稱為路徑)。 這是用Java編寫的。 我想知道如何在Clojure中執行此操作。
謝謝。
您“只是”需要遵循Java互操作指南 :
(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))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.