VertexProgram in Tinkerpop 3
Submit a VertexProgram to a graph’s GraphComputer:
GraphComputer.submit()
ComputerResult is a full copy of the original graph, or a view over the original raph. It alswo gets access to Memory (runtime, number of iterations, results of MapReduce jobs,etc).
(Found the example from Tinkerpop 3 doc)
gremlin> graph = TinkerFactory.createModern() ==>tinkergraph[vertices:6 edges:6] gremlin> result = graph.compute().program(PageRankVertexProgram.build().create()).submit().get() ==>result[tinkergraph[vertices:6 edges:0],memory[size:0]] gremlin> result.memory().runtime ==>214 gremlin> g=result.graph().traversal(standard()) ==>graphtraversalsource[tinkergraph[vertices:6 edges:0], standard] gremlin> g.V().valueMap('name',PageRankVertexProgram.PAGE_RANK) ==>[gremlin.pageRankVertexProgram.pageRank:[0.15000000000000002], name:[marko]] ==>[gremlin.pageRankVertexProgram.pageRank:[0.19250000000000003], name:[vadas]] ==>[gremlin.pageRankVertexProgram.pageRank:[0.4018125], name:[lop]] ==>[gremlin.pageRankVertexProgram.pageRank:[0.19250000000000003], name:[josh]] ==>[gremlin.pageRankVertexProgram.pageRank:[0.23181250000000003], name:[ripple]] ==>[gremlin.pageRankVertexProgram.pageRank:[0.15000000000000002], name:[peter]] gremlin>
Interacts with Java
(Well, this part seems useless >_< , you can scroll down, since it’s nearly the same with above)
1. Loading Data into a TinkerGraph
InputStream in = new FileInputStream(“dataset/test.json&amp;amp;amp;quot;); GraphSONReader reader = GraphSONReader.build().create(); reader.readGraph(in, g);
2. Use GraphComputer
ComputerResult result = graph.compute().program(PageRankVertexProgram.build().create(null)).submit().get();
3. GraphTraversalSource
//GraphTraversalSource gts=result.graph().traversal(); result.graph().traversal().V().valueMap(&quot;name&quot;,PageRankVertexProgram.PAGE_RANK).forEachRemaining(System.out::println);
result:
{gremlin.pageRankVertexProgram.pageRank=[1.0822970208320357], name=[CANDYMAN]} {gremlin.pageRankVertexProgram.pageRank=[1.9359906635483166], name=[HES GONE]} {gremlin.pageRankVertexProgram.pageRank=[0.15000000000000002], name=[LAZY RIVER ROAD]} {gremlin.pageRankVertexProgram.pageRank=[0.1902841984781851], name=[Keith_Godchaux]} {gremlin.pageRankVertexProgram.pageRank=[0.5669931483069848], name=[BIRDSONG]} .....
Problems
When starting..
&gt;&gt;bin/titan.sh start jps command not found. Put the JDK's jps binary on the command path.
So, here comes the prob:
What is jps command?
Java Virtual Machine Process Status Tool, provided by JDK which shows active PID java process. A powerful tool on linux/unix.
jps is on JAVA_HOME/bin/jps, you can also put JAVA_HOME/bin/ into the Path.
Example:
&gt;&gt; jps 23991 Jps 23789 BossMain 23651 Resin
This might because your JDK doesn’t contain the jps, I will suggest you to update your JDK. When you install your JDK, and use “tar -zxvf ..” you will see jps is included in the bin directory.
Cassandra problems:
I moved to a remote computer today, then I was facing some problems, but thanks to google.
1. Initial heap size set to a larger value than the maximum heap size.
solution:
Add an option in .bashrc (used for a local environment variable):
export _JAVA_OPTIONS=“-Xms2048M -Xmx4096M”
2. Cassandra Unable to create thrift socket to localhost/127.0.0.1:9160
Use >> bin/cassandra -f
3. Cassandra commit log FSWriteError. (Permission denied) or no such file: .xx.log
I checked the cassandra.yaml file, and found the commit log file location: commitlog_directory: db/cassandra/commitlog. Then I changed to another directory, and problem solved.
Did not find any ways to delete commit logs. I did not use “sudo” to start. Changing to another directory works but do not know the cause of this problem.
4. Other problems or error with port.
Change rpc_port: 9160 to a new one. (In conf/cassandra/cassandra.yaml file)
References:
https://groups.google.com/forum/#!topic/aureliusgraphs/sb35IdTbqjU
http://skydream.iteye.com/blog/151897