On Mar 8, 9:05 pm, "Stephen C. Gilardi" <squee...@mac.com> wrote:
> On Mar 8, 2009, at 1:53 PM, Rich Hickey wrote:
>
> > First up is contrib.sql, where insert-rows and insert-values both take
> > a vector of column names followed by vectors of unlabeled values that
> > must be in the same order as the corresponding columns. I would hope
> > never to have such fragile things as those vectors in my programs.
>
> For large data sets with a regular structure, insert-rows and insert-
> values use the jdbc interface very efficiently.

Do you have a case where the map-unpacking dominates the I/O time? Or
is this just a speculative optimization?

I want to be clear, just because things come in maps doesn't mean you
can't have a higher-performance insert-uniform-records that takes maps
with identical sets of keys.

> They are also
> convenient building blocks for other functions to use.
>

Hmm...

> > OTOH, the query and update APIs take and return maps.
>
> clojure.contrib.sql now includes:
>
> (defn insert-records
>    "Inserts records into a table. records are maps from strings or
>    keywords (identifying columns) to values."
>    [table & records]
>    (doseq [record records]
>      (insert-values table (keys record) (vals record))))
>
> Here's an example from clojure.contrib.sql.test:
>
> (defn insert-records-fruit
>    "Insert records, maps from keys specifying columns to values"
>    []
>    (sql/insert-records
>     :fruit
>     {:name "Pomegranate" :appearance "fresh" :cost 585}
>     {:name "Kiwifruit" :grade 93}))
>

Thanks!

Rich

--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to