 
 (defn index-vertex
   [g spo]
-  (add-vertex! g {::val {}
-                  ::collect-fn (collect-index spo)
-                  ::score-signal-fn (constantly 1)}))
+  (add-vertex!
+   g {::val             {}
+      ::collect-fn      (collect-index spo)
+      ::score-signal-fn (constantly 1)}))
 
 (def s-idx (index-vertex g 0))
 (def p-idx (index-vertex g 1))

   [taoensso.timbre :refer [debug info warn error]]
   [clojure.set :as set]))

(taoensso.timbre/set-level! :warn)

;;(warn :free-ram (.freeMemory (Runtime/getRuntime)))


(def aggregate-select
  (simple-collect
   (fn [val incoming]
     (let [res (vals (peek incoming))]
       ;;(info :res res)
       (when (and (seq res) (every? #(not= #{nil} %) res))
         (->> res
              (map #(disj % nil))
              (set)
              (sort-by count)
              (reduce set/intersection)
              (map #(deref (vertex-for-id g %)))))))))

;; TODO figure out way how to at to a running context
(defn add-query
  [g s p o]
  (let [acc (add-vertex! g {::val {}  ::collect-fn collect-select})
        res (add-vertex! g {::val nil ::collect-fn aggregate-select})]
    (connect-to! s-idx acc signal-select [0 s])
    (connect-to! p-idx acc signal-select [1 p])
