dbTalk Databases Forums  

Nested sets: given path, find node

comp.databases comp.databases


Discuss Nested sets: given path, find node in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Hamish
 
Posts: n/a

Default Nested sets: given path, find node - 04-21-2009 , 06:48 PM






Hi,

In the literature for nested sets, a commonly described operation is:
given a node, find the path from the root to this node. I wish to find
the most efficient way to do the inverse operation -- given a path,
find the node. Is there a more efficient way of doing this than the
naive approach of walking the path oneself (i.e. multiple queries to
the database)?

Thanks,
Hamish

Reply With Quote
  #2  
Old   
Lennart
 
Posts: n/a

Default Re: Nested sets: given path, find node - 04-22-2009 , 11:24 AM






On 22 Apr, 01:48, Hamish <ham... (AT) gmail (DOT) com> wrote:
Quote:
Hi,

In the literature for nested sets, a commonly described operation is:
given a node, find the path from the root to this node. I wish to find
the most efficient way to do the inverse operation -- given a path,
find the node. Is there a more efficient way of doing this than the
naive approach of walking the path oneself (i.e. multiple queries to
the database)?

I assume you are looking for a leaf node in a set of nodes? If the
tree is consistent it should be sufficient to find the node with min
(rgt) or max(lft) among those nodes.


/Lennart




Reply With Quote
  #3  
Old   
Walter Mitty
 
Posts: n/a

Default Re: Nested sets: given path, find node - 04-22-2009 , 02:02 PM




"Hamish" <hamish (AT) gmail (DOT) com> wrote

Quote:
Hi,

In the literature for nested sets, a commonly described operation is:
given a node, find the path from the root to this node. I wish to find
the most efficient way to do the inverse operation -- given a path,
find the node. Is there a more efficient way of doing this than the
naive approach of walking the path oneself (i.e. multiple queries to
the database)?

Thanks,
Hamish
If you build your nested sets in the traditional way, the criterion "where
rgt = lft +1" will select leaf nodes, and only leaf nodes.
If the path you have been given is a set of nodes with only one leaf, this
criterion will select it.





Reply With Quote
  #4  
Old   
Hamish
 
Posts: n/a

Default Re: Nested sets: given path, find node - 04-22-2009 , 05:10 PM



On Apr 22, 8:02*pm, "Walter Mitty" <wami... (AT) verizon (DOT) net> wrote:
Quote:
"Hamish" <ham... (AT) gmail (DOT) com> wrote in message

news:5da3650c-69b7-437d-8879-8f9632a79be8 (AT) l1g2000yqk (DOT) googlegroups.com...

Hi,

In the literature for nested sets, a commonly described operation is:
given a node, find the path from the root to this node. I wish to find
the most efficient way to do the inverse operation -- given a path,
find the node. Is there a more efficient way of doing this than the
naive approach of walking the path oneself (i.e. multiple queries to
the database)?

Thanks,
Hamish

If you build your nested sets in the traditional way, the criterion "where
rgt = lft +1" will select leaf nodes, and only leaf nodes.
If the path you have been given is a set of nodes with only one leaf, *this
criterion will select it.
Sorry, I didn't explain myself at all well. Let me try again.

Given a path of node labels, which may not be unique and which may not
end at a leaf node, what is the most efficient way of arriving at the
last node in the path?

E.g. the node for '/usr/local/bin' in a filesystem containing '/usr/
bin' and '/usr/local/bin/git'

(Also, I'm hoping to use Dan Hazel's rational numbers keying method
(http://arxiv.org/pdf/0806.3115v1), so I can't assume that leaves have
rgt=lft+1.)

Thanks,
Hamish


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.