On Thu, Jan 28, 2010 at 5:23 PM, Naftoli Gugenheim <[email protected]>wrote:

> Neat. So it's a flatMap?
>

No, it's not flatMap.  It has some of the characteristics of flatMap, but
the function returns a Box[T], not an Iterable[T]


> Should we replace the pattern used often in binding lists
> Author.findAll.flatMap { a => bind ... }
> with
> Author.findMap() { a => bind ... }
> when the list is large or its elements are big?
>

I don't think so.


>
>
> -------------------------------------
> David Pollak<[email protected]> wrote:
>
> def findMap[T](by: QueryParam[A]*)(f: A => Box[T])
>
> Your function, f, will be called as each row is pulled back from the
> database.  If your function returns Empty, the row will not be included in
> the final result.  You can also do fun stuff like:
>
> MyModel.findMap(){
>  row -> row.name.is match {
>    case x if x.length < 4 => Full(x)
>    case _ => Empty
>  }}
>
> This will return a List[String] for all the people with short names.  Your
> function is called as each row is processed, so the whole list is not
> loaded
> into memory.
>
> If you wanted to simulate a foreach here, you'd just return Empty from the
> function every time.
>
>
> On Wed, Jan 27, 2010 at 9:58 PM, Naftoli Gugenheim <[email protected]
> >wrote:
>
> > MetaMapper has a findAll method, which creates a statement based on its
> > parameters, and then iterates over the ResultSet creating Mappers and
> > putting them into a List.
> > It would be neat if it was possible to process the generated Mappers one
> by
> > one instead of loading them into a list. This way large ResultSets don't
> > need to result in a big List in memory.
> > Is such a thing possible today? If not, what would it take to implement?
> > One approach would be foreach/map/flatMap methods. Another would be a
> find
> > method that returns a lazy list or an Iterator.
> > Thanks.
> >
> >
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<liftweb%[email protected]>
> <liftweb%[email protected]<liftweb%[email protected]>
> >
> > .
> > For more options, visit this group at
> > http://groups.google.com/group/liftweb?hl=en.
> >
>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Surf the harmonics
>
> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<liftweb%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<liftweb%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.

Reply via email to