Virtual persistent data structures are very easy to use, as all the 
database stuff is pretty much transparent to the application developer. You 
can query and update them the same way you query and update any Clojure 
persistent data structure.

First, you do need to open and close the database:

(let [opts (yearling-open (File. "my-database"))]
  .
  .
  .
  (db-close opts)

Between the open and the close, you can do queries and updates, like this:

  (println (db-get-sorted-map opts)); -> {}
  (db-update (fn [aamap opts]
               (-> 
                 (assoc :me "Hello world!")
                 (assoc :v (reduce conj [] (range 3))))
             opts)
  (println (db-get-sorted-map opts)); -> {:me Hello world!, :v 0 1 2}

Note that [1 2 3] is an ordinary Clojure vector.

Now lets make things complicated. Lets say you want to add a vector that 
has a million entries. You will want to use a virtual vector instead of a 
regular vector, just because it is so big. This is how you could do it:

  (db-update (fn [aamap opts]
               (assoc aamap :big-v (reduce conj (new-vector opts) (range 
1000000)))
             opts)

>From https://github.com/laforge49/aatree#readme

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to