OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

xdi message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: RE: [External] [xdi] One change to multiplicity proposal

Some thoughts for our query language are below.  These are taken from a comparison  of two Neo4j graph query languages, Cypher and Gremlin, posted at http://romikoderbynew.com/2012/02/22/gremlin-vs-cypher-initial-thoughts-neo4j/.


  • Simple graph traversals are much more efficient when using Gremlin
  • Queries in Gremlin are 30-50% faster for simple traversals
  • Cypher is ideal for complex traversals where back tracking is required
  • Cypher is our choice of query language for reporting
  • Gremlin is our choice of query language for simple traversals where projections are not required
  • Cypher has intrinsic table projection model, where Gremlins table projection model relies on AS steps which can be cumbersome when backtracking e.g. Back(), As() and _CopySplit, where cypher is just comma separated matches
  • Cypher is much better suited for outer joins than Gremlin, to achieve similar results in gremlin requires parallel querying with CopySplit, where as in Cypher using the Match clause with optional relationships
  • Gremlin is ideal when you need to retrieve very simple data structures
  • Table projection in gremlin can be very powerful, however outer joins can be very verbose

An example of Cypher

var resultSet = graphClient.RootNode








                       ->(createdByUser), (referral)-[:REFERRAL_HAS_WHO_SECTION]


                .Where<Agency>(agency => agency.Key == userIdentifier.AgencyKey)


                .Where<User>(user => user.Username == userIdentifier.Username)


                .Where<Referral>(referral => referral.Completed == false)

                .Return((user, program, centre, createdByUser, referral, whoSection, participant) =>

                new ReferralByGroup


                    UserFamilyName = createdByUser.As<User>().FamilyName,

                    UserGivenName = createdByUser.As<User>().GivenName,

                    Program = program.As<Program>().Name,

                    Centre = centre.As<Centre>().Name,

                    ReferralId = referral.As<Referral>().UniqueId,

                    ReferralDate = whoSection.As<ReferralWhoSection>().ReferralDate,

                    ParticipantName = participant.As<ReferralParticipant>().Name,

                    ParticipantDisplayOrder = participant.As<ReferralParticipant>().DisplayOrder,





An equivalent in Gremlin:

var resultSet = graphClient


    .Out<Agency>(Hosts.TypeKey, a => a.Key == userIdentifier.AgencyKey)

    .In<User>(UserBelongsTo.TypeKey, u => u.Username == userIdentifier.Username)







    .In<Referral>(ReferralHasDecisionsSection.TypeKey, r => r.Completed == false)












    <ReferralByGroup, Program, Centre, Referral, User, User, ReferralWhoSection, ReferralParticipant,


            program => program.Name,

            centre => centre.Name,

            referral => referral.UniqueId,

            user => user.FamilyName,

            user => user.GivenName,

            who => who.ReferralDate,

            participant => participant.Name,

            participant => participant.DisplayOrder




And I will try to post a follow-up email with an equivalent in XGP, XDI Graph Patterns, the query language I’ve been trying to put together as an underpinning for applying DLP style reasoning to an XDI dataset, similar to what Euler# allows for semantic web queries.




Kind regards,


Bill Barnhill

Booz Allen Hamilton - Belcamp,MD


Cell: 1-443-924-0824

Desk: 1-443-861-9102


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]