You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Emmanuel Hugonnet <eh...@gmail.com> on 2008/07/17 16:44:51 UTC
Not referenced
Hi,
I would like to get all the nodes of a list that are NOT referenced.
Is there a way to do this with a XPath Query because it looks like
reference is a one way axis for xpath :( .
Thanks,
Emmanuel
Re: Not referenced
Posted by Emmanuel Hugonnet <eh...@gmail.com>.
Hi,
Thanks for your comments. I should have read the wiki more carefully ;o)
I thought that references allowed me to better express my relations (so
that users of my data structure knew what to put where).
As for your solution with soft references, I will consider it as it is
closer to what I want ;o).
I have not invested enought time in the event part of the JSR and
thought that references was the way ;o).
I'll look into it as soon as possible.
Thanks,
Emmanuel
Alexander Klimetschek a écrit :
> If you have lots of references in your system, maybe you could
> consider using "soft" references by storing the reference in a PATH
> property with simply the path to the property. Also have a look at the
> content modeling tips on the Jackrabbit wiki, which explains why
> references in JCR are not recommended:
> http://wiki.apache.org/jackrabbit/DavidsModel#head-ed794ec9f4f716b3e53548be6dd91b23e5dd3f3a
>
> You no longer have the getReferences() method available, but initially
> you could build a simple search a la
>
> //element(*, my:referencers)[@ref]
>
> Then iterate over the @ref properties using the getRows() iterator and
> do a query for each @ref and build a hash map of all documents that
> are referenced. Then you install an observation listener for all
> "my:referencers" nodes (that have references) and update the hash set
> when a new reference is added or removed. This way you have a quick
> lookup in your hash map for nodes that are referenced.
>
> Regards,
> Alex
>
> On Fri, Jul 18, 2008 at 7:46 AM, Emmanuel Hugonnet <eh...@gmail.com> wrote:
>
>> Alexander Klimetschek a écrit :
>>
>>> On Thu, Jul 17, 2008 at 4:44 PM, Emmanuel Hugonnet <eh...@gmail.com>
>>> wrote:
>>>
>>>
>>>> I would like to get all the nodes of a list that are NOT referenced.
>>>> Is there a way to do this with a XPath Query because it looks like
>>>> reference is a one way axis for xpath :( .
>>>>
>>>>
>>> I think it is not possible with a query. You can iterate over all the
>>> nodes you want to inspect, call getReferences() on it and hence find
>>> out, which ones are referenced by another node.
>>>
>>> Regards,
>>> Alex
>>>
>>>
>>>
>> Thanks,
>> That's what I was doing but with over 3000 nodes this is quite a bottleneck
>> for performance :-(
>> Maybe I should add an attribute for better filtering but I am moving from
>> the data to the logic :-(
>> Regards,
>> Emmanuel
>>
>>
>>
>
>
>
>
Re: Not referenced
Posted by Alexander Klimetschek <ak...@day.com>.
If you have lots of references in your system, maybe you could
consider using "soft" references by storing the reference in a PATH
property with simply the path to the property. Also have a look at the
content modeling tips on the Jackrabbit wiki, which explains why
references in JCR are not recommended:
http://wiki.apache.org/jackrabbit/DavidsModel#head-ed794ec9f4f716b3e53548be6dd91b23e5dd3f3a
You no longer have the getReferences() method available, but initially
you could build a simple search a la
//element(*, my:referencers)[@ref]
Then iterate over the @ref properties using the getRows() iterator and
do a query for each @ref and build a hash map of all documents that
are referenced. Then you install an observation listener for all
"my:referencers" nodes (that have references) and update the hash set
when a new reference is added or removed. This way you have a quick
lookup in your hash map for nodes that are referenced.
Regards,
Alex
On Fri, Jul 18, 2008 at 7:46 AM, Emmanuel Hugonnet <eh...@gmail.com> wrote:
> Alexander Klimetschek a écrit :
>>
>> On Thu, Jul 17, 2008 at 4:44 PM, Emmanuel Hugonnet <eh...@gmail.com>
>> wrote:
>>
>>>
>>> I would like to get all the nodes of a list that are NOT referenced.
>>> Is there a way to do this with a XPath Query because it looks like
>>> reference is a one way axis for xpath :( .
>>>
>>
>> I think it is not possible with a query. You can iterate over all the
>> nodes you want to inspect, call getReferences() on it and hence find
>> out, which ones are referenced by another node.
>>
>> Regards,
>> Alex
>>
>>
>
> Thanks,
> That's what I was doing but with over 3000 nodes this is quite a bottleneck
> for performance :-(
> Maybe I should add an attribute for better filtering but I am moving from
> the data to the logic :-(
> Regards,
> Emmanuel
>
>
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: Not referenced
Posted by Emmanuel Hugonnet <eh...@gmail.com>.
Alexander Klimetschek a écrit :
> On Thu, Jul 17, 2008 at 4:44 PM, Emmanuel Hugonnet <eh...@gmail.com> wrote:
>
>> I would like to get all the nodes of a list that are NOT referenced.
>> Is there a way to do this with a XPath Query because it looks like
>> reference is a one way axis for xpath :( .
>>
>
> I think it is not possible with a query. You can iterate over all the
> nodes you want to inspect, call getReferences() on it and hence find
> out, which ones are referenced by another node.
>
> Regards,
> Alex
>
>
Thanks,
That's what I was doing but with over 3000 nodes this is quite a
bottleneck for performance :-(
Maybe I should add an attribute for better filtering but I am moving
from the data to the logic :-(
Regards,
Emmanuel
Re: Not referenced
Posted by Alexander Klimetschek <ak...@day.com>.
On Thu, Jul 17, 2008 at 4:44 PM, Emmanuel Hugonnet <eh...@gmail.com> wrote:
> I would like to get all the nodes of a list that are NOT referenced.
> Is there a way to do this with a XPath Query because it looks like
> reference is a one way axis for xpath :( .
I think it is not possible with a query. You can iterate over all the
nodes you want to inspect, call getReferences() on it and hence find
out, which ones are referenced by another node.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com