map:map is but one of a handful of programming techniques for MarkLogic. Like most techniques, its use should depend on careful thought and analysis. map:map is optimized to map strings to values, and is modifiable. The former provides a very efficient way of storing and retrieving values which is much faster than if stored in a XML node and accessed via xpath. It can also store values which are impossible to store in an XML node such as function objects. The later, however, does violate the functional aspect of XQuery in that it can make expressions order dependent so should be used with care.
Maps can be especially useful if stored as a server variable so that parsed values are extremely fast to lookup. On the other hand map:map holds onto memory as long as it is in scope which can have negative impacts depending on how much you have stored. Also consider that to populate a map you need to read in all the keys values and evaluate them. Sometimes this is reasonable, but it can also be abused by reading in too much data in hopes of gaining efficiency. ----------------------------------------------------------------------------- David Lee Lead Engineer MarkLogic Corporation [email protected] Phone: +1 812-482-5224 Cell: +1 812-630-7622 www.marklogic.com<http://www.marklogic.com/> From: [email protected] [mailto:[email protected]] On Behalf Of colin mcenearney Sent: Tuesday, November 13, 2012 5:44 PM To: [email protected] Subject: [MarkLogic Dev General] Why use maps in ML? Hi all, Why use the map:map structure in ML? Is it to make data available to entities that don't speak xquery? If performance, than why is a map faster than a simple xml doc which has been parsed into memory? <root> <map-like key="..." value="..." /> ... </root> Thanks, Colin
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
