Skip to content

Instantly share code, notes, and snippets.

View spmallette's full-sized avatar

stephen mallette spmallette

View GitHub Profile
gremlin> g = traversal().withRemote(DriverRemoteConnection.using("localhost",8182,"g"))
==>graphtraversalsource[emptygraph[empty], standard]
gremlin> g.V()
gremlin> t = g.addV('zoo');[]
gremlin> t.iterate()
gremlin> t.iterate()
gremlin> t.iterate()
gremlin> t.iterate()
gremlin> t.iterate()
gremlin> t.iterate()
gremlin> g.inject([1,2],[1,2,3],[1,3],[1,2,3]).dedup().by(union(limit(local,1), tail(local)).fold())
==>[1,2]
==>[1,2,3]
gremlin> g.inject([1,2],[1,2,3],[1,3],[1,2,3]).dedup().by(project('p1','p2').by(limit(local,1)).by(tail(local)))
==>[1,2]
==>[1,2,3]
gremlin> g.V().has('age',between(29, 32)).elementMap()
==>[id:1,label:person,name:marko,age:29]
gremlin> g.V().has('age',between(29, 33)).elementMap()
==>[id:1,label:person,name:marko,age:29]
==>[id:4,label:person,name:josh,age:32]
gremlin> g.addV('Person').property('name','Sam')
==>v[16]
gremlin> g
==>graphtraversalsource[tinkergraph[vertices:1 edges:0], standard]
gremlin> g.inject(['Sam','Peter','Frank']).
......1> unfold().as('find').
......2> V().as('p').
......3> coalesce(
......4> where(eq('p')).
......5> by(select('find')).
gremlin> g = TinkerGraph.open().traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> g.withSideEffect('onCreate', [name:'a', created: 123]).
......1> withSideEffect('onMatch', [updated: 321]).
......2> V().has('name','a').fold().
......3> coalesce(unfold().as('v').sideEffect(select('onMatch').unfold().as('kv').
......4> select('v').
......5> property(select('kv').by(keys), select('kv').by(values))),
......6> addV().as('v').sideEffect(select('onCreate').unfold().as('kv').
......7> select('v').
g = TinkerGraph.open().traversal()
n1 = g.addV('A').property('id', '1').property('p', "node01").next()
n2 = g.addV('A').property('id', '2').property('p', 'node02').next()
n3 = g.addV('A').property('id', '3').property('p', 'node03').next()
n4 = g.addV('A').property('id', '4').property('p', 'node04').next()
n5 = g.addV('A').property('id', '5').property('p', 'node05').next()
n6 = g.addV('B').property('id', '6').property('p', 'node06').next()
n7 = g.addV('B').property('id', '7').property('p', 'node07').next()
n8 = g.addV('B').property('id', '8').property('p', 'node08').next()
n9 = g.addV('B').property('id', '9').property('p', 'node09').next()
gremlin> g.V([1,2])
==>v[1]
==>v[2]
gremlin> g.V().hasId([1,2])
==>v[1]
==>v[2]
gremlin> g.V().both().hasId(1,2)
==>v[2]
==>v[1]
==>v[1]
gremlin> import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex
==>...
gremlin> g.V().is(new DetachedVertex(1,'person',[:]))
==>v[1]
WebSocketClientBehaviorIntegrateTest#shouldPrintCorrectErrorForRegularWebSocketHandshakeTimeout()
[INFO] org.apache.tinkerpop.gremlin.driver.ConnectionPool - Signalled closing of connection pool on Host{address=localhost/127.0.0.1:45943, hostUri=ws://localhost:45943/gremlin} with core size of 1
[ERROR] org.apache.tinkerpop.gremlin.driver.Client$ClusteredClient - Could not initialize client for Host{address=localhost/127.0.0.1:45943, hostUri=ws://localhost:45943/gremlin}
[ERROR] org.apache.tinkerpop.gremlin.driver.Client$ClusteredClient - Initialization failed
java.util.concurrent.CompletionException: Could not initialize 1 (minPoolSize) connections in pool. Successful connections=0. Closing the connection pool.
at org.apache.tinkerpop.gremlin.driver.ConnectionPool.<init>(ConnectionPool.java:136)
at org.apache.tinkerpop.gremlin.driver.ConnectionPool.<init>(ConnectionPool.java:83)
at org.apache.tinkerpop.gremlin.driver.ConnectionPool.<init>(ConnectionPool.java:78)
at org.apache.tinkerpop.gremlin.driver.Cli
Scenario: g_mergeVXid_xxx_label_person_name_stephenX
Given the empty graph
And the graph initializer of
"""
g.addV("person").property("name", "marko").property("age", 29)
"""
And using the parameter xx1 defined as "m[{\"t[id]\": 1, \"t[label]\": \"person\", \"name\":\"stephen\"}]"
And the traversal of
"""