jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dürig <mdue...@apache.org>
Subject Re: ContentSession.getCurrentRoot() is slow
Date Thu, 13 Sep 2012 15:47:13 GMT


On 13.9.12 16:42, Thomas Mueller wrote:
> Hi,
>
> To read a node, the query engine currently uses:
>
>      session.getCurrentRoot().getTree(path);
>
> The query engine calls this whenever it has to evaluate a property. It
> turns out internally the getCurrentRoot() method always calls
> MicroKernel.getHeadRevision(). I wonder if this is required, and if yes,
> why? The javadoc for this method is:
>
>      /**
>       * The current root as seen by this content session. Use
>       * {@link Root#commit(ConflictHandler)} to atomically apply the
> changes made in that
>       * subtree the underlying Microkernel.
>       *
>       * @return  the current root
>       */
>
> Should I cache the Root instance in the query engine for the duration of a
> query? Or would it be possible to change the Root implementation so this
> is not needed?

The root instance gives you a stable view of the tree at the time you 
acquired the root. That's why acquiring a new root does a round trip to 
the Microkernel. However evaluating a query I think its not only better 
but also the correct thing to acquire the root once for the whole query 
evaluation.

Michael

>
> Regards,
> Thomas
>
>

Mime
View raw message