       all-whales
       :type
       nil
-      #(union
-	(ccount
-	 (split
-	  %
-	  :time
-	  (fn [time] (list (or (.lower years time) time)))
-	  )))
+      #(pivot
+	(union
+	 (ccount
+	  (split
+	   %
+	   :time
+	   (fn [time] (list (or (.lower years time) time)))
+	   )))
+	:time
+	years
+	(keyword (count-value-key nil)))
       ))
 
 ;;(def counted-whales-by-type (ccount whales-by-type))



(defn union [[#^Model src-metamodel #^Metadata src-metadata #^Collection extra-keys] & [#^String prefix]]
  (let [tgt-model (model (str (or prefix (name (gensym "HERE"))) ".union()") nil src-metadata)
	tgt-metamodel (meta-view ".union()" src-metamodel (fn [tgt-metamodel src-model & extra-values] (connect src-model tgt-model)))]
    (insert *metamodel* tgt-model)
    (insert tgt-metamodel [tgt-model])
    [tgt-metamodel src-metadata extra-keys]))

;;--------------------------------------------------------------------------------


;; create some whales...

(def num-whales 1000)

(time
 (doall
