Search in sources :

Example 1 with GhostVertexRemover

use of com.thinkaurelius.titan.graphdb.olap.job.GhostVertexRemover in project titan by thinkaurelius.

the class OLAPTest method removeGhostVertices.

@Test
public void removeGhostVertices() throws Exception {
    TitanVertex v1 = tx.addVertex("person");
    v1.property("name", "stephen");
    TitanVertex v2 = tx.addVertex("person");
    v1.property("name", "marko");
    TitanVertex v3 = tx.addVertex("person");
    v1.property("name", "dan");
    v2.addEdge("knows", v3);
    v1.addEdge("knows", v2);
    newTx();
    long v3id = getId(v3);
    long v1id = getId(v1);
    assertTrue(v3id > 0);
    v3 = getV(tx, v3id);
    assertNotNull(v3);
    v3.remove();
    tx.commit();
    TitanTransaction xx = graph.buildTransaction().checkExternalVertexExistence(false).start();
    v3 = getV(xx, v3id);
    assertNotNull(v3);
    v1 = getV(xx, v1id);
    assertNotNull(v1);
    v3.property("name", "deleted");
    v3.addEdge("knows", v1);
    xx.commit();
    newTx();
    assertNull(getV(tx, v3id));
    v1 = getV(tx, v1id);
    assertNotNull(v1);
    assertEquals(v3id, v1.query().direction(Direction.IN).labels("knows").vertices().iterator().next().longId());
    tx.commit();
    mgmt.commit();
    ScanMetrics result = executeScanJob(new GhostVertexRemover(graph));
    assertEquals(1, result.getCustom(GhostVertexRemover.REMOVED_VERTEX_COUNT));
    assertEquals(2, result.getCustom(GhostVertexRemover.REMOVED_RELATION_COUNT));
    assertEquals(0, result.getCustom(GhostVertexRemover.SKIPPED_GHOST_LIMIT_COUNT));
}
Also used : GhostVertexRemover(com.thinkaurelius.titan.graphdb.olap.job.GhostVertexRemover) ScanMetrics(com.thinkaurelius.titan.diskstorage.keycolumnvalue.scan.ScanMetrics) Test(org.junit.Test) TitanGraphBaseTest(com.thinkaurelius.titan.graphdb.TitanGraphBaseTest)

Aggregations

ScanMetrics (com.thinkaurelius.titan.diskstorage.keycolumnvalue.scan.ScanMetrics)1 TitanGraphBaseTest (com.thinkaurelius.titan.graphdb.TitanGraphBaseTest)1 GhostVertexRemover (com.thinkaurelius.titan.graphdb.olap.job.GhostVertexRemover)1 Test (org.junit.Test)1