You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by hsp_ <pi...@ibest.com.br> on 2007/11/22 20:37:55 UTC
Checking if node exists
Is there a best way to check if exists a node in repository (by the path
and/or by the uuid).
I have a use case that now is trying to load the node, if it is not null
means it exists, otherwise.....
So, I guess that would have a better solution that doesn't need to load all
node, could you help me?
tks
Helio.
--
View this message in context: http://www.nabble.com/Checking-if-node-exists-tf4858118.html#a13902158
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: Checking if node exists
Posted by Jukka Zitting <ju...@gmail.com>.
Hi,
On Nov 22, 2007 10:21 PM, hsp_ <pi...@ibest.com.br> wrote:
> Which is faster Jukka?
The Session.itemExists() and Node.hasNode() calls are roughly
equivalent in performance. If you already have an ancestor node
reference, then using Node.hasNode() with the relative path is
probably a bit faster.
The main performance gain from itemExists() or hasNode() as compared
to methods like getNode(), is that they don't need to load the node
state of the referenced node, just the node states of all the ancestor
nodes which are typically already cached in memory.
BR,
Jukka Zitting
Re: Checking if node exists
Posted by hsp_ <pi...@ibest.com.br>.
Which is faster Jukka?
Tks in advanced
Helio
Jukka Zitting wrote:
>
> Hi,
>
> On Nov 22, 2007 9:37 PM, hsp_ <pi...@ibest.com.br> wrote:
>> Is there a best way to check if exists a node in repository (by the path
>> and/or by the uuid).
>
> Use session.itemExists("/absolute/path") or node.hasNode("relative/path").
>
> BR,
>
> Jukka Zitting
>
>
--
View this message in context: http://www.nabble.com/Checking-if-node-exists-tf4858118.html#a13902817
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: Checking if node exists
Posted by Jukka Zitting <ju...@gmail.com>.
Hi,
On Nov 23, 2007 12:45 PM, hsp_ <pi...@ibest.com.br> wrote:
> By the way, is there a way to get the path of a node by your uuid, without
> have to get the node and get the path?
No. To get the path of a node in Jackrabbit, the system needs to load
the node states of the node and all its ancestors. Lucklily most of
the ancestor nodes are typically already cached so you don't see the
full performance hit of loading all those nodes.
If you really need a fast (like an in-memory HashMap) uuid-to-path
lookup mechanism, I suggest you implement such a map on the
application level and keep it up to date using observation.
BR,
Jukka Zitting
Re: Checking if node exists
Posted by hsp_ <pi...@ibest.com.br>.
Tks Jukka;
By the way, is there a way to get the path of a node by your uuid, without
have to get the node and get the path? I have a use case where there is a
uuid and I need to charge the path, but I prefer just to get the path and
not load the node and get the path.
Tks in advanced.
Helio.
Jukka Zitting wrote:
>
> Hi,
>
> On Nov 22, 2007 9:37 PM, hsp_ <pi...@ibest.com.br> wrote:
>> Is there a best way to check if exists a node in repository (by the path
>> and/or by the uuid).
>
> Use session.itemExists("/absolute/path") or node.hasNode("relative/path").
>
> BR,
>
> Jukka Zitting
>
>
--
View this message in context: http://www.nabble.com/Checking-if-node-exists-tf4858118.html#a13910059
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: Checking if node exists
Posted by Jukka Zitting <ju...@gmail.com>.
Hi,
On Nov 22, 2007 9:37 PM, hsp_ <pi...@ibest.com.br> wrote:
> Is there a best way to check if exists a node in repository (by the path
> and/or by the uuid).
Use session.itemExists("/absolute/path") or node.hasNode("relative/path").
BR,
Jukka Zitting