Search in sources :

Example 1 with GhostVertexRemover

use of org.janusgraph.graphdb.olap.job.GhostVertexRemover in project janusgraph by JanusGraph.

the class OLAPTest method removeGhostVertices.

@Test
public void removeGhostVertices() throws Exception {
    JanusGraphVertex v1 = tx.addVertex("person");
    v1.property("name", "stephen");
    JanusGraphVertex v2 = tx.addVertex("person");
    v1.property("name", "marko");
    JanusGraphVertex 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();
    JanusGraphTransaction 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(org.janusgraph.graphdb.olap.job.GhostVertexRemover) ScanMetrics(org.janusgraph.diskstorage.keycolumnvalue.scan.ScanMetrics) Test(org.junit.Test) JanusGraphBaseTest(org.janusgraph.graphdb.JanusGraphBaseTest)

Aggregations

ScanMetrics (org.janusgraph.diskstorage.keycolumnvalue.scan.ScanMetrics)1 JanusGraphBaseTest (org.janusgraph.graphdb.JanusGraphBaseTest)1 GhostVertexRemover (org.janusgraph.graphdb.olap.job.GhostVertexRemover)1 Test (org.junit.Test)1