Created
January 29, 2016 14:09
-
-
Save ableasdale/d9ef310864d7fb554178 to your computer and use it in GitHub Desktop.
MarkLogic: Aggregated Rebalancer Preview Fragment Counts
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
declare function local:update($map, $key, $num) { | |
let $key := fn:tokenize($key, "-")[3] | |
let $e := ( map:get($map, $key), 0) [1] | |
return map:put($map, $key, $e + $num) | |
}; | |
let $map:= map:map() | |
let $_ := | |
for $f in xdmp:document-get("/path/to/result.xml")/result/*:forest-counts | |
return ( | |
local:update($map, $f/*:forest-name/fn:string(.), fn:sum ($f//*:active-fragment-count)), | |
local:update($map, $f/*:forest-name/fn:string(.), - fn:sum ($f//*:rebalance-fragment-count/*:fragment-count)), | |
for $d in $f//*:rebalance-fragment-count[*:fragment-count != 0] | |
return local:update($map, $d/*:rebalance-destination/fn:string(.), fn:sum ($d/*:fragment-count)) | |
) | |
for $k in map:keys($map) | |
let $v := map:get($map, $k) | |
order by $v | |
return | |
($k ||":"|| $v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment