This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| daniel@cube /usr/local/titan-0.5.4-hadoop1 $ echo $HADOOP_PREFIX | |
| /usr/local/hadoop | |
| daniel@cube /usr/local/titan-0.5.4-hadoop1 $ bin/gremlin.sh | |
| \,,,/ | |
| (o o) | |
| -----oOOo-(_)-oOOo----- | |
| gremlin> hdfs.ls() | |
| gremlin> g = TitanFactory.open("conf/titan-cassandra-es.properties") | |
| ==>titangraph[cassandrathrift:[127.0.0.1]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| daniel@cube /usr/local/titan-0.5.2-hadoop1 $ for i in {1..100000}; do echo -e "User #$i\tuser$i@example.com" >> /tmp/userInfo_js.txt; done | |
| daniel@cube /usr/local/titan-0.5.2-hadoop1 $ cat /tmp/batchImportTest2.properties | |
| storage.backend=berkeleyje | |
| storage.directory=/tmp/graph | |
| storage.batch-loading=true | |
| query.fast-property=true | |
| daniel@cube /usr/local/titan-0.5.2-hadoop1 $ bin/gremlin.sh | |
| \,,,/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| g.V().choose(level1(), | |
| level1().choose(level2(), | |
| level2().choose(level3(), | |
| level3(), | |
| identity()), | |
| identity()), | |
| identity()).path().by("name") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| g = new TinkerGraph() | |
| v1 = g.addVertex(1, ["type": "data", "name": "Foo"]) | |
| v2 = g.addVertex(2, ["type": "data", "name": "Cicero"]) | |
| v3 = g.addVertex(3, ["type": "data", "name": "Pan"]) | |
| v4 = g.addVertex(4, ["type": "data", "name": "Cicero"]) | |
| v5 = g.addVertex(5, ["type": "data", "name": "Pan"]) | |
| v6 = g.addVertex(6, ["type": "data", "name": "Bar"]) | |
| v7 = g.addVertex(7, ["type": "data", "name": "Lorem"]) | |
| DRAFT = g.addVertex(["type": "status", "name": "DRAFT"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \,,,/ | |
| (o o) | |
| -----oOOo-(3)-oOOo----- | |
| plugin activated: tinkerpop.server | |
| plugin activated: tinkerpop.utilities | |
| plugin activated: tinkerpop.tinkergraph | |
| gremlin> import static com.tinkerpop.gremlin.process.util.Range.* | |
| ... | |
| gremlin> __.inject(1,2,3,4,5).is(inside, inclusive(2,4)) | |
| ==>2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| g.V().has(__.union(__.map {it.get().outE().count().next()}.is(gt, 2L), | |
| __.has(__.map {it.get().bothE().values("weight").mean().next()}.is(lte, 0.5d)). | |
| has(__.values("age").union(__.is(27), __.is(gt, 30))))).values("name") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Find vertices with only incoming edges: | |
| v[2] | |
| v[5] | |
| Find vertices with only outgoing edges: | |
| v[1] | |
| v[3] | |
| v[7] | |
| Find vertices with at most 1 edge on any side: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| set -u | |
| # Environment variables that affect this script: | |
| # | |
| # TITAN_JAVA_OPTS | |
| # | |
| # When set to a nonempty value, this variable is interpreted as a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| g = TitanFactory.open("conf/titan-cassandra-es.properties") | |
| m = g.openManagement() | |
| vidp = m.makePropertyKey("vid").dataType(Integer.class).make() | |
| // only use Cardinality.SET if a vertex can have multiple is-a relations | |
| isa = m.makePropertyKey("is-a").dataType(String.class).cardinality(Cardinality.SET).make() | |
| m.buildIndex("by_vid", Vertex.class).addKey(vidp).buildCompositeIndex() | |
| m.buildIndex("by_isa", Vertex.class).addKey(isa).buildCompositeIndex() | |
| m.makeEdgeLabel("test").make() | |
| m.commit() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.google.common.collect.Lists; | |
| import com.tinkerpop.gremlin.process.T; | |
| import com.tinkerpop.gremlin.process.Traverser; | |
| import com.tinkerpop.gremlin.structure.Vertex; | |
| import com.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; | |
| import java.util.Collection; | |
| import java.util.HashMap; | |
| /** |