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: Tree.hasChild() / Tree.getChild()
Date Tue, 01 Oct 2013 13:27:26 GMT


On 1.10.13 3:09 , Jukka Zitting wrote:
> The double-checking pattern is a leftover, but the hasChild() method
> as such still has a place. Depending on the backend, a getChild() call
> may require the identified node to be fetched from the disk or over
> the network (SegmentMK uses lazy loading to avoid this). So if we're
> only interested in the existence of a node (like in
> Session.nodeExists), hasChild() can in some cases be orders of
> magnitude faster than getChild().

But since we have that exists call, getChild() can return just a 
"thunk". The actual round-trip is deferred to later accesses of the 
returned child. And the hasNode() optimisation you mention would go into 
the exists() call.

I'm aware that things are currently not implemented that way and we even 
implement hasChild() through getChild().exists(). But maybe we should 
reconsider this!?

Michael

Mime
View raw message