Hello Ankit,

as Christian and yourself said, the element is created in main memory and this 
is required by the specification.

So if you hold 2 GB data in main memory, you will need sufficient memory to 
hold this data. Is there any problem or limit you encounter when increasing the 
memory for BaseX (using -Xmx)?

Cheers,
Dirk

On 02/06/2015 10:29 AM, ankit kumar wrote:
> 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 <[email protected]>
> 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
> >
>

-- 
Dirk Kirsten, BaseX GmbH, http://basexgmbh.de
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
`-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22

Reply via email to