     [clojure.string :as str]
     [clojure.tools.cli :as cli]
     [clojure.tools.logging :as log]
+    [com.stuartsierra.component :as component]
     [merkle-db.database :as db]
     [merkle-db.spark.table-rdd :as table-rdd]
     [merkle-db.table :as table]

  ["load-db" "most-tagged" "best-rated"])


; TODO: best way to pass around store connection parameters to the executors?
(defn- store-constructor
  "Initialize a MerkleDAG graph store from the given config."

    (require 'riemann.client)
    (mdag/init-store
      :encoding [:mdag :gzip :cbor]
      :store (-> (block/->store (:blocks-url cfg))
                 (assoc :riemann/client (when-let [host (:riemann-host cfg)]
                                          (riemann/tcp-client
                                            :host host
                                            :port (:riemann-port cfg 5555)))
                        :blocks.meter/recorder block-recorder
                        :blocks.meter/label "s3")
                 (component/start))
      :cache {:total-size-limit (:cache-size cfg (* 32 1024 1024))}
      :types merkle-db.graph/codec-types)))

