   (:require [noir.response :as response])
   (:require [ring.util.codec :as codec])
   (:require [clojure.edn :as edn])
-  (:require [clojure.data.json :as json])
+  (:require [cheshire.custom :as json])
   (:require [cavm.h2 :as h2])
+  (:import mikera.matrixx.Matrix)
+  (:import mikera.vectorz.impl.ArraySubVector)
   (:gen-class))
 
 (defpage [:get "/datasets"] []

                         {:experiment exp
                          :sample samp}) (repeat ('table %)) ('samples %)))))

(def functions
  {'fetch sources/read-symbols
   'query h2/run-query

  (let [{db :db} (ring-request)]
    (response/json (d/query db (edn/read-string query)))))

; pretty-print query
(defpage [:get ["/query-p/:query" :query #".+"]] {:keys [query]}
  (let [{db :db} (ring-request)]
    (response/content-type "application/json; charset=utf-8"
                           (binding [clojure.pprint/*print-right-margin* 200]
                             (with-out-str (json/encode (d/query db (edn/read-string query)) {:pretty true}))))))

(defn samples-for-attr [attr]
  {:select [[:experiments.name "experiment"] :exp_samples.name]
