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));
}
Aggregations