   (.write w (str (count (triples g))))
   (.write w " triples)>"))
 
-
-;; (defn make-index [triples key1 key2 key3]
-;;   (reduce (fn [i0 triple]
-;;             (let [i1 (or (i0 (key1 triple)) {})
-;;                   i2 (or (i1 (key2 triple)) #{})]
-;;               (assoc i0
-;;                 (key1 triple)
-;;                 (assoc i1
-;;                   (key2 triple)
-;;                   (conj i2 (key3 triple))))))
-;;     {} triples))
 
 (defn make-index [triples key1 key2 key3]
   (reduce (fn [i0 triple]

;;  => #<Graph 6d863860-723d-1195-8101-7831c1bbb832 (1 triples)>
;;  => #<Graph 6d863860-723d-1195-8101-7831c1bbb832 (1 triples)>

(defmacro with-context [designator & body]
  `(binding [*context* (intern-graph (graph ~designator))]
     ~@body))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Indexed Database Query
;;
;; Implememnted as a multifunction rather than protocol to allow modular
;; separation of implmentation based on supplied constituents of query.

      (id x)
      (util/returning (id g)
        (swap! db #(into % [[(id g) g] [(triples g) g]]))))))
  
(def ^{:dynamic true} *context* (intern-graph (graph nil)))

(extend-type java.util.UUID GraphBuilder
             (graph [this]
               (get @db this)))

(defmacro with-context [designator & body]
  `(binding [*context* (intern-graph (graph ~designator))]
     ~@body))


;; (assert (= (graph *context*) (graph nil) (graph uuid/+null+)))

