Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Pere Urbon Bayes
After a fast walk throw the code I found that option quite interesting and
probably the best fit till now for that problem! I hope I will be able to
provide a useful solution for those with the same problem than me...

I just tried you say I was expecting neo4j to provide me with something like
a sort command, I really realise is something not common in the graphdb
world, but something cool that can help a lot of people.

- purbon


On 15 July 2011 20:50, David Montag  wrote:

> Marko,
>
> Isn't that pretty similar to what
> https://github.com/peterneubauer/graph-collections<
> https://github.com/peterneubauer/graph-collections/tree/master/src/main/java/org/neo4j/collections/sortedtree
> >
> provides
> for Neo4j?
>
> David
>
> On Fri, Jul 15, 2011 at 11:30 AM, Marko Rodriguez  >wrote:
>
> > Hi,
> >
> > Pere, my last thought on this is that you might want to use something
> like
> > JDBM2.
> >
> >http://code.google.com/p/jdbm2/
> >
> > It has a Maven2  if you do it that way.
> >
> > JDBM2 provides you some Java collection implementations that are
> persistent
> > to disk...
> >
> > See ya,
> > Marko.
> >
> > http://markorodriguez.com
> >
> > On Jul 15, 2011, at 12:22 PM, Pere Urbon Bayes wrote:
> >
> > > Yeah! well to order in memory I can really deal with that task, for
> this
> > I
> > > really don't need cypher. Don´t take it personally, I know you really
> > want
> > > to promote your language, xD!
> > >
> > > - purbon
> > >
> > > PD: See you next graphdb meetup in Berlin!
> > >
> > > On 15 July 2011 19:37, Michael Hunger <
> michael.hun...@neotechnology.com
> > >wrote:
> > >
> > >> You might also try to use cypher for your traversal which is able to
> > order
> > >> (also in memory of course).
> > >>
> > >> See the screencast I did:
> > >> http://neo4j.vidcaster.com/U2Y/introduction-to-cypher/
> > >>
> > >> It's even the same domain.
> > >>
> > >> Cheers
> > >>
> > >> Michael
> > >>
> > >> Am 15.07.2011 um 17:24 schrieb Rick Bullotta:
> > >>
> > >>> But you couldn't easy do a complex traversal with an RDBMS. ;-)
> > >>>
> > >>> I suspect that even if you could write some magic SQL to do so, you'd
> > >> almost certainly lose the benefits any optimized sorting/ordering that
> > >> indices provide, so even the RDBMS would have to post-process the
> sort.
> > >>>
> > >>> If the traversal isn't complex or randomly "deep", then Neo indexing
> +
> > >> querying might work for you the same way an RDBMS might handle it.
> > >>>
> > >>>
> > >>> -Original Message-
> > >>> From: user-boun...@lists.neo4j.org [mailto:
> > user-boun...@lists.neo4j.org]
> > >> On Behalf Of Pere Urbon Bayes
> > >>> Sent: Friday, July 15, 2011 11:21 AM
> > >>> To: Neo4j user discussions
> > >>> Subject: Re: [Neo4j] Getting sorted results from a traversal
> > >>>
> > >>> Well, the thing is that the database can easy deal with that, as the
> > >>> relational system do.
> > >>>
> > >>> / purbon
> > >>>
> > >>> On 15 July 2011 17:08, Rick Bullotta 
> > >> wrote:
> > >>>
> > >>>> The DB would do it in memory too, wouldn't it?  In the case of a
> > complex
> > >>>> traversal, indexes don't really apply, since the ordering and the
> > >> traversal
> > >>>> order are unrelated, so you'd generally need to sort in memory
> anyway.
> > >>>> Whether you do it as you add elements to the traversed list of
> "stuff"
> > >> or
> > >>>> do it after the fact is another discussion, but I think in either
> > case,
> > >> it
> > >>>> needs to be done "after the fact".
> > >>>>
> > >>>>
> > >>>> -Original Message-
> > >>>> From: user-boun...@lists.neo4j.org [mailto:
> > user-boun...@lists.neo4j.org
> > >> ]
> > >>>> On Behalf Of Pere Urbon Bayes
> > >>>> Sent: Friday, July 15, 2011 11:05 AM
> > >>>> To: Neo4j user discussions
> > &

Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Pere Urbon Bayes
Jajajaja, Marko I just need to meet you sometime! I always listen good thing
about you from Peter and Achim ... I am quite not satisfied, probably I will
change somethings on my project in order to fit better with that use case!

- purbon


On 15 July 2011 20:53, Marko Rodriguez  wrote:

> Hey,
>
> > Isn't that pretty similar to what
> > https://github.com/peterneubauer/graph-collections<
> https://github.com/peterneubauer/graph-collections/tree/master/src/main/java/org/neo4j/collections/sortedtree
> >
> > provides
> > for Neo4j?
>
> I dunno. I haven't played with Graph Collections. But I assume so if it
> implements Java Collections interfaces ? The reason I brought up JDBM2 is
> because Pere still didn't seem satisfied after Niels recommendation of using
> graph-collections (that was the first email response to Pere).
>
> Just throwing stuff out there -- must...make..Pere...happy...
>
> Marko.
> http://markorodriguez.com
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Pere Urbon-Bayes
moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Michael Hunger
With our jruby script extension you can write server-side code in ruby that can 
do that for you.

Cheers

Michael

Am 15.07.2011 um 20:22 schrieb Pere Urbon Bayes:

> Yeah! well to order in memory I can really deal with that task, for this I
> really don't need cypher. Don´t take it personally, I know you really want
> to promote your language, xD!
> 
> - purbon
> 
> PD: See you next graphdb meetup in Berlin!
> 
> On 15 July 2011 19:37, Michael Hunger wrote:
> 
>> You might also try to use cypher for your traversal which is able to order
>> (also in memory of course).
>> 
>> See the screencast I did:
>> http://neo4j.vidcaster.com/U2Y/introduction-to-cypher/
>> 
>> It's even the same domain.
>> 
>> Cheers
>> 
>> Michael
>> 
>> Am 15.07.2011 um 17:24 schrieb Rick Bullotta:
>> 
>>> But you couldn't easy do a complex traversal with an RDBMS. ;-)
>>> 
>>> I suspect that even if you could write some magic SQL to do so, you'd
>> almost certainly lose the benefits any optimized sorting/ordering that
>> indices provide, so even the RDBMS would have to post-process the sort.
>>> 
>>> If the traversal isn't complex or randomly "deep", then Neo indexing +
>> querying might work for you the same way an RDBMS might handle it.
>>> 
>>> 
>>> -----Original Message-----
>>> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
>> On Behalf Of Pere Urbon Bayes
>>> Sent: Friday, July 15, 2011 11:21 AM
>>> To: Neo4j user discussions
>>> Subject: Re: [Neo4j] Getting sorted results from a traversal
>>> 
>>> Well, the thing is that the database can easy deal with that, as the
>>> relational system do.
>>> 
>>> / purbon
>>> 
>>> On 15 July 2011 17:08, Rick Bullotta 
>> wrote:
>>> 
>>>> The DB would do it in memory too, wouldn't it?  In the case of a complex
>>>> traversal, indexes don't really apply, since the ordering and the
>> traversal
>>>> order are unrelated, so you'd generally need to sort in memory anyway.
>>>> Whether you do it as you add elements to the traversed list of "stuff"
>> or
>>>> do it after the fact is another discussion, but I think in either case,
>> it
>>>> needs to be done "after the fact".
>>>> 
>>>> 
>>>> -Original Message-
>>>> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org
>> ]
>>>> On Behalf Of Pere Urbon Bayes
>>>> Sent: Friday, July 15, 2011 11:05 AM
>>>> To: Neo4j user discussions
>>>> Subject: Re: [Neo4j] Getting sorted results from a traversal
>>>> 
>>>> Well, this is great if I want to do all the math in memory, but I expect
>> to
>>>> do the computation by the db.
>>>> 
>>>> / purbon
>>>> 
>>>> On 15 July 2011 16:10, Marko Rodriguez  wrote:
>>>> 
>>>>> Hi Pere,
>>>>> 
>>>>> To sort you need to have all your results.
>>>>> 
>>>>> Thus, in Gremlin (and hopefully you can do the mapping to the core
>> Neo4j
>>>>> traverser framework),
>>>>> 
>>>>> results = []
>>>>> g.v(1).out('friend').out('likes') >> results // what my friends like
>>>>> results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
>>>> name
>>>>> 
>>>>> In short, once you have the result of your traversal, you can then
>> apply
>>>> a
>>>>> comparator to the Collection to sort it as you please --- its just Java
>>>>> comparators.
>>>>> 
>>>>> See ya,
>>>>> Marko.
>>>>> 
>>>>> http://markorodriguez.com
>>>>> 
>>>>> On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
>>>>> 
>>>>>> HI!
>>>>>> I am on the situation of having to traverse neo4j, and then expect the
>>>>>> resultset returned to be ordered in a certain order. I've been
>>>>> researching a
>>>>>> bit over the traversal API, but I did not find anything related to
>>>> that.
>>>>> I
>>>>>> really will appreciate any tip on that!!
>>>>>> 
>>>>>> BTW > I expect t

Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Marko Rodriguez
Hey,

> Isn't that pretty similar to what
> https://github.com/peterneubauer/graph-collections
> provides
> for Neo4j?

I dunno. I haven't played with Graph Collections. But I assume so if it 
implements Java Collections interfaces ? The reason I brought up JDBM2 is 
because Pere still didn't seem satisfied after Niels recommendation of using 
graph-collections (that was the first email response to Pere).

Just throwing stuff out there -- must...make..Pere...happy...

Marko.
http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread David Montag
Marko,

Isn't that pretty similar to what
https://github.com/peterneubauer/graph-collections<https://github.com/peterneubauer/graph-collections/tree/master/src/main/java/org/neo4j/collections/sortedtree>
provides
for Neo4j?

David

On Fri, Jul 15, 2011 at 11:30 AM, Marko Rodriguez wrote:

> Hi,
>
> Pere, my last thought on this is that you might want to use something like
> JDBM2.
>
>http://code.google.com/p/jdbm2/
>
> It has a Maven2  if you do it that way.
>
> JDBM2 provides you some Java collection implementations that are persistent
> to disk...
>
> See ya,
> Marko.
>
> http://markorodriguez.com
>
> On Jul 15, 2011, at 12:22 PM, Pere Urbon Bayes wrote:
>
> > Yeah! well to order in memory I can really deal with that task, for this
> I
> > really don't need cypher. Don´t take it personally, I know you really
> want
> > to promote your language, xD!
> >
> > - purbon
> >
> > PD: See you next graphdb meetup in Berlin!
> >
> > On 15 July 2011 19:37, Michael Hunger  >wrote:
> >
> >> You might also try to use cypher for your traversal which is able to
> order
> >> (also in memory of course).
> >>
> >> See the screencast I did:
> >> http://neo4j.vidcaster.com/U2Y/introduction-to-cypher/
> >>
> >> It's even the same domain.
> >>
> >> Cheers
> >>
> >> Michael
> >>
> >> Am 15.07.2011 um 17:24 schrieb Rick Bullotta:
> >>
> >>> But you couldn't easy do a complex traversal with an RDBMS. ;-)
> >>>
> >>> I suspect that even if you could write some magic SQL to do so, you'd
> >> almost certainly lose the benefits any optimized sorting/ordering that
> >> indices provide, so even the RDBMS would have to post-process the sort.
> >>>
> >>> If the traversal isn't complex or randomly "deep", then Neo indexing +
> >> querying might work for you the same way an RDBMS might handle it.
> >>>
> >>>
> >>> -Original Message-
> >>> From: user-boun...@lists.neo4j.org [mailto:
> user-boun...@lists.neo4j.org]
> >> On Behalf Of Pere Urbon Bayes
> >>> Sent: Friday, July 15, 2011 11:21 AM
> >>> To: Neo4j user discussions
> >>> Subject: Re: [Neo4j] Getting sorted results from a traversal
> >>>
> >>> Well, the thing is that the database can easy deal with that, as the
> >>> relational system do.
> >>>
> >>> / purbon
> >>>
> >>> On 15 July 2011 17:08, Rick Bullotta 
> >> wrote:
> >>>
> >>>> The DB would do it in memory too, wouldn't it?  In the case of a
> complex
> >>>> traversal, indexes don't really apply, since the ordering and the
> >> traversal
> >>>> order are unrelated, so you'd generally need to sort in memory anyway.
> >>>> Whether you do it as you add elements to the traversed list of "stuff"
> >> or
> >>>> do it after the fact is another discussion, but I think in either
> case,
> >> it
> >>>> needs to be done "after the fact".
> >>>>
> >>>>
> >>>> -Original Message-
> >>>> From: user-boun...@lists.neo4j.org [mailto:
> user-boun...@lists.neo4j.org
> >> ]
> >>>> On Behalf Of Pere Urbon Bayes
> >>>> Sent: Friday, July 15, 2011 11:05 AM
> >>>> To: Neo4j user discussions
> >>>> Subject: Re: [Neo4j] Getting sorted results from a traversal
> >>>>
> >>>> Well, this is great if I want to do all the math in memory, but I
> expect
> >> to
> >>>> do the computation by the db.
> >>>>
> >>>> / purbon
> >>>>
> >>>> On 15 July 2011 16:10, Marko Rodriguez  wrote:
> >>>>
> >>>>> Hi Pere,
> >>>>>
> >>>>> To sort you need to have all your results.
> >>>>>
> >>>>> Thus, in Gremlin (and hopefully you can do the mapping to the core
> >> Neo4j
> >>>>> traverser framework),
> >>>>>
> >>>>> results = []
> >>>>> g.v(1).out('friend').out('likes') >> results // what my friends like
> >>>>> results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
> >>>> name
> >>>>>
> >

Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Marko Rodriguez
Hey,

Actually, I was just Googling and found this cool library:
http://code.google.com/p/pcollections/

This way you have Set, Vector, etc. persisted. Perhaps that could help you out 
Pere.

See ya,
Marko.

http://markorodriguez.com

On Jul 15, 2011, at 12:30 PM, Marko Rodriguez wrote:

> Hi,
> 
> Pere, my last thought on this is that you might want to use something like 
> JDBM2.
> 
>   http://code.google.com/p/jdbm2/
> 
> It has a Maven2  if you do it that way.
> 
> JDBM2 provides you some Java collection implementations that are persistent 
> to disk...
> 
> See ya,
> Marko.
> 
> http://markorodriguez.com
> 
> On Jul 15, 2011, at 12:22 PM, Pere Urbon Bayes wrote:
> 
>> Yeah! well to order in memory I can really deal with that task, for this I
>> really don't need cypher. Don´t take it personally, I know you really want
>> to promote your language, xD!
>> 
>> - purbon
>> 
>> PD: See you next graphdb meetup in Berlin!
>> 
>> On 15 July 2011 19:37, Michael Hunger 
>> wrote:
>> 
>>> You might also try to use cypher for your traversal which is able to order
>>> (also in memory of course).
>>> 
>>> See the screencast I did:
>>> http://neo4j.vidcaster.com/U2Y/introduction-to-cypher/
>>> 
>>> It's even the same domain.
>>> 
>>> Cheers
>>> 
>>> Michael
>>> 
>>> Am 15.07.2011 um 17:24 schrieb Rick Bullotta:
>>> 
>>>> But you couldn't easy do a complex traversal with an RDBMS. ;-)
>>>> 
>>>> I suspect that even if you could write some magic SQL to do so, you'd
>>> almost certainly lose the benefits any optimized sorting/ordering that
>>> indices provide, so even the RDBMS would have to post-process the sort.
>>>> 
>>>> If the traversal isn't complex or randomly "deep", then Neo indexing +
>>> querying might work for you the same way an RDBMS might handle it.
>>>> 
>>>> 
>>>> -Original Message-
>>>> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
>>> On Behalf Of Pere Urbon Bayes
>>>> Sent: Friday, July 15, 2011 11:21 AM
>>>> To: Neo4j user discussions
>>>> Subject: Re: [Neo4j] Getting sorted results from a traversal
>>>> 
>>>> Well, the thing is that the database can easy deal with that, as the
>>>> relational system do.
>>>> 
>>>> / purbon
>>>> 
>>>> On 15 July 2011 17:08, Rick Bullotta 
>>> wrote:
>>>> 
>>>>> The DB would do it in memory too, wouldn't it?  In the case of a complex
>>>>> traversal, indexes don't really apply, since the ordering and the
>>> traversal
>>>>> order are unrelated, so you'd generally need to sort in memory anyway.
>>>>> Whether you do it as you add elements to the traversed list of "stuff"
>>> or
>>>>> do it after the fact is another discussion, but I think in either case,
>>> it
>>>>> needs to be done "after the fact".
>>>>> 
>>>>> 
>>>>> -Original Message-
>>>>> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org
>>> ]
>>>>> On Behalf Of Pere Urbon Bayes
>>>>> Sent: Friday, July 15, 2011 11:05 AM
>>>>> To: Neo4j user discussions
>>>>> Subject: Re: [Neo4j] Getting sorted results from a traversal
>>>>> 
>>>>> Well, this is great if I want to do all the math in memory, but I expect
>>> to
>>>>> do the computation by the db.
>>>>> 
>>>>> / purbon
>>>>> 
>>>>> On 15 July 2011 16:10, Marko Rodriguez  wrote:
>>>>> 
>>>>>> Hi Pere,
>>>>>> 
>>>>>> To sort you need to have all your results.
>>>>>> 
>>>>>> Thus, in Gremlin (and hopefully you can do the mapping to the core
>>> Neo4j
>>>>>> traverser framework),
>>>>>> 
>>>>>> results = []
>>>>>> g.v(1).out('friend').out('likes') >> results // what my friends like
>>>>>> results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
>>>>> name
>>>>>> 
>>>>>> In short, once you have the result of your traversal, you can then
>>

Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Marko Rodriguez
Hi,

Pere, my last thought on this is that you might want to use something like 
JDBM2.

http://code.google.com/p/jdbm2/

It has a Maven2  if you do it that way.

JDBM2 provides you some Java collection implementations that are persistent to 
disk...

See ya,
Marko.

http://markorodriguez.com

On Jul 15, 2011, at 12:22 PM, Pere Urbon Bayes wrote:

> Yeah! well to order in memory I can really deal with that task, for this I
> really don't need cypher. Don´t take it personally, I know you really want
> to promote your language, xD!
> 
> - purbon
> 
> PD: See you next graphdb meetup in Berlin!
> 
> On 15 July 2011 19:37, Michael Hunger wrote:
> 
>> You might also try to use cypher for your traversal which is able to order
>> (also in memory of course).
>> 
>> See the screencast I did:
>> http://neo4j.vidcaster.com/U2Y/introduction-to-cypher/
>> 
>> It's even the same domain.
>> 
>> Cheers
>> 
>> Michael
>> 
>> Am 15.07.2011 um 17:24 schrieb Rick Bullotta:
>> 
>>> But you couldn't easy do a complex traversal with an RDBMS. ;-)
>>> 
>>> I suspect that even if you could write some magic SQL to do so, you'd
>> almost certainly lose the benefits any optimized sorting/ordering that
>> indices provide, so even the RDBMS would have to post-process the sort.
>>> 
>>> If the traversal isn't complex or randomly "deep", then Neo indexing +
>> querying might work for you the same way an RDBMS might handle it.
>>> 
>>> 
>>> -----Original Message-----
>>> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
>> On Behalf Of Pere Urbon Bayes
>>> Sent: Friday, July 15, 2011 11:21 AM
>>> To: Neo4j user discussions
>>> Subject: Re: [Neo4j] Getting sorted results from a traversal
>>> 
>>> Well, the thing is that the database can easy deal with that, as the
>>> relational system do.
>>> 
>>> / purbon
>>> 
>>> On 15 July 2011 17:08, Rick Bullotta 
>> wrote:
>>> 
>>>> The DB would do it in memory too, wouldn't it?  In the case of a complex
>>>> traversal, indexes don't really apply, since the ordering and the
>> traversal
>>>> order are unrelated, so you'd generally need to sort in memory anyway.
>>>> Whether you do it as you add elements to the traversed list of "stuff"
>> or
>>>> do it after the fact is another discussion, but I think in either case,
>> it
>>>> needs to be done "after the fact".
>>>> 
>>>> 
>>>> -Original Message-
>>>> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org
>> ]
>>>> On Behalf Of Pere Urbon Bayes
>>>> Sent: Friday, July 15, 2011 11:05 AM
>>>> To: Neo4j user discussions
>>>> Subject: Re: [Neo4j] Getting sorted results from a traversal
>>>> 
>>>> Well, this is great if I want to do all the math in memory, but I expect
>> to
>>>> do the computation by the db.
>>>> 
>>>> / purbon
>>>> 
>>>> On 15 July 2011 16:10, Marko Rodriguez  wrote:
>>>> 
>>>>> Hi Pere,
>>>>> 
>>>>> To sort you need to have all your results.
>>>>> 
>>>>> Thus, in Gremlin (and hopefully you can do the mapping to the core
>> Neo4j
>>>>> traverser framework),
>>>>> 
>>>>> results = []
>>>>> g.v(1).out('friend').out('likes') >> results // what my friends like
>>>>> results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
>>>> name
>>>>> 
>>>>> In short, once you have the result of your traversal, you can then
>> apply
>>>> a
>>>>> comparator to the Collection to sort it as you please --- its just Java
>>>>> comparators.
>>>>> 
>>>>> See ya,
>>>>> Marko.
>>>>> 
>>>>> http://markorodriguez.com
>>>>> 
>>>>> On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
>>>>> 
>>>>>> HI!
>>>>>> I am on the situation of having to traverse neo4j, and then expect the
>>>>>> resultset returned to be ordered in a certain order. I've been
>>>>> researching a
>>>>>> bit over the traversal API, but I did not find anything related to

Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Pere Urbon Bayes
Hi Rick,

On 15 July 2011 17:24, Rick Bullotta  wrote:

> But you couldn't easy do a complex traversal with an RDBMS. ;-)
>

Yeah, so you are on me, from neo4j I could only expect to deal really good
with traversals, when you need some simple thing like ordering nodes, you
can not do it easily.


> I suspect that even if you could write some magic SQL to do so, you'd
> almost certainly lose the benefits any optimized sorting/ordering that
> indices provide, so even the RDBMS would have to post-process the sort.
>

Well, there are two tasks involved on that,

1.- Do the traversals? ( Where neo4j simple rocks!)
2.- The post ordering? ( Where I will need something else)

The thing is that with the second one I would expect something like this

Traversal -> Set of Nodes -> Order -> Set of Nodes ordered

In this use case I really would like to have this feature as traversals
expect to return always some kind of node set. On the oder side there are
the graph maching, where you expect a full graph. Also will be interesting
when dealing with edges, there we could also have something like an ordered
tree
https://github.com/peterneubauer/graph-collections/tree/master/src/main/java/org/neo4j/collections/sortedtree


> If the traversal isn't complex or randomly "deep", then Neo indexing +
> querying might work for you the same way an RDBMS might handle it.
>

Well, If I was able to ask the internal lucene to order the resultset from
the traversal then will be find. But please teach me how you will do it,
oder wise for me its just a use case neo4j can not provide me.

- purbon

-Original Message-
> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
> On Behalf Of Pere Urbon Bayes
> Sent: Friday, July 15, 2011 11:21 AM
> To: Neo4j user discussions
> Subject: Re: [Neo4j] Getting sorted results from a traversal
>
> Well, the thing is that the database can easy deal with that, as the
> relational system do.
>
> / purbon
>
> On 15 July 2011 17:08, Rick Bullotta  wrote:
>
> > The DB would do it in memory too, wouldn't it?  In the case of a complex
> > traversal, indexes don't really apply, since the ordering and the
> traversal
> > order are unrelated, so you'd generally need to sort in memory anyway.
> >  Whether you do it as you add elements to the traversed list of "stuff"
> or
> > do it after the fact is another discussion, but I think in either case,
> it
> > needs to be done "after the fact".
> >
> >
> > -Original Message-
> > From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
> > On Behalf Of Pere Urbon Bayes
> > Sent: Friday, July 15, 2011 11:05 AM
> > To: Neo4j user discussions
> > Subject: Re: [Neo4j] Getting sorted results from a traversal
> >
> > Well, this is great if I want to do all the math in memory, but I expect
> to
> > do the computation by the db.
> >
> > / purbon
> >
> > On 15 July 2011 16:10, Marko Rodriguez  wrote:
> >
> > > Hi Pere,
> > >
> > > To sort you need to have all your results.
> > >
> > > Thus, in Gremlin (and hopefully you can do the mapping to the core
> Neo4j
> > > traverser framework),
> > >
> > > results = []
> > > g.v(1).out('friend').out('likes') >> results // what my friends like
> > > results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
> > name
> > >
> > > In short, once you have the result of your traversal, you can then
> apply
> > a
> > > comparator to the Collection to sort it as you please --- its just Java
> > > comparators.
> > >
> > > See ya,
> > > Marko.
> > >
> > > http://markorodriguez.com
> > >
> > > On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
> > >
> > > > HI!
> > > > I am on the situation of having to traverse neo4j, and then expect
> the
> > > > resultset returned to be ordered in a certain order. I've been
> > > researching a
> > > > bit over the traversal API, but I did not find anything related to
> > that.
> > > I
> > > > really will appreciate any tip on that!!
> > > >
> > > > BTW > I expect to be possible right?, as we have in relational the
> > > ordering,
> > > > or on redis, etc...
> > > >
> > > > /purbon
> > > >
> > > > --
> > > > Pere Urbon-Bayes
> > > > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > > > Telefon

Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Pere Urbon Bayes
Yeah! well to order in memory I can really deal with that task, for this I
really don't need cypher. Don´t take it personally, I know you really want
to promote your language, xD!

- purbon

PD: See you next graphdb meetup in Berlin!

On 15 July 2011 19:37, Michael Hunger wrote:

> You might also try to use cypher for your traversal which is able to order
> (also in memory of course).
>
> See the screencast I did:
> http://neo4j.vidcaster.com/U2Y/introduction-to-cypher/
>
> It's even the same domain.
>
> Cheers
>
> Michael
>
> Am 15.07.2011 um 17:24 schrieb Rick Bullotta:
>
> > But you couldn't easy do a complex traversal with an RDBMS. ;-)
> >
> > I suspect that even if you could write some magic SQL to do so, you'd
> almost certainly lose the benefits any optimized sorting/ordering that
> indices provide, so even the RDBMS would have to post-process the sort.
> >
> > If the traversal isn't complex or randomly "deep", then Neo indexing +
> querying might work for you the same way an RDBMS might handle it.
> >
> >
> > -Original Message-
> > From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
> On Behalf Of Pere Urbon Bayes
> > Sent: Friday, July 15, 2011 11:21 AM
> > To: Neo4j user discussions
> > Subject: Re: [Neo4j] Getting sorted results from a traversal
> >
> > Well, the thing is that the database can easy deal with that, as the
> > relational system do.
> >
> > / purbon
> >
> > On 15 July 2011 17:08, Rick Bullotta 
> wrote:
> >
> >> The DB would do it in memory too, wouldn't it?  In the case of a complex
> >> traversal, indexes don't really apply, since the ordering and the
> traversal
> >> order are unrelated, so you'd generally need to sort in memory anyway.
> >> Whether you do it as you add elements to the traversed list of "stuff"
> or
> >> do it after the fact is another discussion, but I think in either case,
> it
> >> needs to be done "after the fact".
> >>
> >>
> >> -Original Message-
> >> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org
> ]
> >> On Behalf Of Pere Urbon Bayes
> >> Sent: Friday, July 15, 2011 11:05 AM
> >> To: Neo4j user discussions
> >> Subject: Re: [Neo4j] Getting sorted results from a traversal
> >>
> >> Well, this is great if I want to do all the math in memory, but I expect
> to
> >> do the computation by the db.
> >>
> >> / purbon
> >>
> >> On 15 July 2011 16:10, Marko Rodriguez  wrote:
> >>
> >>> Hi Pere,
> >>>
> >>> To sort you need to have all your results.
> >>>
> >>> Thus, in Gremlin (and hopefully you can do the mapping to the core
> Neo4j
> >>> traverser framework),
> >>>
> >>> results = []
> >>> g.v(1).out('friend').out('likes') >> results // what my friends like
> >>> results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
> >> name
> >>>
> >>> In short, once you have the result of your traversal, you can then
> apply
> >> a
> >>> comparator to the Collection to sort it as you please --- its just Java
> >>> comparators.
> >>>
> >>> See ya,
> >>> Marko.
> >>>
> >>> http://markorodriguez.com
> >>>
> >>> On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
> >>>
> >>>> HI!
> >>>> I am on the situation of having to traverse neo4j, and then expect the
> >>>> resultset returned to be ordered in a certain order. I've been
> >>> researching a
> >>>> bit over the traversal API, but I did not find anything related to
> >> that.
> >>> I
> >>>> really will appreciate any tip on that!!
> >>>>
> >>>> BTW > I expect to be possible right?, as we have in relational the
> >>> ordering,
> >>>> or on redis, etc...
> >>>>
> >>>> /purbon
> >>>>
> >>>> --
> >>>> Pere Urbon-Bayes
> >>>> moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> >>>> Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> >>>> ___
> >>>> Neo4j mailing list
> >>>> User@lists.neo4j.org
> >>>

Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Michael Hunger
You might also try to use cypher for your traversal which is able to order 
(also in memory of course).

See the screencast I did: http://neo4j.vidcaster.com/U2Y/introduction-to-cypher/

It's even the same domain.

Cheers

Michael

Am 15.07.2011 um 17:24 schrieb Rick Bullotta:

> But you couldn't easy do a complex traversal with an RDBMS. ;-)
> 
> I suspect that even if you could write some magic SQL to do so, you'd almost 
> certainly lose the benefits any optimized sorting/ordering that indices 
> provide, so even the RDBMS would have to post-process the sort.
> 
> If the traversal isn't complex or randomly "deep", then Neo indexing + 
> querying might work for you the same way an RDBMS might handle it.
> 
> 
> -Original Message-
> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On 
> Behalf Of Pere Urbon Bayes
> Sent: Friday, July 15, 2011 11:21 AM
> To: Neo4j user discussions
> Subject: Re: [Neo4j] Getting sorted results from a traversal
> 
> Well, the thing is that the database can easy deal with that, as the
> relational system do.
> 
> / purbon
> 
> On 15 July 2011 17:08, Rick Bullotta  wrote:
> 
>> The DB would do it in memory too, wouldn't it?  In the case of a complex
>> traversal, indexes don't really apply, since the ordering and the traversal
>> order are unrelated, so you'd generally need to sort in memory anyway.
>> Whether you do it as you add elements to the traversed list of "stuff" or
>> do it after the fact is another discussion, but I think in either case, it
>> needs to be done "after the fact".
>> 
>> 
>> -Original Message-
>> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
>> On Behalf Of Pere Urbon Bayes
>> Sent: Friday, July 15, 2011 11:05 AM
>> To: Neo4j user discussions
>> Subject: Re: [Neo4j] Getting sorted results from a traversal
>> 
>> Well, this is great if I want to do all the math in memory, but I expect to
>> do the computation by the db.
>> 
>> / purbon
>> 
>> On 15 July 2011 16:10, Marko Rodriguez  wrote:
>> 
>>> Hi Pere,
>>> 
>>> To sort you need to have all your results.
>>> 
>>> Thus, in Gremlin (and hopefully you can do the mapping to the core Neo4j
>>> traverser framework),
>>> 
>>> results = []
>>> g.v(1).out('friend').out('likes') >> results // what my friends like
>>> results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
>> name
>>> 
>>> In short, once you have the result of your traversal, you can then apply
>> a
>>> comparator to the Collection to sort it as you please --- its just Java
>>> comparators.
>>> 
>>> See ya,
>>> Marko.
>>> 
>>> http://markorodriguez.com
>>> 
>>> On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
>>> 
>>>> HI!
>>>> I am on the situation of having to traverse neo4j, and then expect the
>>>> resultset returned to be ordered in a certain order. I've been
>>> researching a
>>>> bit over the traversal API, but I did not find anything related to
>> that.
>>> I
>>>> really will appreciate any tip on that!!
>>>> 
>>>> BTW > I expect to be possible right?, as we have in relational the
>>> ordering,
>>>> or on redis, etc...
>>>> 
>>>> /purbon
>>>> 
>>>> --
>>>> Pere Urbon-Bayes
>>>> moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
>>>> Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
>>>> ___
>>>> Neo4j mailing list
>>>> User@lists.neo4j.org
>>>> https://lists.neo4j.org/mailman/listinfo/user
>>> 
>>> ___
>>> Neo4j mailing list
>>> User@lists.neo4j.org
>>> https://lists.neo4j.org/mailman/listinfo/user
>>> 
>> 
>> 
>> 
>> --
>> Pere Urbon-Bayes
>> moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
>> Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
>> ___
>> Neo4j mailing list
>> User@lists.neo4j.org
>> https://lists.neo4j.org/mailman/listinfo/user
>> ___
>> Neo4j mailing list
>> User@lists.neo4j.org
>> https://lists.neo4j.org/mailman/listinfo/user
>> 
> 
> 
> 
> -- 
> Pere Urbon-Bayes
> moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Rick Bullotta
But you couldn't easy do a complex traversal with an RDBMS. ;-)

I suspect that even if you could write some magic SQL to do so, you'd almost 
certainly lose the benefits any optimized sorting/ordering that indices 
provide, so even the RDBMS would have to post-process the sort.

If the traversal isn't complex or randomly "deep", then Neo indexing + querying 
might work for you the same way an RDBMS might handle it.


-Original Message-
From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On 
Behalf Of Pere Urbon Bayes
Sent: Friday, July 15, 2011 11:21 AM
To: Neo4j user discussions
Subject: Re: [Neo4j] Getting sorted results from a traversal

Well, the thing is that the database can easy deal with that, as the
relational system do.

/ purbon

On 15 July 2011 17:08, Rick Bullotta  wrote:

> The DB would do it in memory too, wouldn't it?  In the case of a complex
> traversal, indexes don't really apply, since the ordering and the traversal
> order are unrelated, so you'd generally need to sort in memory anyway.
>  Whether you do it as you add elements to the traversed list of "stuff" or
> do it after the fact is another discussion, but I think in either case, it
> needs to be done "after the fact".
>
>
> -Original Message-
> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
> On Behalf Of Pere Urbon Bayes
> Sent: Friday, July 15, 2011 11:05 AM
> To: Neo4j user discussions
> Subject: Re: [Neo4j] Getting sorted results from a traversal
>
> Well, this is great if I want to do all the math in memory, but I expect to
> do the computation by the db.
>
> / purbon
>
> On 15 July 2011 16:10, Marko Rodriguez  wrote:
>
> > Hi Pere,
> >
> > To sort you need to have all your results.
> >
> > Thus, in Gremlin (and hopefully you can do the mapping to the core Neo4j
> > traverser framework),
> >
> > results = []
> > g.v(1).out('friend').out('likes') >> results // what my friends like
> > results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
> name
> >
> > In short, once you have the result of your traversal, you can then apply
> a
> > comparator to the Collection to sort it as you please --- its just Java
> > comparators.
> >
> > See ya,
> > Marko.
> >
> > http://markorodriguez.com
> >
> > On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
> >
> > > HI!
> > > I am on the situation of having to traverse neo4j, and then expect the
> > > resultset returned to be ordered in a certain order. I've been
> > researching a
> > > bit over the traversal API, but I did not find anything related to
> that.
> > I
> > > really will appreciate any tip on that!!
> > >
> > > BTW > I expect to be possible right?, as we have in relational the
> > ordering,
> > > or on redis, etc...
> > >
> > > /purbon
> > >
> > > --
> > > Pere Urbon-Bayes
> > > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > > ___
> > > Neo4j mailing list
> > > User@lists.neo4j.org
> > > https://lists.neo4j.org/mailman/listinfo/user
> >
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>
>
> --
> Pere Urbon-Bayes
> moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Pere Urbon-Bayes
moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Rick Bullotta
A few questions/thoughts:

- Do you have any expectation/prediction of the number of nodes satisfying the 
query?
- Do you care about *all* results or only the top "n" (I ask this because in 
most cases, a dataset of a zillion ordered records is of little value - often 
only the "edges" have meaningful content)

If the answer to the first question is < a couple million or so, I would 
probably sort in memory.  If the answer to the second question is "yes", then 
the problem because very easy, in that you can maintain a sorted list of the 
top "n" during the traversal process fairly easily.


-Original Message-
From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On 
Behalf Of Pere Urbon Bayes
Sent: Friday, July 15, 2011 11:17 AM
To: Neo4j user discussions
Subject: Re: [Neo4j] Getting sorted results from a traversal

Well in fact, I expect to order the resulting set of nodes by a property on
that end nodes. But This class cold also help on some use cases I think.

/ purbon

On 15 July 2011 16:43, Niels Hoogeveen  wrote:

>
> Hi,You basically have two options. If your result set is not too big, you
> can sort it in memory, though that approach may consume too much memory if
> the result set is very large. In that case you can use SortedTree (see:
> https://github.com/peterneubauer/graph-collections/tree/master/src/main/java/org/neo4j/collections/sortedtree).
> This allows you to layout the relationships you want to traverse in sorted
> order.
> Niels
> > Date: Fri, 15 Jul 2011 16:06:44 +0200
> > From: p...@moviepilot.com
> > To: user@lists.neo4j.org
> > Subject: [Neo4j] Getting sorted results from a traversal
> >
> > HI!
> >  I am on the situation of having to traverse neo4j, and then expect the
> > resultset returned to be ordered in a certain order. I've been
> researching a
> > bit over the traversal API, but I did not find anything related to that.
> I
> > really will appreciate any tip on that!!
> >
> > BTW > I expect to be possible right?, as we have in relational the
> ordering,
> > or on redis, etc...
> >
> > /purbon
> >
> > --
> > Pere Urbon-Bayes
> > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
>
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Pere Urbon-Bayes
moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Pere Urbon Bayes
Well, the thing is that the database can easy deal with that, as the
relational system do.

/ purbon

On 15 July 2011 17:08, Rick Bullotta  wrote:

> The DB would do it in memory too, wouldn't it?  In the case of a complex
> traversal, indexes don't really apply, since the ordering and the traversal
> order are unrelated, so you'd generally need to sort in memory anyway.
>  Whether you do it as you add elements to the traversed list of "stuff" or
> do it after the fact is another discussion, but I think in either case, it
> needs to be done "after the fact".
>
>
> -Original Message-
> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
> On Behalf Of Pere Urbon Bayes
> Sent: Friday, July 15, 2011 11:05 AM
> To: Neo4j user discussions
> Subject: Re: [Neo4j] Getting sorted results from a traversal
>
> Well, this is great if I want to do all the math in memory, but I expect to
> do the computation by the db.
>
> / purbon
>
> On 15 July 2011 16:10, Marko Rodriguez  wrote:
>
> > Hi Pere,
> >
> > To sort you need to have all your results.
> >
> > Thus, in Gremlin (and hopefully you can do the mapping to the core Neo4j
> > traverser framework),
> >
> > results = []
> > g.v(1).out('friend').out('likes') >> results // what my friends like
> > results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
> name
> >
> > In short, once you have the result of your traversal, you can then apply
> a
> > comparator to the Collection to sort it as you please --- its just Java
> > comparators.
> >
> > See ya,
> > Marko.
> >
> > http://markorodriguez.com
> >
> > On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
> >
> > > HI!
> > > I am on the situation of having to traverse neo4j, and then expect the
> > > resultset returned to be ordered in a certain order. I've been
> > researching a
> > > bit over the traversal API, but I did not find anything related to
> that.
> > I
> > > really will appreciate any tip on that!!
> > >
> > > BTW > I expect to be possible right?, as we have in relational the
> > ordering,
> > > or on redis, etc...
> > >
> > > /purbon
> > >
> > > --
> > > Pere Urbon-Bayes
> > > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > > ___
> > > Neo4j mailing list
> > > User@lists.neo4j.org
> > > https://lists.neo4j.org/mailman/listinfo/user
> >
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>
>
> --
> Pere Urbon-Bayes
> moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Pere Urbon-Bayes
moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Pere Urbon Bayes
Yes the graph structure is relevant, but I am just saying I don't know how
the structure can help me in this use case.

All that I want is to do a traversal, and then order the expected result. It
will be possible If I only use neo4j as a traversal thing, and then another
system as a property store, but I think the hole neo4j should be able to
deal with that, right?

/ purbon

On 15 July 2011 17:16, Rick Bullotta  wrote:

> I would think that the graph structure definitely matters, in that there
> may be optimizations that can be achieved via indexing/querying vs traversal
> and sorting (or a hybrid of the two) depending on the specifics.
>
> -Original Message-
> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
> On Behalf Of Pere Urbon Bayes
> Sent: Friday, July 15, 2011 11:14 AM
> To: Neo4j user discussions
> Subject: Re: [Neo4j] Getting sorted results from a traversal
>
> Well the graph structure is not relevant here, I think. The property I
> expect to be sorting is on the destination node, so I can do the traversal
> and then expect to run the sorting.
>
> Please, tell me how the data structure can help me to deal with that order,
> please?
>
> / purbon
>
> On 15 July 2011 17:10, David Montag 
> wrote:
>
> > Hi Pere,
> >
> > Can you elaborate on your graph structure?
> >
> > Thanks,
> > David
> >
> > On Fri, Jul 15, 2011 at 8:04 AM, Pere Urbon Bayes  > >wrote:
> >
> > > Well, this is great if I want to do all the math in memory, but I
> expect
> > to
> > > do the computation by the db.
> > >
> > > / purbon
> > >
> > > On 15 July 2011 16:10, Marko Rodriguez  wrote:
> > >
> > > > Hi Pere,
> > > >
> > > > To sort you need to have all your results.
> > > >
> > > > Thus, in Gremlin (and hopefully you can do the mapping to the core
> > Neo4j
> > > > traverser framework),
> > > >
> > > > results = []
> > > > g.v(1).out('friend').out('likes') >> results // what my friends like
> > > > results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
> > > name
> > > >
> > > > In short, once you have the result of your traversal, you can then
> > apply
> > > a
> > > > comparator to the Collection to sort it as you please --- its just
> Java
> > > > comparators.
> > > >
> > > > See ya,
> > > > Marko.
> > > >
> > > > http://markorodriguez.com
> > > >
> > > > On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
> > > >
> > > > > HI!
> > > > > I am on the situation of having to traverse neo4j, and then expect
> > the
> > > > > resultset returned to be ordered in a certain order. I've been
> > > > researching a
> > > > > bit over the traversal API, but I did not find anything related to
> > > that.
> > > > I
> > > > > really will appreciate any tip on that!!
> > > > >
> > > > > BTW > I expect to be possible right?, as we have in relational the
> > > > ordering,
> > > > > or on redis, etc...
> > > > >
> > > > > /purbon
> > > > >
> > > > > --
> > > > > Pere Urbon-Bayes
> > > > > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > > > > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > > > > ___
> > > > > Neo4j mailing list
> > > > > User@lists.neo4j.org
> > > > > https://lists.neo4j.org/mailman/listinfo/user
> > > >
> > > > ___
> > > > Neo4j mailing list
> > > > User@lists.neo4j.org
> > > > https://lists.neo4j.org/mailman/listinfo/user
> > > >
> > >
> > >
> > >
> > > --
> > > Pere Urbon-Bayes
> > > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > > ___
> > > Neo4j mailing list
> > > User@lists.neo4j.org
> > > https://lists.neo4j.org/mailman/listinfo/user
> > >
> >
> >
> >
> > --
> > David Montag 
> > Neo Technology, www.neotechnology.com
> > Cell: 650.556.4411
> > Skype: ddmontag
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>
>
> --
> Pere Urbon-Bayes
> moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Pere Urbon-Bayes
moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Pere Urbon Bayes
Well in fact, I expect to order the resulting set of nodes by a property on
that end nodes. But This class cold also help on some use cases I think.

/ purbon

On 15 July 2011 16:43, Niels Hoogeveen  wrote:

>
> Hi,You basically have two options. If your result set is not too big, you
> can sort it in memory, though that approach may consume too much memory if
> the result set is very large. In that case you can use SortedTree (see:
> https://github.com/peterneubauer/graph-collections/tree/master/src/main/java/org/neo4j/collections/sortedtree).
> This allows you to layout the relationships you want to traverse in sorted
> order.
> Niels
> > Date: Fri, 15 Jul 2011 16:06:44 +0200
> > From: p...@moviepilot.com
> > To: user@lists.neo4j.org
> > Subject: [Neo4j] Getting sorted results from a traversal
> >
> > HI!
> >  I am on the situation of having to traverse neo4j, and then expect the
> > resultset returned to be ordered in a certain order. I've been
> researching a
> > bit over the traversal API, but I did not find anything related to that.
> I
> > really will appreciate any tip on that!!
> >
> > BTW > I expect to be possible right?, as we have in relational the
> ordering,
> > or on redis, etc...
> >
> > /purbon
> >
> > --
> > Pere Urbon-Bayes
> > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
>
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Pere Urbon-Bayes
moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Rick Bullotta
I would think that the graph structure definitely matters, in that there may be 
optimizations that can be achieved via indexing/querying vs traversal and 
sorting (or a hybrid of the two) depending on the specifics.

-Original Message-
From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On 
Behalf Of Pere Urbon Bayes
Sent: Friday, July 15, 2011 11:14 AM
To: Neo4j user discussions
Subject: Re: [Neo4j] Getting sorted results from a traversal

Well the graph structure is not relevant here, I think. The property I
expect to be sorting is on the destination node, so I can do the traversal
and then expect to run the sorting.

Please, tell me how the data structure can help me to deal with that order,
please?

/ purbon

On 15 July 2011 17:10, David Montag  wrote:

> Hi Pere,
>
> Can you elaborate on your graph structure?
>
> Thanks,
> David
>
> On Fri, Jul 15, 2011 at 8:04 AM, Pere Urbon Bayes  >wrote:
>
> > Well, this is great if I want to do all the math in memory, but I expect
> to
> > do the computation by the db.
> >
> > / purbon
> >
> > On 15 July 2011 16:10, Marko Rodriguez  wrote:
> >
> > > Hi Pere,
> > >
> > > To sort you need to have all your results.
> > >
> > > Thus, in Gremlin (and hopefully you can do the mapping to the core
> Neo4j
> > > traverser framework),
> > >
> > > results = []
> > > g.v(1).out('friend').out('likes') >> results // what my friends like
> > > results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
> > name
> > >
> > > In short, once you have the result of your traversal, you can then
> apply
> > a
> > > comparator to the Collection to sort it as you please --- its just Java
> > > comparators.
> > >
> > > See ya,
> > > Marko.
> > >
> > > http://markorodriguez.com
> > >
> > > On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
> > >
> > > > HI!
> > > > I am on the situation of having to traverse neo4j, and then expect
> the
> > > > resultset returned to be ordered in a certain order. I've been
> > > researching a
> > > > bit over the traversal API, but I did not find anything related to
> > that.
> > > I
> > > > really will appreciate any tip on that!!
> > > >
> > > > BTW > I expect to be possible right?, as we have in relational the
> > > ordering,
> > > > or on redis, etc...
> > > >
> > > > /purbon
> > > >
> > > > --
> > > > Pere Urbon-Bayes
> > > > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > > > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > > > ___
> > > > Neo4j mailing list
> > > > User@lists.neo4j.org
> > > > https://lists.neo4j.org/mailman/listinfo/user
> > >
> > > ___
> > > Neo4j mailing list
> > > User@lists.neo4j.org
> > > https://lists.neo4j.org/mailman/listinfo/user
> > >
> >
> >
> >
> > --
> > Pere Urbon-Bayes
> > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>
>
> --
> David Montag 
> Neo Technology, www.neotechnology.com
> Cell: 650.556.4411
> Skype: ddmontag
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Pere Urbon-Bayes
moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Pere Urbon Bayes
Well the graph structure is not relevant here, I think. The property I
expect to be sorting is on the destination node, so I can do the traversal
and then expect to run the sorting.

Please, tell me how the data structure can help me to deal with that order,
please?

/ purbon

On 15 July 2011 17:10, David Montag  wrote:

> Hi Pere,
>
> Can you elaborate on your graph structure?
>
> Thanks,
> David
>
> On Fri, Jul 15, 2011 at 8:04 AM, Pere Urbon Bayes  >wrote:
>
> > Well, this is great if I want to do all the math in memory, but I expect
> to
> > do the computation by the db.
> >
> > / purbon
> >
> > On 15 July 2011 16:10, Marko Rodriguez  wrote:
> >
> > > Hi Pere,
> > >
> > > To sort you need to have all your results.
> > >
> > > Thus, in Gremlin (and hopefully you can do the mapping to the core
> Neo4j
> > > traverser framework),
> > >
> > > results = []
> > > g.v(1).out('friend').out('likes') >> results // what my friends like
> > > results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
> > name
> > >
> > > In short, once you have the result of your traversal, you can then
> apply
> > a
> > > comparator to the Collection to sort it as you please --- its just Java
> > > comparators.
> > >
> > > See ya,
> > > Marko.
> > >
> > > http://markorodriguez.com
> > >
> > > On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
> > >
> > > > HI!
> > > > I am on the situation of having to traverse neo4j, and then expect
> the
> > > > resultset returned to be ordered in a certain order. I've been
> > > researching a
> > > > bit over the traversal API, but I did not find anything related to
> > that.
> > > I
> > > > really will appreciate any tip on that!!
> > > >
> > > > BTW > I expect to be possible right?, as we have in relational the
> > > ordering,
> > > > or on redis, etc...
> > > >
> > > > /purbon
> > > >
> > > > --
> > > > Pere Urbon-Bayes
> > > > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > > > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > > > ___
> > > > Neo4j mailing list
> > > > User@lists.neo4j.org
> > > > https://lists.neo4j.org/mailman/listinfo/user
> > >
> > > ___
> > > Neo4j mailing list
> > > User@lists.neo4j.org
> > > https://lists.neo4j.org/mailman/listinfo/user
> > >
> >
> >
> >
> > --
> > Pere Urbon-Bayes
> > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>
>
> --
> David Montag 
> Neo Technology, www.neotechnology.com
> Cell: 650.556.4411
> Skype: ddmontag
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Pere Urbon-Bayes
moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread David Montag
Hi Pere,

Can you elaborate on your graph structure?

Thanks,
David

On Fri, Jul 15, 2011 at 8:04 AM, Pere Urbon Bayes wrote:

> Well, this is great if I want to do all the math in memory, but I expect to
> do the computation by the db.
>
> / purbon
>
> On 15 July 2011 16:10, Marko Rodriguez  wrote:
>
> > Hi Pere,
> >
> > To sort you need to have all your results.
> >
> > Thus, in Gremlin (and hopefully you can do the mapping to the core Neo4j
> > traverser framework),
> >
> > results = []
> > g.v(1).out('friend').out('likes') >> results // what my friends like
> > results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by
> name
> >
> > In short, once you have the result of your traversal, you can then apply
> a
> > comparator to the Collection to sort it as you please --- its just Java
> > comparators.
> >
> > See ya,
> > Marko.
> >
> > http://markorodriguez.com
> >
> > On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
> >
> > > HI!
> > > I am on the situation of having to traverse neo4j, and then expect the
> > > resultset returned to be ordered in a certain order. I've been
> > researching a
> > > bit over the traversal API, but I did not find anything related to
> that.
> > I
> > > really will appreciate any tip on that!!
> > >
> > > BTW > I expect to be possible right?, as we have in relational the
> > ordering,
> > > or on redis, etc...
> > >
> > > /purbon
> > >
> > > --
> > > Pere Urbon-Bayes
> > > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > > ___
> > > Neo4j mailing list
> > > User@lists.neo4j.org
> > > https://lists.neo4j.org/mailman/listinfo/user
> >
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>
>
> --
> Pere Urbon-Bayes
> moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
David Montag 
Neo Technology, www.neotechnology.com
Cell: 650.556.4411
Skype: ddmontag
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Marko Rodriguez
Hi,

Ah. Then I would recommend using a persistent data structure such as the one 
the Neil discussed in his follow up post.

Marko.

http://markorodriguez.com

On Jul 15, 2011, at 9:04 AM, Pere Urbon Bayes wrote:

> Well, this is great if I want to do all the math in memory, but I expect to
> do the computation by the db.
> 
> / purbon
> 
> On 15 July 2011 16:10, Marko Rodriguez  wrote:
> 
>> Hi Pere,
>> 
>> To sort you need to have all your results.
>> 
>> Thus, in Gremlin (and hopefully you can do the mapping to the core Neo4j
>> traverser framework),
>> 
>> results = []
>> g.v(1).out('friend').out('likes') >> results // what my friends like
>> results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by name
>> 
>> In short, once you have the result of your traversal, you can then apply a
>> comparator to the Collection to sort it as you please --- its just Java
>> comparators.
>> 
>> See ya,
>> Marko.
>> 
>> http://markorodriguez.com
>> 
>> On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
>> 
>>> HI!
>>> I am on the situation of having to traverse neo4j, and then expect the
>>> resultset returned to be ordered in a certain order. I've been
>> researching a
>>> bit over the traversal API, but I did not find anything related to that.
>> I
>>> really will appreciate any tip on that!!
>>> 
>>> BTW > I expect to be possible right?, as we have in relational the
>> ordering,
>>> or on redis, etc...
>>> 
>>> /purbon
>>> 
>>> --
>>> Pere Urbon-Bayes
>>> moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
>>> Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
>>> ___
>>> Neo4j mailing list
>>> User@lists.neo4j.org
>>> https://lists.neo4j.org/mailman/listinfo/user
>> 
>> ___
>> Neo4j mailing list
>> User@lists.neo4j.org
>> https://lists.neo4j.org/mailman/listinfo/user
>> 
> 
> 
> 
> -- 
> Pere Urbon-Bayes
> moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Rick Bullotta
The DB would do it in memory too, wouldn't it?  In the case of a complex 
traversal, indexes don't really apply, since the ordering and the traversal 
order are unrelated, so you'd generally need to sort in memory anyway.  Whether 
you do it as you add elements to the traversed list of "stuff" or do it after 
the fact is another discussion, but I think in either case, it needs to be done 
"after the fact".


-Original Message-
From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On 
Behalf Of Pere Urbon Bayes
Sent: Friday, July 15, 2011 11:05 AM
To: Neo4j user discussions
Subject: Re: [Neo4j] Getting sorted results from a traversal

Well, this is great if I want to do all the math in memory, but I expect to
do the computation by the db.

/ purbon

On 15 July 2011 16:10, Marko Rodriguez  wrote:

> Hi Pere,
>
> To sort you need to have all your results.
>
> Thus, in Gremlin (and hopefully you can do the mapping to the core Neo4j
> traverser framework),
>
> results = []
> g.v(1).out('friend').out('likes') >> results // what my friends like
> results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by name
>
> In short, once you have the result of your traversal, you can then apply a
> comparator to the Collection to sort it as you please --- its just Java
> comparators.
>
> See ya,
> Marko.
>
> http://markorodriguez.com
>
> On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
>
> > HI!
> > I am on the situation of having to traverse neo4j, and then expect the
> > resultset returned to be ordered in a certain order. I've been
> researching a
> > bit over the traversal API, but I did not find anything related to that.
> I
> > really will appreciate any tip on that!!
> >
> > BTW > I expect to be possible right?, as we have in relational the
> ordering,
> > or on redis, etc...
> >
> > /purbon
> >
> > --
> > Pere Urbon-Bayes
> > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
>
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Pere Urbon-Bayes
moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Pere Urbon Bayes
Well, this is great if I want to do all the math in memory, but I expect to
do the computation by the db.

/ purbon

On 15 July 2011 16:10, Marko Rodriguez  wrote:

> Hi Pere,
>
> To sort you need to have all your results.
>
> Thus, in Gremlin (and hopefully you can do the mapping to the core Neo4j
> traverser framework),
>
> results = []
> g.v(1).out('friend').out('likes') >> results // what my friends like
> results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by name
>
> In short, once you have the result of your traversal, you can then apply a
> comparator to the Collection to sort it as you please --- its just Java
> comparators.
>
> See ya,
> Marko.
>
> http://markorodriguez.com
>
> On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
>
> > HI!
> > I am on the situation of having to traverse neo4j, and then expect the
> > resultset returned to be ordered in a certain order. I've been
> researching a
> > bit over the traversal API, but I did not find anything related to that.
> I
> > really will appreciate any tip on that!!
> >
> > BTW > I expect to be possible right?, as we have in relational the
> ordering,
> > or on redis, etc...
> >
> > /purbon
> >
> > --
> > Pere Urbon-Bayes
> > moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> > Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
>
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Pere Urbon-Bayes
moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Niels Hoogeveen

Hi,You basically have two options. If your result set is not too big, you can 
sort it in memory, though that approach may consume too much memory if the 
result set is very large. In that case you can use SortedTree (see: 
https://github.com/peterneubauer/graph-collections/tree/master/src/main/java/org/neo4j/collections/sortedtree).
 This allows you to layout the relationships you want to traverse in sorted 
order. 
Niels
> Date: Fri, 15 Jul 2011 16:06:44 +0200
> From: p...@moviepilot.com
> To: user@lists.neo4j.org
> Subject: [Neo4j] Getting sorted results from a traversal
> 
> HI!
>  I am on the situation of having to traverse neo4j, and then expect the
> resultset returned to be ordered in a certain order. I've been researching a
> bit over the traversal API, but I did not find anything related to that. I
> really will appreciate any tip on that!!
> 
> BTW > I expect to be possible right?, as we have in relational the ordering,
> or on redis, etc...
> 
> /purbon
> 
> -- 
> Pere Urbon-Bayes
> moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
  
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Marko Rodriguez
Hi Pere,

To sort you need to have all your results. 

Thus, in Gremlin (and hopefully you can do the mapping to the core Neo4j 
traverser framework),

results = []
g.v(1).out('friend').out('likes') >> results // what my friends like
results.sort{a,b -> a.name <=> b.name} // sort resultant vertices by name

In short, once you have the result of your traversal, you can then apply a 
comparator to the Collection to sort it as you please --- its just Java 
comparators.

See ya,
Marko.

http://markorodriguez.com

On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:

> HI!
> I am on the situation of having to traverse neo4j, and then expect the
> resultset returned to be ordered in a certain order. I've been researching a
> bit over the traversal API, but I did not find anything related to that. I
> really will appreciate any tip on that!!
> 
> BTW > I expect to be possible right?, as we have in relational the ordering,
> or on redis, etc...
> 
> /purbon
> 
> -- 
> Pere Urbon-Bayes
> moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
> Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Pere Urbon Bayes
HI!
 I am on the situation of having to traverse neo4j, and then expect the
resultset returned to be ordered in a certain order. I've been researching a
bit over the traversal API, but I did not find anything related to that. I
really will appreciate any tip on that!!

BTW > I expect to be possible right?, as we have in relational the ordering,
or on redis, etc...

/purbon

-- 
Pere Urbon-Bayes
moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user