On Fri, Jun 10, 2011 at 11:16 AM, alsor <alsor....@gmail.com> wrote:

> ... but what if this is exactly what I need?
>
> I'm working with Lucene and I have my custom Collector. This collector
> accept fn as a constructor argument and then for each matched document it
> gathers needed information from the fields of document, builds some useful
> clojure object and passes it back to fn.
>
> Here is the example, where the goal is just to collect all results into the
> vector, and I used transients here, which are updated in-place and I'm
> ignoring (conj! ..) returned value:
>
> (let [v (transient [])
>           f (fn [obj]
>               (conj! v obj))]
>       (.search searcher (MatchAllDocsQuery.) (MyCustomCollector. f))
>       (persistent! v))
>
> Looks nice to me. And it works. But then I noticed this statement on
> http://clojure.org/Transients page:
>
> "Note in particular that transients are not designed to be bashed
> in-place."
>
> Does it mean that some future version of Clojure may broke my code?


What performance benefit is there to using transients if you're only adding
one thing? Transients were designed for the rapid creation of large
collections.

David

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

Reply via email to