Skip to content

Instantly share code, notes, and snippets.

@kovasb
Created October 6, 2014 22:38
Show Gist options
  • Save kovasb/a641c42ce0bd120296cb to your computer and use it in GitHub Desktop.
Save kovasb/a641c42ce0bd120296cb to your computer and use it in GitHub Desktop.
(require '[clojure.data.fressian :as fress])
(require '[clojure.java.io :as io])
(import 'java.util.zip.GZIPInputStream)
(defn fress-seq* [reader]
(let [x (try (fress/read-object reader) (catch Exception e :eof))]
(if (= :eof x)
(do (.close reader) nil)
(cons x
(lazy-seq (fress-seq* reader))))))
(defn fress-seq [file]
(let [ is (GZIPInputStream. (io/input-stream (io/file file)))
r (fress/create-reader is)]
(.read is)
(fress-seq* r)))
(count (fress-seq "/Users/kovasb/data/events.fress.gzip"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment