Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created November 1, 2015 19:36
Show Gist options
  • Save ableasdale/8539247c7fb513a3fdac to your computer and use it in GitHub Desktop.
Save ableasdale/8539247c7fb513a3fdac to your computer and use it in GitHub Desktop.
Parse a support dump and generate a CSV for *some* values
xquery version "1.0-ml";
(text{"Forest Name,State,Rebalancer Enabled,Rebalancing,Stand Count,On Disk Size (MiB),In Mem Size (MiB)"},
for $i in doc()
where starts-with(xdmp:node-uri($i), "/MY_APP_FOREST_NAMES_HERE")
order by xdmp:node-uri($i)
return
text {string-join( (xs:string($i//*:forest-name), xs:string($i//*:state), xs:string($i//*:rebalancer-enable), xs:string($i//*:rebalancing), xs:string(fn:count($i//*:stands/*:stand)), xs:string(fn:sum( xs:integer($i//*:stands/*:stand/*:disk-size))), xs:string(fn:sum( xs:integer($i//*:stands/*:stand/*:memory-size))) ), ",")});
xquery version "1.0-ml";
for $i in xdmp:document-get("E:\supportdump.txt", <options xmlns="xdmp:document-get">
<format>xml</format>
<repair>full</repair>
</options>)/*:forest-status
return xdmp:document-insert(concat("/",$i/*:forest-name,".xml"), $i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment