jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: Contrasting performances of skip on node iterator
Date Thu, 02 Oct 2008 12:06:04 GMT
Hi,

On Thu, Oct 2, 2008 at 1:52 PM, Sridhar Raman <sridhar.raman@gmail.com> wrote:
> Here's another curious thing that I noticed.  In the first case, I was using
> node.getNodes() to get the iterator.  I tried node.getNodes("*"), and I
> notice that the skip method now is almost instantaneous.  Is this expected?

That's because getNodes("*") already traverses the list of all child
nodes before returning an iterator over the collection of all matching
nodes. The skip method is fast on the returned iterator just because
all the hard work has already been done.

The getNodes() method on the other hand tries to postpone the
expensive operations as long as possible, which is why it'll return
fast, but then the next() and skip() methods on the returned iterator
are more expensive.

BR,

Jukka Zitting

Mime
View raw message