@Override public Vertex createEntity( TypeMetadataSet<EntityTypeMetadata<TitanVertexMetadata>> types, Set<String> discriminators, Map<PrimitivePropertyMethodMetadata<TitanPropertyMetadata>, Object> exampleEntity) { Vertex vertex = titanGraph.addVertex(null); for (String discriminator : discriminators) { vertex.setProperty(TitanStoreSession.XO_DISCRIMINATORS_PROPERTY + discriminator, discriminator); } return vertex; }
private static Vertex createComicBook(TitanGraph graph, String value) { long start = System.currentTimeMillis(); Vertex vertex = graph.addVertex(); vertex.property(COMIC_BOOK, value); REGISTRY.counter(COUNTER_GET + COMIC_BOOK).inc(); long end = System.currentTimeMillis(); long time = end - start; REGISTRY.timer(TIMER_CREATE + COMIC_BOOK).update(time, TimeUnit.MILLISECONDS); return vertex; }
private static Vertex createCharacter(TitanGraph graph, String value) { long start = System.currentTimeMillis(); Vertex vertex = graph.addVertex(); vertex.property(CHARACTER, value); // only sets weapon on character vertex on initial creation. vertex.property(WEAPON, WEAPONS[RANDOM.nextInt(WEAPONS.length)]); REGISTRY.counter(COUNTER_GET + CHARACTER).inc(); long end = System.currentTimeMillis(); long time = end - start; REGISTRY.timer(TIMER_CREATE + CHARACTER).update(time, TimeUnit.MILLISECONDS); return vertex; } }
@Override public AtlasVertex<Titan0Vertex, Titan0Edge> addVertex() { Vertex result = getGraph().addVertex(null); return GraphDbObjectFactory.createVertex(this, result); }
private Vertex getOrCreate(TitanGraph graph, String vertexId) { GraphTraversalSource g = graph.traversal(); return g.V().has("uniqueId", vertexId).tryNext().orElseGet(() -> graph.addVertex("uniqueId", vertexId); }
@Override public AtlasVertex<Titan1Vertex, Titan1Edge> addVertex() { Vertex result = getGraph().addVertex(); return GraphDbObjectFactory.createVertex(this, result); }
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(); }
/** * Initialise the handler using the graph passed as arguments. * * @param graph */ public TitanRDFHandler(TitanGraph graph, String indexes) { this.graph = new BatchGraph(graph); if (!graph.getIndexedKeys(Vertex.class).contains(VALUE)) { graph.createKeyIndex(VALUE, Vertex.class); } createTripleIndices(indexes, graph); namespaces = graph.addVertex(NAMESPACES_VERTEX_ID); }
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(); }
/** * Initialise the handler using the graph passed as arguments. * * @param graph */ public TitanRDFHandler(TitanGraph graph, String indexes) { this.graph = new BatchGraph(graph); if (!graph.getIndexedKeys(Vertex.class).contains(VALUE)) { graph.createKeyIndex(VALUE, Vertex.class); } createTripleIndices(indexes, graph); namespaces = graph.addVertex(NAMESPACES_VERTEX_ID); }
private static void process(TitanGraph graph, Appeared appeared) { Vertex comicBookVertex = get(graph, COMIC_BOOK, appeared.getComicBook()); if (null == comicBookVertex) { REGISTRY.counter("error.missingComicBook." + appeared.getComicBook()).inc(); comicBookVertex = graph.addVertex(); comicBookVertex.property(COMIC_BOOK, appeared.getComicBook()); } Vertex characterVertex = get(graph, CHARACTER, appeared.getCharacter()); if (null == characterVertex) { REGISTRY.counter("error.missingCharacter." + appeared.getCharacter()).inc(); characterVertex = graph.addVertex(); characterVertex.property(CHARACTER, appeared.getCharacter()); characterVertex.property(WEAPON, WEAPONS[RANDOM.nextInt(WEAPONS.length)]); } characterVertex.addEdge(APPEARED, comicBookVertex); }
@Override public Vertex getOrCreate(String value) { Integer intValue = Integer.valueOf(value); final Vertex v; if (titanGraph.query().has("nodeId", Compare.EQUAL, intValue).vertices().iterator().hasNext()) { v = (Vertex) titanGraph.query().has("nodeId", Compare.EQUAL, intValue).vertices().iterator().next(); } else { final long titanVertexId = TitanId.toVertexId(intValue); v = titanGraph.addVertex(titanVertexId); v.setProperty("nodeId", intValue); titanGraph.commit(); } return v; }
Vertex v = g.addVertex(i);
Vertex v = g.addVertex(i);