Skip to content

Instantly share code, notes, and snippets.

View spmallette's full-sized avatar

stephen mallette spmallette

View GitHub Profile
gremlin> g.inject([a:1,b:2],[a:10,c:3]).
......1> unfold().
......2> group().by(select(keys)).by(select(values))
==>[a:10,b:2,c:3]
gremlin> g.inject([a:1,b:2],[a:10,c:3]).
......1> fold([:], addAll)
==>[a:10,b:2,c:3]
Error: Tests run: 786, Failures: 3, Errors: 0, Skipped: 271, Time elapsed: 323.93 s <<< FAILURE! - in org.apache.tinkerpop.gremlin.spark.SparkGraphFeatureIntegrateTest
Error: g_withStrategiesXSeedStrategyX_V_order_byXlabel_descX_sampleX1X_byXageX(Step - sample()) Time elapsed: 0.333 s <<< FAILURE!
java.lang.AssertionError:
Expected: iterable with items [<v[6]>] in any order
but: not matched: <v[1]>
Error: g_withStrategiesXProductiveByStrategyX_V_group_byXageX(Step - group()) Time elapsed: 0.703 s <<< FAILURE!
java.lang.AssertionError:
gremlin> g.V().coalesce(out(),fail('vertex has no out edges'))
==>v[3]
==>v[2]
==>v[4]
fail() Step Triggered
===========================================================
Message > vertex has no out edges
Traverser> v[2]
Bulk > 1
Traversal> fail()
gremlin> g.inject(null).V().both().coalesce(has('name','marko').both(),constant(null)).cyclicPath().path()
==>[null,v[1],v[3],null]
==>[null,v[1],v[2],null]
==>[null,v[1],v[4],null]
==>[null,v[2],v[1],v[2]]
==>[null,v[3],v[1],v[3]]
==>[null,v[3],v[4],null]
==>[null,v[3],v[6],null]
==>[null,v[4],v[5],null]
==>[null,v[4],v[3],null]
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 = traversal().withRemote(DriverRemoteConnection.using("localhost",8182,"g"))
==>graphtraversalsource[emptygraph[empty], standard]
gremlin> t = g.V().filter(bothE('knows')).map(bothE("knows").order().by('weight',desc).limit(1));[]
gremlin> t.clone()
==>e[8][1-knows->4]
==>e[8][1-knows->4]
==>e[7][1-knows->2]
gremlin> t.clone()
==>e[8][1-knows->4]
==>e[8][1-knows->4]
new Object[]{"datetime('2018-03-22T00:35:44.741Z')", new DateTime(2018, 03, 22, 00, 35, 44, 741, DateTimeZone.UTC).toDate()},
new Object[]{"datetime('2018-03-22T00:35:44.741-0000')", new DateTime(2018, 03, 22, 00, 35, 44, 741, DateTimeZone.UTC).toDate()},
new Object[]{"datetime('2018-03-22T00:35:44.741+0000')", new DateTime(2018, 03, 22, 00, 35, 44, 741, DateTimeZone.UTC).toDate()},
new Object[]{"datetime('2018-03-22T00:35:44.741-0300')", new DateTime(2018, 03, 22, 00, 35, 44, 741, DateTimeZone.forOffsetHours(-3)).toDate()},
new Object[]{"datetime('2018-03-22T00:35:44.741+1600')", new DateTime(2018, 03, 22, 00, 35, 44, 741, DateTimeZone.forOffsetHours(16)).toDate()},
new Object[]{"datetime('2018-03-22T00:35:44.741')", new DateTime(2018, 03, 22, 00, 35, 44, 741, DateTimeZone.UTC).toDate()},
new Object[]{"datetime('2018-03-22T00:35:44Z')", new DateTime(2018, 03, 22, 00, 35, 44, DateTimeZone.UTC).toDat
{Operator.and, true, true, true},
{Operator.and, true, false, false},
{Operator.and, false, true, false},
{Operator.and, false, false, false},
{Operator.and, null, null, null},
{Operator.and, null, false, false},
{Operator.and, false, null, false},
{Operator.and, null, true, true},
{Operator.and, true, null, true},
{Operator.or, true, true, true},
gremlin> g.inject(null,null,null).select('a')
gremlin> g.inject(null,"test",null).select('a')
gremlin> g.inject(null,"test",[a:1]).select('a')
==>1
gremlin> g.inject(null,null,null).select('a').by('x')
gremlin> g.inject(null,"test",null).select('a').by('x')
gremlin> g.inject([a:1]).select('a')
==>1
gremlin> g.inject([a:1]).select('b')
gremlin> g.inject([x:'1']).as('a').select('a').by('y')
https://groups.google.com/g/gremlin-users/c/6EXYq2Howdo/m/hST6BW97AgAJ
The reason properties on properties makes sense for vertices and not for
edges is rooted in database design and not logical semantics.
A property on a vertex is a record as is an edge in the database sense.
Hence, we have use cases where we want to know who added a property on a
vertex (as a record).
For edges, the property on the edge is not a record and thinking about it
as such would make the data model really complex (because you could then
get recursively more complex). Hence, all properties of the edge are part