      :usertype (id->user-type (get-user-type unsafe address))
      }))
 
-
+(defn to-file [record-collection filename]
+  (with-open [w (io/output-stream (io/file filename))]
+    (serialize record-collection w)))

             @ret
             (recur (inc i) (+ offset object-size) ret)))))))

;; deftype - implement Indexed,Counted,
(deftype RecordCollection [^Unsafe unsafe address num-records]


(ns hikesaber.off-heap-ride-records
  (:require
   [hikesaber.dates :as dates]
   [clojure.string :as string]
   [hikesaber.divvy-ride-records :as records]
   [hikesaber.util.integer-ids :as ids]
   [hikesaber.performance-tools :as perf]
   [clojure.java.io :as io])
  (:import [sun.misc Unsafe]
           [java.io OutputStream DataOutputStream]
           [org.joda.time DateTime]))

;; This namespace is an implementation of the ideas in http://mechanical-sympathy.blogspot.com/2012/10/compact-off-heap-structurestuples-in.html
