Last active
May 31, 2017 17:03
-
-
Save tternquist/3fcb8cc6c8bfc768f865366cf86f9444 to your computer and use it in GitHub Desktop.
Batch processing in marklogic with spawn function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
let $input := for $i in (1 to 100) return $i | |
let $batch-size := 2 | |
let $input-size := fn:count($input) | |
let $num-batches := xs:int(math:ceil($input-size div $batch-size )) | |
let $result := | |
for $batch-start in (1 to $num-batches) | |
let $processing-seq := $input[($batch-size * ($batch-start - 1) + 1) to ($batch-size * ($batch-start ))] | |
return | |
xdmp:spawn-function(function() { | |
fn:string-join($processing-seq ! fn:string(.),",") | |
}, | |
<options xmlns="xdmp:eval"> | |
<result>true</result> | |
<transaction-mode>update-auto-commit</transaction-mode> | |
</options>) | |
return ($result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment