You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Alexandre Martins <al...@gmail.com> on 2007/03/30 14:10:58 UTC

Problems with NodeIterator - iter.next() is better than iter.nextNode()

Hi All,

The NodeIterator class has a method called nextNode(), using this is not
necessary do a cast. However, using the next method (normal from Iterator) ,
the results are so better (iteration time).

 (Node)iter.Next: 453 ms
 iter.NextNode(): 3552 ms

Somebody knows why?

BR,

-- 
Alexandre Costa Martins
CESAR - Recife Center for Advanced Studies and Systems
Software Engineer and Software Reuse Researcher
MSc Candidate at Federal University of Pernambuco
RiSE Member - http://www.rise.com.br

E-mail: alexandre.martins@cesar.org.br
MSN: xandecmartins@hotmail.com
GTalk: alexandremartins@gmail.com
Skype: xandecmartins
Mobile: +55 (81) 9929-9548
Office: +55 (81) 3425-4763
Fax: +55 (81) 3425-4701

Re: Problems with NodeIterator - iter.next() is better than iter.nextNode()

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 3/30/07, Alexandre Martins <al...@gmail.com> wrote:
> The NodeIterator class has a method called nextNode(), using this is not
> necessary do a cast. However, using the next method (normal from Iterator) ,
> the results are so better (iteration time).
>
>  (Node)iter.Next: 453 ms
>  iter.NextNode(): 3552 ms
>
> Somebody knows why?

Did you do something like this:

    Node parent = ...;
    NodeIterator a = parent.getNodes();
    while (a.hasNext()) { a.nextNode(); }
    NodeIterator b = parent.getNodes();
    while (b.hasNext()) { b.next(); }

In such a case the second run will definitely be much faster since all
the nodes are already cached.

BR,

Jukka Zitting

Re: Problems with NodeIterator - iter.next() is better than iter.nextNode()

Posted by Stefan Guggisberg <st...@gmail.com>.
hi alexandre,

On 3/30/07, Alexandre Martins <al...@gmail.com> wrote:
> Hi All,
>
> The NodeIterator class has a method called nextNode(), using this is not
> necessary do a cast. However, using the next method (normal from Iterator) ,
> the results are so better (iteration time).
>
>  (Node)iter.Next: 453 ms
>  iter.NextNode(): 3552 ms
>
> Somebody knows why?

no, and it's frankly hard to believe. both implementations should IMO be
identical, apart from the type cast of course.

where did you get the NodeIterator from?

cheers
stefan

>
> BR,
>
> --
> Alexandre Costa Martins
> CESAR - Recife Center for Advanced Studies and Systems
> Software Engineer and Software Reuse Researcher
> MSc Candidate at Federal University of Pernambuco
> RiSE Member - http://www.rise.com.br
>
> E-mail: alexandre.martins@cesar.org.br
> MSN: xandecmartins@hotmail.com
> GTalk: alexandremartins@gmail.com
> Skype: xandecmartins
> Mobile: +55 (81) 9929-9548
> Office: +55 (81) 3425-4763
> Fax: +55 (81) 3425-4701
>