Element constructors

Wednesday, 15 March 2017 · 5 messages · last reply 17 Mar 2017
J
Joseph15 Mar 2017 19:57 #
Hi, I have an xml file consisting (only) of many elements similar to this
<re>
 <de>something</de>
 <se>something</se>
 <id>something</id>
 <p>something</p>
 <s>something</s>
 <h>something</h>
 <b>something</b>
 <m>something</m>
</re>
and a simple query like this
let $t := doc("file.xml")
for $a in $t//re
let $b := $a/de
let $c := $a/se
return
(element r {attribute f {$b || "-" || $c},
<i>{$a/id/data(.)}</i>, <f>{$b/data(.)}</f>, <p>{$a/p/data(.)}</p>,
<l>{$c/data(.)}</l>, <s>{$a/s/data(.)}</s> ,<h>{$a/h/data(.)}</h>,
<b>{$a/b/data(.)}</b>, <m>{$a/m/data(.)}</m> })
I have noticed that while the preceding query works fine, if I substitute all the elements in it (e.g, <s>{$a/s/data(.)}</s>) with their contents ($a/s/) (i.e., I expect that the exact same element of the document is inserted), BaseX gets out of main memory. Any explanation? Thanks. Joseph
CG
Christian Grün15 Mar 2017 20:49 #
Quoted text · Joseph · 4 lines
> I have noticed that while the preceding query works fine, if I substitute > all the elements in it (e.g, <s>{$a/s/data(.)}</s>) with their contents > ($a/s/) (i.e., I expect that the exact same element of the document is > inserted), BaseX gets out of main memory. Any explanation? Thanks.
Some executable code would be helpful. Thanks, Christian
M
meumapple17 Mar 2017 16:05 #
Hi Christian, The code I sent is actually working code. The data however are many files. I do not know whether it depends on the amount of data (800 mb) or on the query itself. In general, I was wondering whether there may be a performance difference between using an explicit element constructor (e.g, <s>{$a/s/data(.)}</s>) and adding an element already contained in the document ($a/s, which evaluates to the same element as the above). Thanks.
Quoted text · Christian Grün · 6 lines
> Il giorno 15 mar 2017, alle ore 20:49, Christian Grün <christian.gruen at gmail.com> ha scritto: > > I have noticed that while the preceding query works fine, if I substitute > all the elements in it (e.g, <s>{$a/s/data(.)}</s>) with their contents > ($a/s/) (i.e., I expect that the exact same element of the document is > inserted), BaseX gets out of main memory. Any explanation? Thanks.
Some executable code would be helpful. Thanks, Christian
CG
Christian Grün17 Mar 2017 17:36 #
Quoted text · meumapple · 1 line
> I was wondering whether there may be a performance difference between using an explicit element constructor (e.g, <s>{$a/s/data(.)}</s>) and adding an element already contained in the document ($a/s, which evaluates to the same element as the above). Thanks.
In both cases, nodes will need to be duplicated (due to the memory consuming semantics of the XQuery specification), so there should be no big difference. As you have observed (if I got you right) that only one of your queries is getting out of memory, you may need to provide us with both queries. Are you working with the BaseX GUI, on command-line, or with any other API?
M
meumapple17 Mar 2017 23:45 #
BaseX GUI. I start with it all the times.
Quoted text · Christian Grün · 3 lines
> Il giorno 17 mar 2017, alle ore 17:36, Christian Grün <christian.gruen at gmail.com> ha scritto: > > I was wondering whether there may be a performance difference between using an explicit element constructor (e.g, <s>{$a/s/data(.)}</s>) and adding an element already contained in the document ($a/s, which evaluates to the same element as the above). Thanks.
In both cases, nodes will need to be duplicated (due to the memory consuming semantics of the XQuery specification), so there should be no big difference. As you have observed (if I got you right) that only one of your queries is getting out of memory, you may need to provide us with both queries. Are you working with the BaseX GUI, on command-line, or with any other API?

⚡Generated with XQuery