On Apr 20, 2014, at 7:27 PM, Ragu Vijaykumar <[email protected]> wrote:

> I've been defining a bunch of MAPBLOCKs for my view and I was wondering 
> whether there was anyway of converting the (NSDictionary* doc) parameter to a 
> CBLModel inside my map function? Ideally, I'd want to convert the doc to a 
> CBLDocument* object, and then use the CBLModelFactory to create the right 
> type of CBLModel for me, or nil, and then I can check if the CBLModel is the 
> right kind of model I want (isKindOfClass). If so, I can then do my map 
> processing using the properties of the model.

I can see the appeal of this, as it makes your map functions look more like the 
rest of your code and lets you use the higher-level abstractions that the model 
provides. But I think it's too heavyweight. Map functions need to be fast or 
they'll become a bottleneck in view indexing. (I'm coincidentally doing some 
optimization work on indexing right now, so this is on my mind.)

Also, I think there's too much state involved in CBLDocument and CBLModel to be 
safe to use in a map function. The map function may be run on a background 
thread (if you use a live query), and in the future we may parallelize it so it 
runs on several threads at once, if the CPU has enough cores.

--Jens

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/41A9A204-8B85-449B-ADC7-CAE105C3DC80%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to