Last active
March 13, 2021 22:17
-
-
Save echeran/f0eee2bc932a8334b2561de82ca18e16 to your computer and use it in GitHub Desktop.
Reusing your fns as Clojure serialized fns to use in Flambo (Spark wrapper for Clojure)
This file contains hidden or 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
(require '[clj-time.core :as t]) | |
(require '[flambo.api :as f]) | |
(defn date-filter-fn | |
"Given a LocalDate, returns a serializable fn that takes a DateTime | |
object and returns true if the DateTime fields match those of the | |
provided LocalDate, else returns false." | |
[local-date] | |
;; returning a serializable fn to be used with Flambo/Spark's filter operation | |
(f/fn | |
[date-time] | |
(boolean | |
(and | |
(= (t/day local-date) (t/day date-time))) | |
(= (t/month local-date) (t/month date-time)) | |
(= (t/year local-date) (t/year date-time)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment