Hi,

I have a large xml database around 2 GB. I have to group elements on the basis of some attribute. As i mention in my previous mail, I tried to created a new element and embedding the element as a child element. I am getting Out of Memory because of this. If i never create a new element just using that element it is not showing any Out of Memory Error. As per my understanding is it happenning because it is creating a totally new element in the main memory itself. Please help me out. Please go through the scenario.

Scenario :1

=== Without Any Out of Memory Error=====================

long t1=System.currentTimeMillis();
QueryProcessor pr = new QueryProcessor("let $a := //elements   return $c",context);
pr.context(itr);
Iter first=pr.iter();
System.out.println(System.currentTimeMillis() - t1);

long t2=System.currentTimeMillis();
QueryProcessor pr1 = new QueryProcessor("declare variable $elements external; let $a := $elements/* return $a",context);
pr1.bind("elements",first);
Iter second=pr1.iter();
System.out.println(System.currentTimeMillis() - t2);

Scenario : 2

=== With  Out of Memory Error=====================

long t1=System.currentTimeMillis();
QueryProcessor pr = new QueryProcessor("let $a := //elements   return <Nelement>$c</Nelement>",context); // Here i am creating new element
pr.context(itr);
Iter first=pr.iter();
System.out.println(System.currentTimeMillis() - t1);

long t2=System.currentTimeMillis();
QueryProcessor pr1 = new QueryProcessor("declare variable $elements external; let $a := $elements/* return $a",context);
pr1.context(first);
pr1.bind("elements",first);
Iter second=pr1.iter(); // Here Out of Memory Error Comes.
System.out.println(System.currentTimeMillis() - t2);
 



On 6 February 2015 at 00:01, Christian Grün <christian.gruen@gmail.com> wrote:
Hi Ankit,

> let $c := <product><abc>{$b}</abc><bcd>$b</bcd></product>
>
> My question is, Will $c hold all the xml data in main memory or  will it
> contains reference to $a , $b which points to the data in database ?.

The XQuery spec. doesn't actually allow us to point to the original
database node, because the embedded node has a different node id:

  <abc>{$b}</abc>/* is $b → false

However, the representation of the embedded node resembles the data
structure of the original node, so it will take much less memory than
an XML fragment that has completely been created in main memory.

Best,
Christian