MarkLogic 12 EA 1 Product Documentation
op:lock-for-update

op:lock-for-update(
   [$lockUriCol as item()?]
) as map:map

Summary

Gets an early lock on documents that will be updated later in the pipeline with an operation like remove() or write(). Documents are always locked, but for complex pipelines, it can be beneficial to lock the document early, so to minimize the potential for lock contention.

Parameters
$lockUriCol If this column is not specified then it assumes a column 'uri' is present. This can be a string of the uri column name or an op:col. Use op:view-col or op:schema-col if you need to identify columns in the two views that have the same column name.

Usage Notes

op:lock-for-update() needs to be run as an update transaction. Use 'declare option xdmp:update "true";' in the prolog, or use xdmp:invoke/xdmp:invoke-function with update="true".

See Also

Example

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";
declare option xdmp:update "true";

op:from-doc-descriptors(map:entry("uri", "/optic/update/write1.xml")=>map:with("doc", <doc>write1</doc>))
=>op:lock-for-update()
=>op:write()
=>op:result();
  

Example

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";
declare option xdmp:update "true";

op:from-doc-descriptors(map:entry("uri", "/optic/update/write1.xml")=>map:with("doc", <doc>write1</doc>))
=>op:lock-for-update("uri")
=>op:write()
=>op:result();
  

Example

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";
declare option xdmp:update "true";

op:from-doc-descriptors(map:entry("uri", "/optic/update/write.xml")=>map:with("doc", <doc>write1</doc>), "myQualifier")
=>op:lock-for-update(op:view-col("myQualifier","uri"))
=>op:write(op:doc-cols("myQualifier", ("uri", "doc")))
=>op:result();
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy