 	     (let [model-entry (list* model (concat extra-values [extra-value]))]
 	       (insert tgt-metamodel model-entry)
 	       (insert *metamodel* model)
+	       (if subchain
+		 (subchain
+		  [(meta-view
+		    (str "=" extra-value)
+		    tgt-metamodel
+		    (fn [tgt-metamodel2 model & extra-values]
+			;;(insert tgt-metamodel tgt-metamodel2)
+			(insert tgt-metamodel2 model-entry)
+			;;(insert *metamodel* model)
+			))
+		   src-metadata
+		   (concat extra-keys [split-key])]))
+	       model
 	       )))))
    src-metadata
    (concat extra-keys [split-key])])

       (Date. 8 0 1)
       (Date. 9 0 1))))

(def whales-by-type-and-year (split whales-by-type
				    :time 
				    (fn [time] (list (or (.lower years time) time)))))

(def counted-whales-by-type-and-year (ccount whales-by-type-and-year))
(def grouped-counted-whales-by-type-and-year (union counted-whales-by-type-and-year "Whales.split(:type).split(:time).count()"))

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

;; create some whales...

(def num-whales 1000)

(time
 (doall

		  (doall (map (fn [#^Update insertion] (apply f tgt-metamodel (.getNewValue insertion))) insertions)))))
  tgt-metamodel))

(defn split [[#^Model src-metamodel #^Metadata src-metadata #^Collection extra-keys] split-key & [split-key-fn subchain]]
  [(meta-view
    (str ".split(" split-key")")
    src-metamodel
