Created
March 3, 2015 13:55
-
-
Save erasmas/642f6c6f0f574b68a368 to your computer and use it in GitHub Desktop.
Clojure fn that recursively find directories on HDFS containing *.parquet files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn dirs-with-parquet | |
"Recursively find directories on HDFS that contain *.parquet files" | |
[path] | |
(let [fs (FileSystem/getLocal (Configuration.)) | |
directory (Path. path) | |
dir? #(.isDirectory fs %) | |
contains-parquet (fn [path] (not (empty? (.globStatus fs (Path. path "*.parquet"))))) | |
dirs (tree-seq dir? | |
(fn [path] (map #(.getPath %) (.listStatus fs path))) | |
directory)] | |
(->> dirs | |
(filter contains-parquet) | |
(map #(.getPath (.toUri %)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment