Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created September 12, 2018 12:14
Show Gist options
  • Save ableasdale/13ac416cfadc4acb904b9b53c63cf30f to your computer and use it in GitHub Desktop.
Save ableasdale/13ac416cfadc4acb904b9b53c63cf30f to your computer and use it in GitHub Desktop.
MarkLogic: Calculations for forest sizes (including forest reserve) by host from a support dump
xquery version "1.0-ml";
declare default element namespace "http://marklogic.com/xdmp/status/forest";
declare variable $path as xs:string := '/PATH/TO/support-request-go.xqy.txt';
declare variable $support as document-node()* := xdmp:document-get(
$path,
<options xmlns="xdmp:document-get">
<format>xml</format>
<repair>full</repair>
</options>
);
for $v in fn:distinct-values(fn:data($support/forest-status/host-id))
return (
element host {
element host-id {$v},
element journal-on-disk-size {
sum(for $forest in $support/forest-status
where $forest/host-id eq $v
return fn:data($forest/journals-size))},
element forest-on-disk-size {
sum(for $forest in $support/forest-status
where $forest/host-id eq $v
return fn:data($forest/stands/stand/disk-size))},
element total-forests {count(for $forest in $support/forest-status
where $forest/host-id eq $v return 1)},
element large-data-size {sum(for $forest in $support/forest-status
where $forest/host-id eq $v return $forest/large-data-size)},
element reserve {sum(for $forest in $support/forest-status
where $forest/host-id eq $v
return $forest/forest-reserve)}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment