Search in sources :

Example 21 with GraphTransaction

use of com.baidu.hugegraph.backend.tx.GraphTransaction in project incubator-hugegraph by apache.

the class VertexCoreTest method testAddVertexWithTx.

@Test
public void testAddVertexWithTx() {
    HugeGraph graph = graph();
    GraphTransaction tx = params().openTransaction();
    tx.addVertex(T.label, "book", "name", "java-4");
    tx.addVertex(T.label, "book", "name", "java-5");
    try {
        tx.commit();
    } finally {
        tx.close();
    }
    long count = graph.traversal().V().count().next();
    Assert.assertEquals(2, count);
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) GraphTransaction(com.baidu.hugegraph.backend.tx.GraphTransaction) Test(org.junit.Test)

Example 22 with GraphTransaction

use of com.baidu.hugegraph.backend.tx.GraphTransaction in project incubator-hugegraph by apache.

the class VertexCoreTest method testRemoveVertexAfterAddVertexWithTx.

@Test
public void testRemoveVertexAfterAddVertexWithTx() {
    HugeGraph graph = graph();
    GraphTransaction tx = params().openTransaction();
    Vertex java1 = tx.addVertex(T.label, "book", "name", "java-1");
    tx.addVertex(T.label, "book", "name", "java-2");
    tx.commit();
    java1.remove();
    tx.commit();
    tx.close();
    List<Vertex> vertices = graph.traversal().V().toList();
    Assert.assertEquals(1, vertices.size());
    assertNotContains(vertices, T.label, "book", "name", "java-1");
}
Also used : FakeVertex(com.baidu.hugegraph.testutil.FakeObjects.FakeVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) HugeGraph(com.baidu.hugegraph.HugeGraph) GraphTransaction(com.baidu.hugegraph.backend.tx.GraphTransaction) Test(org.junit.Test)

Aggregations

GraphTransaction (com.baidu.hugegraph.backend.tx.GraphTransaction)22 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)7 SchemaTransaction (com.baidu.hugegraph.backend.tx.SchemaTransaction)6 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)6 LockUtil (com.baidu.hugegraph.util.LockUtil)6 Id (com.baidu.hugegraph.backend.id.Id)5 HugeGraph (com.baidu.hugegraph.HugeGraph)4 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)4 Test (org.junit.Test)4 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)3 EdgeLabel (com.baidu.hugegraph.schema.EdgeLabel)3 VertexLabel (com.baidu.hugegraph.schema.VertexLabel)3 HugeElement (com.baidu.hugegraph.structure.HugeElement)3 Edge (org.apache.tinkerpop.gremlin.structure.Edge)3 HugeException (com.baidu.hugegraph.HugeException)2 HugeGraphParams (com.baidu.hugegraph.HugeGraphParams)2 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)2 Query (com.baidu.hugegraph.backend.query.Query)2 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)2 FakeEdge (com.baidu.hugegraph.testutil.FakeObjects.FakeEdge)2