Hi Marko,

Working nicely now :)

Here is how it looks on our client. I am not sure if I can call _() an 
identityPipe, any inspiration here? I had to use Aggregate here, instead of 
Store(), else the Except does not work.

var results = graphClient
                .RootNode
                .CopySplit(
                    new IdentityPipe()
                        .Out<Agency>(Hosts.TypeKey, a => a.Key == 
userIdentifier.AgencyKey)
                        .In<User>(UserBelongsTo.TypeKey)
                        .Out<Centre>(UserLinkedToCentre.TypeKey)
                        .In<User>(UserLinkedToCentre.TypeKey)
                        .In<Referral>(CreatedBy.TypeKey, r => r.Completed == 
false)
                        .AggregateV<Referral>("ReferralWithCentres"),
                    new IdentityPipe()
                        .Out<Agency>(Hosts.TypeKey, a => a.Key == 
userIdentifier.AgencyKey)
                )
                .FairMerge()
                .In<Referral>(ReferralBelongsTo.TypeKey, r => r.Completed == 
false)
                .As("ReferralId")
                .ExceptV<Referral>("ReferralWithCentres")
                .GremlinDistinct()
                .Out<User>(CreatedBy.TypeKey)
                .As("UserGivenName")
                .As("UserFamilyName")
                .Table<ReferralByGroup, Referral, User, User>(
                    referral => referral.UniqueId,
                    user => user.FamilyName,
                    user => user.GivenName
                );

Which generates this optimised query.
ReferralWithCentres = [];g.v(p0)._.copySplit(_().outE[[label:p1]].inV.filter{ 
it[p2].equalsIgnoreCase(p3) 
}.inE[[label:p4]].outV.outE[[label:p5]].inV.inE[[label:p6]].outV.inE[[label:p7]].outV.filter{
 it[p8] == p9 }.aggregate(ReferralWithCentres), 
_().outE[[label:p10]].inV.filter{ it[p11].equalsIgnoreCase(p12) 
}).fairMerge.inE[[label:p13]].outV.filter{ it[p14] == p15 
}.as(p16).except(ReferralWithCentres).uniqueObject().outE[[label:p17]].inV.as(p18).as(p19).table(new
 Table()){it[p20]}{it[p21]}{it[p22]}.cap

Thanks again for all the help :)

-----Original Message-----
From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On 
Behalf Of Marko A. Rodriguez
Sent: Sunday, 4 December 2011 4:09 PM
To: Neo4j user discussions
Subject: Re: [Neo4j] Aggregates inside copySplit()

Hey,

That will probably give you unwanted behavior as aggregate is a greedy step. If 
you just want to lazily store and not aggregate then:

  Gremlin 1.3:   sideEffect{x.add(it)}
  Gremlin 1.4:   store(x)

HTH,
Marko.

http://markorodriguez.com

On Dec 3, 2011, at 8:50 PM, Romiko Derbynew <romiko.derby...@readify.net> wrote:

> Sorry, forgot to complete question. So I use a 
> x=[];g.v(0).out.copySplit(_().out.aggregate(x), 
> _().out).fairMerge().out.retain(x). I guess this is not possible, where a 
> retain clause is used after a fairMerge()?
> 
> -----Original Message-----
> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On 
> Behalf Of Romiko Derbynew
> Sent: Sunday, 4 December 2011 2:38 PM
> To: Neo4j user discussions (user@lists.neo4j.org)
> Subject: [Neo4j] Aggregates inside copySplit()
> 
> Hi,
> 
> Is it possible to use aggregates within a copySplit pipe?
> _______________________________________________
> 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


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

Reply via email to