BaseX 8.3.1, installed on Linux today from zip archive.
I have about 137,000 target elements, each having an average of 550 descendant elements, and each taking about 45k of space on disk. The target elements each have an @uuid value, and I'd like to extract each @uuid value and assign it a unique number from an incrementing sequence of integers. I'd like to be able to start the sequence at an arbitrary value.
I tried a recursive function I borrowed and modified from a StackOverflow post:
declare function local:loop($seq, $count) { if(empty($seq)) then () else let $prod := $seq[1], $count := $count + 1 return ( <result> <id>{$count}</id> <uuid>{data($prod)}</uuid> </result>, local:loop(tail($seq), $count) ) };
and calling it like so:
return <results>{ local:loop($pubs, 0) }</results>
where $prod is a sequence of all the @uuid attributes (not the values, and not the whole elements).
My query fails with the error: [bxerr:BASX0005] Stack Overflow: Try tail recursion?
I'm using -Xmx6g and -Xss4m as flags for Java in the basexgui script.
Is there some way to get BaseX to use tail recursion? Or is there another approach to doing what I want?
Many thanks, Chuck
Hi Chuck,
target elements each have an @uuid value, and I'd like to extract each @uuid value and assign it a unique number from an incrementing sequence of integers.
There has recently been a thread on generating consecutive ids, it should answer some of your questions [1].
I tried a recursive function I borrowed and modified from a StackOverflow post: [...] I'm using -Xmx6g and -Xss4m as flags for Java in the basexgui script.
Is there some way to get BaseX to use tail recursion?
Absolutely. You can rewrite function calls in recursive code to tail calls (but it’s hardly possible to do this automatically); see [2] for some examples.
Hope this helps, Christian
[1] https://www.mail-archive.com/basex-talk%40mailman.uni-konstanz.de/msg07120.h... [2] https://en.wikipedia.org/wiki/Tail_call
basex-talk@mailman.uni-konstanz.de