 	   TreeSet
 	   ])
  (:import [org.dada.core
+	   Batcher
 	   Creator
 	   Metadata
 	   Model

(def #^Metadata whale-metadata (apply metadata Whale :time :version attributes))
(def #^Model whales (model "Whales" whale-metadata))

(def num-whales 1000)
(def start-time (System/currentTimeMillis))

(insert *metamodel* whales)

;; TODO - Why does insert-n work here, but not insert ?

;; create some whales and insert them into model
(insert-n
 whales
 (let [#^Creator creator (.getCreator whale-metadata)
       max-length-x-100 (* max-length 100)
       max-weight-x-100 (* max-weight 100)]
   (for [id (range start-time (+ start-time num-whales))]
     (.create
      creator
      (into-array
       Object
       [(DateMidnight. (+ (rand-int 10) 2000)
		       (+ (rand-int 12) 1)
		       (+ (rand-int 28) 1))
	0
	(rnd types)
	(/ (rand-int max-length-x-100) 100)
	(/ (rand-int max-weight-x-100) 100)])))))

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


;; simplify splitting - Sparse splitting should use Object keys, not only int
;; transform needs to suppport synthetic attributes

;; create 10,000 whales and insert them into model
 ;;whales
(doall
 (let [batcher (Batcher. 999 1000 (list whales))
       #^Creator creator (.getCreator whale-metadata)
       max-length-x-100 (* max-length 100)
       max-weight-x-100 (* max-weight 100)]
   (for [id (range start-time (+ start-time num-whales))]
     (insert
      batcher
      (.create
       creator
       (into-array
	Object
	[(DateMidnight. (+ (rand-int 10) 2000)
			(+ (rand-int 12) 1)
			(+ (rand-int 28) 1))
	 0
	 (rnd types)
	 (/ (rand-int max-length-x-100) 100)
	 (/ (rand-int max-weight-x-100) 100)]))))))

(println "LOADED!")


;; need some form of pluggable sorting algorithm

;; operations are:
