 (ns io.cyanite.engine.buckets
-  (:require [io.cyanite.utils :refer [nbhm keyset remove!]]
+  (:require [io.cyanite.utils      :refer [nbhm keyset remove!]]
             [clojure.tools.logging :refer [debug]])
   (:import java.util.concurrent.atomic.AtomicLong
            java.util.concurrent.atomic.AtomicLongArray
-           java.util.concurrent.atomic.AtomicReferenceArray))
+           java.util.concurrent.atomic.AtomicReferenceArray
+           io.cyanite.engine.rule.Resolution))
 
-(deftype MetricTuple [^String id ^String path]
+(deftype MetricTuple [^Resolution id ^String path]
   java.lang.Object
   (hashCode [this]
-    (.hashCode (str id ":" path)))
+    (.hashCode [id path]))
   (equals [this other]
     (and
      (= (.id this) (.id other))

          (debug e "exception while snapshotting"))))))

(defn metric-key
  [^MetricTuple k resolution]
  (MetricKey. k resolution (nbhm) (drift-slot)))

(defn tuple
  [^String id ^String path]
  (MetricTuple. id path))

(comment
  (let [k   (tuple "foo" "bar")
        mk  (metric-key k {:precision 5 :id "foo"})
        now (quot (System/currentTimeMillis) 1000)]
    (add! mk {:time (- now 5) :metric 1.0 :path "bar"})
    (add! mk {:time (- now 5) :metric 1.0 :path "bar"})

    (* p (quot now p))))

(defn insert-slot!
  [time-slots k]
  (let [slot (MetricTimeSlot.
              k
              (AtomicLong. 0)
