TitanTransaction tx1 = graph.newTransaction(); TitanTransaction tx2 = graph.newTransaction(); job.run(tx1); job.run(tx2);
TitanTransaction tx = graph.newTransaction();
public class GraphManagerFactory(){ TitanGraph instance; public static GraphManager getGraphManager(){ if(instance = null){ instance = TitanFactory.open("conf/titan-cassandra.properties"); } return new GraphManager(instance.newTransaction()); } }
private static void codeSnippets() throws Exception { TitanGraph g = TitanFactory.open("/tmp/titan"); g.createKeyIndex("name", Vertex.class); Vertex juno = g.addVertex(null); juno.setProperty("name", "juno"); juno = g.getVertices("name", "juno").iterator().next(); TransactionalGraph tx = g.newTransaction(); Thread[] threads = new Thread[10]; for (int i = 0; i < threads.length; i++) { //threads[i]=new Thread(new DoSomething(tx)); threads[i].start(); } for (int i = 0; i < threads.length; i++) threads[i].join(); tx.commit(); }
private static void codeSnippets() throws Exception { TitanGraph g = TitanFactory.open("/tmp/titan"); g.createKeyIndex("name", Vertex.class); Vertex juno = g.addVertex(null); juno.setProperty("name", "juno"); juno = g.getVertices("name", "juno").iterator().next(); TransactionalGraph tx = g.newTransaction(); Thread[] threads = new Thread[10]; for (int i = 0; i < threads.length; i++) { //threads[i]=new Thread(new DoSomething(tx)); threads[i].start(); } for (int i = 0; i < threads.length; i++) threads[i].join(); tx.commit(); }
public class GraphManagerFactory(){ TitanGraph instance; public static GraphManager getGraphManager(){ if(instance = null){ instance = TitanFactory.open("conf/titan-cassandra.properties"); TitanManagement management = instance.openManagement(); //Check if the labels exist before creating explicitly. //If they don't exist do the following: management.makeEdgeLabel("EdgeLabel").make(); management.makePropertyKey("property").dataType(String.class).make(); management.commit(); } return new GraphManager(instance.newTransaction()); } }
TitanTransaction tx1 = graph.newTransaction(); TitanTransaction tx2 = graph.newTransaction(); job.run(tx1); job.run(tx2);
public void makeTypes(TitanGraph g) { Preconditions.checkArgument(edgeLabels <= edgePropKeys); TitanTransaction tx = g.newTransaction(); for (int i = 0; i < vertexPropKeys; i++) { tx.makeKey(getVertexPropertyName(i)).dataType(Integer.class).indexed(Vertex.class).single().make(); } for (int i = 0; i < edgePropKeys; i++) { tx.makeKey(getEdgePropertyName(i)).dataType(Integer.class).indexed(Edge.class).single().make(); } for (int i = 0; i < edgeLabels; i++) { String labelName = getEdgeLabelName(i); String pkName = getSortKeyForLabel(labelName); TitanKey pk = tx.getPropertyKey(pkName); tx.makeLabel(getEdgeLabelName(i)).sortKey(pk).make(); } tx.makeKey(UID_PROP).dataType(Long.class).indexed(Vertex.class).single().unique().make(); tx.commit(); }
TitanTransaction tx = g.newTransaction();
TitanTransaction tx = g.newTransaction();
TitanTransaction tx = graph.newTransaction();
TitanTransaction tx = graph.newTransaction();