   (:import [java.util List Map Set]
            [org.apache.hadoop.conf Configuration Configurable]
            [org.apache.hadoop.mapreduce Job JobContext]))
+
+(def ^:dynamic ^:private *default*
+  "Base configuration, used as template for fresh configurations."
+  (Configuration.))
 
 (defmulti ^:private configuration*
   "Internal implementation multimethod for extracting a `Configuration`."

  "Merge key-value pairs `kvs` into Hadoop configuration `conf`."
  [conf & kvs] (merge! conf (partition 2 kvs)))

(defn clone
  "Return new Hadoop `Configuration`, cloning `conf`."
  [conf] (Configuration. (configuration conf)))

(defmethod configuration* Configuration [conf] conf)
(defmethod configuration* Configurable
  [cable] (.getConf ^Configurable cable))

(defn configuration
  "Extract or produce a Hadoop `Configuration`.  If provided a `conf`
argument, coerce it to be a `Configuration` which if possible shares
mutable state with that original argument.  If not, return a fresh
configuration copied from the current default."
  {:tag `Configuration}
  ([] (Configuration. *default*))
  ([conf] (configuration* conf)))

(def ^{:tag `Configuration} iguration
