Skip to content

Instantly share code, notes, and snippets.

@spmallette
Last active September 23, 2021 14:03
Show Gist options
  • Save spmallette/15cfbbd439573b60dd2fc6e4ee9d0d0b to your computer and use it in GitHub Desktop.
Save spmallette/15cfbbd439573b60dd2fc6e4ee9d0d0b to your computer and use it in GitHub Desktop.
basically made by(String) => by(coalesce(values(k), constant(null)))
basically made by(values(k)) => by(coalesce(values(k), constant(null)))
by(Traversal) => RuntimeException
make consistent with ProductiveByStrategy which could take keys that would otherwise convert to above pattern and always wrap Traversal
would warnings help with filters?
aggregate()
gremlin> g.V().aggregate('a').by('age').cap('a') // 3.5.x
==>[29,27,null,null,32,35]
gremlin> g.V().aggregate('a').by('age').cap('a') // future
==>[29,27,32,35]
cyclicPath()
gremlin> g.V().has('person','name','marko').both().both().cyclicPath().by('age') // 3.5.x
==>v[1]
java.lang.NullPointerException
Type ':help' or ':h' for help.
Display stack trace? [yN]n
gremlin> g.V().has('person','name','marko').both().both().cyclicPath().by('age') // future
==>v[1]
==>v[1]
dedup()
gremlin> g.V().both().dedup().by('age').elementMap() // 3.5.x
==>[id:3,label:software,name:lop,lang:java]
==>[id:2,label:person,name:vadas,age:27]
==>[id:4,label:person,name:josh,age:32]
==>[id:1,label:person,name:marko,age:29]
==>[id:6,label:person,name:peter,age:35]
gremlin> g.V().both().dedup().by('age').elementMap() // future
==>[id:2,label:person,name:vadas,age:27]
==>[id:4,label:person,name:josh,age:32]
==>[id:1,label:person,name:marko,age:29]
==>[id:6,label:person,name:peter,age:35]
group()
unproductive by() for values
gremlin> g.V().group().by('name').by('age') // 3.5.x
==>[ripple:[null],peter:[35],vadas:[27],josh:[32],lop:[null],marko:[29]]
gremlin> g.V().group().by('name').by('age') // future option 1
==>[ripple:[],peter:[35],vadas:[27],josh:[32],lop:[],marko:[29]]
gremlin> g.V().group().by('name').by('age') // future option 2
==>[peter:[35],vadas:[27],josh:[32],marko:[29]]
gremlin> g.V().group().by('name').by('age') // future option 3
==>[ripple:[v[5]],peter:[35],vadas:[27],josh:[32],lop:[v[3]],marko:[29]]
// unproductive by() for keys
gremlin> g.V().group().by('age').by('name') // 3.5.x
==>[null:[lop,ripple],32:[josh],35:[peter],27:[vadas],29:[marko]]
gremlin> g.V().group().by('age').by('name') // future option 1
==>[32:[josh],35:[peter],27:[vadas],29:[marko]]
gremlin> g.V().group().by('age').by('name') // future option 2
==>[v[3]:[lop],v[5]:[ripple],32:[josh],35:[peter],27:[vadas],29:[marko]]
groupCount()
gremlin> g.V().groupCount().by('age') // 3.5.x
==>[null:2,32:1,35:1,27:1,29:1]
gremlin> g.V().groupCount().by('age') // future option 1
==>[32:1,35:1,27:1,29:1]
gremlin> g.V().groupCount().by('age') // future option 2
==>[v[3]:1,v[5]:1,32:1,35:1,27:1,29:1]
math()
gremlin> g.V().math('_+1').by('age') // 3.5.x
==>30.0
==>28.0
The variable _ for math() step must resolve to a Number - it is instead of type null with value null
Type ':help' or ':h' for help.
Display stack trace? [yN]n
gremlin> g.V().math('_+1').by('age') // future
==>30.0
==>28.0
==>33.0
==>36.0
path()
gremlin> g.V().both().path().by('age') // 3.5.x
==>[29,null]
==>[29,27]
==>[29,32]
==>[27,29]
==>[null,29]
==>[null,32]
==>[null,35]
==>[32,null]
==>[32,null]
==>[32,29]
==>[null,32]
==>[35,null]
gremlin> g.V().both().path().by('age') // future option 1
==>[29]
==>[29,27]
==>[29,32]
==>[27,29]
==>[29]
==>[32]
==>[35]
==>[32]
==>[32]
==>[32,29]
==>[32]
==>[35]
gremlin> g.V().both().path().by('age') // future option 2
==>[29,27]
==>[29,32]
==>[27,29]
==>[32,29]
gremlin> g.V().both().path().by('age') // future option 3
==>[29,v[3]]
==>[29,27]
==>[29,32]
==>[27,29]
==>[v[3],29]
==>[v[3],32]
==>[v[3],35]
==>[32,v[5]]
==>[32,v[3]]
==>[32,29]
==>[v[5],32]
==>[35,v[3]]
project()
gremlin> g.V().project('n','a').by('name').by('age') // 3.5.x
==>[n:marko,a:29]
==>[n:vadas,a:27]
==>[n:lop,a:null]
==>[n:josh,a:32]
==>[n:ripple,a:null]
==>[n:peter,a:35]
gremlin> g.V().project('n','a').by('name').by('age') // future option 1
==>[n:marko,a:29]
==>[n:vadas,a:27]
==>[n:lop]
==>[n:josh,a:32]
==>[n:ripple]
==>[n:peter,a:35]
gremlin> g.V().project('n','a').by('name').by('age') // future option 2
==>[n:marko,a:29]
==>[n:vadas,a:27]
==>[n:josh,a:32]
==>[n:peter,a:35]
gremlin> g.V().project('n','a').by('name').by('age') // future option 3
==>[n:marko,a:29]
==>[n:vadas,a:27]
==>[n:lop,a:v[3]]
==>[n:josh,a:32]
==>[n:ripple,a:v[5]]
==>[n:peter,a:35]
propertyMap()
only by(Traversal) can be applied here and it is executed on a List
gremlin> g.V().propertyMap().by(is('x')) // 3.5.x
The provided start does not map to a value: [vp[name->marko]]->[IsStep(eq(x))]
Type ':help' or ':h' for help.
Display stack trace? [yN]n
gremlin> g.V().valueMap().by(is('x')) // future
==>[name:[],age:[]]
==>[name:[],age:[]]
==>[name:[],lang:[]]
==>[name:[],age:[]]
==>[name:[],lang:[]]
==>[name:[],age:[]]
order()
gremlin> g.V().both().order().by('age').elementMap() // 3.5.x
==>[id:3,label:software,name:lop,lang:java]
==>[id:3,label:software,name:lop,lang:java]
==>[id:3,label:software,name:lop,lang:java]
==>[id:5,label:software,name:ripple,lang:java]
==>[id:2,label:person,name:vadas,age:27]
==>[id:1,label:person,name:marko,age:29]
==>[id:1,label:person,name:marko,age:29]
==>[id:1,label:person,name:marko,age:29]
==>[id:4,label:person,name:josh,age:32]
==>[id:4,label:person,name:josh,age:32]
==>[id:4,label:person,name:josh,age:32]
==>[id:6,label:person,name:peter,age:35]
gremlin> g.V().both().order().by('age').elementMap() //future
==>[id:2,label:person,name:vadas,age:27]
==>[id:1,label:person,name:marko,age:29]
==>[id:1,label:person,name:marko,age:29]
==>[id:1,label:person,name:marko,age:29]
==>[id:4,label:person,name:josh,age:32]
==>[id:4,label:person,name:josh,age:32]
==>[id:4,label:person,name:josh,age:32]
==>[id:6,label:person,name:peter,age:35]
sack()
gremlin> g.V().sack(assign).by('age').sack() // 3.5.x
==>29
==>27
==>null
==>32
==>null
==>35
gremlin> g.V().sack(assign).by('age').sack() // future option 1
==>29
==>27
==>32
==>35
gremlin> g.V().sack(assign).by('age').sack() // future option 2
==>29
==>27
==>v[3]
==>32
==>v[5]
==>35
sample()
gremlin> g.V().both().sample(2).by('age') // 3.5.x
java.lang.NullPointerException
Type ':help' or ':h' for help.
Display stack trace? [yN]n
gremlin> g.V().both().sample(2).by('age') // future
gremlin>
select()
gremlin> g.V().has('person','name','marko').as('a').both().as('b').select('a','b').by('age') // 3.5.x
==>[a:29,b:null]
==>[a:29,b:27]
==>[a:29,b:32]
gremlin> g.V().has('person','name','marko').as('a').both().as('b').select('a','b').by('age') // future option 1
==>[a:29]
==>[a:29,b:27]
==>[a:29,b:32]
gremlin> g.V().has('person','name','marko').as('a').both().as('b').select('a','b').by('age') // future option 2
==>[a:29,b:27]
==>[a:29,b:32]
gremlin> g.V().has('person','name','marko').as('a').both().as('b').select('a','b').by('age') // future option 3
==>[a:29,b:v[3]]
==>[a:29,b:27]
==>[a:29,b:32]
simplePath()
gremlin> g.V().has('person','name','marko').both().both().simplePath().by('age') // 3.5.x
java.lang.NullPointerException
Type ':help' or ':h' for help.
Display stack trace? [yN]n
gremlin> g.V().has('person','name','marko').both().both().simplePath().by('age') // future
gremlin>
tree()
poor tree
valueMap()
only by(Traversal) can be applied here and it is executed on a List
gremlin> g.V().valueMap().by(is('x')) // 3.5.x
The provided start does not map to a value: [marko]->[IsStep(eq(x))]
Type ':help' or ':h' for help.
Display stack trace? [yN]n
gremlin> g.V().valueMap().by(is('x')) // future
==>[name:[],age:[]]
==>[name:[],age:[]]
==>[name:[],lang:[]]
==>[name:[],age:[]]
==>[name:[],lang:[]]
==>[name:[],age:[]]
where()
gremlin> g.V().as('a').both().both().as('b').where('a',eq('b')).by('age') // 3.5.x
==>v[1]
==>v[1]
==>v[1]
==>v[2]
==>v[3]
==>v[5]
==>v[3]
==>v[3]
==>v[4]
==>v[4]
==>v[4]
==>v[5]
==>v[3]
==>v[6]
gremlin> g.V().as('a').both().both().as('b').where('a',eq('b')).by('age') // future
==>v[1]
==>v[1]
==>v[1]
==>v[2]
==>v[4]
==>v[4]
==>v[4]
==>v[6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment