Search in sources :

Example 1 with MockTransactionalGraph

use of com.tinkerpop.blueprints.impls.tg.MockTransactionalGraph in project blueprints by tinkerpop.

the class BatchGraphTest method loadingTest.

public void loadingTest(int total, int bufferSize, VertexIDType type, LoadingFactory ids) {
    final VertexEdgeCounter counter = new VertexEdgeCounter();
    MockTransactionalGraph tgraph = null;
    if (ignoreIDs) {
        tgraph = new MockTransactionalGraph(new IgnoreIdTinkerGraph());
    } else {
        tgraph = new MockTransactionalGraph(new TinkerGraph());
    }
    BLGraph graph = new BLGraph(tgraph, counter, ids);
    BatchGraph<BLGraph> loader = new BatchGraph<BLGraph>(graph, type, bufferSize);
    if (assignKeys) {
        loader.setVertexIdKey(vertexIDKey);
        loader.setEdgeIdKey(edgeIDKey);
    }
    //Create a chain
    int chainLength = total;
    Vertex previous = null;
    for (int i = 0; i <= chainLength; i++) {
        Vertex next = loader.addVertex(ids.getVertexID(i));
        next.setProperty(UID, i);
        counter.numVertices++;
        counter.totalVertices++;
        if (previous != null) {
            Edge e = loader.addEdge(ids.getEdgeID(i), loader.getVertex(previous.getId()), loader.getVertex(next.getId()), "next");
            e.setProperty(UID, i);
            counter.numEdges++;
        }
        previous = next;
    }
    loader.stopTransaction(TransactionalGraph.Conclusion.SUCCESS);
    assertTrue(tgraph.allSuccessful());
    loader.shutdown();
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) IgnoreIdTinkerGraph(com.tinkerpop.blueprints.impls.tg.IgnoreIdTinkerGraph) IgnoreIdTinkerGraph(com.tinkerpop.blueprints.impls.tg.IgnoreIdTinkerGraph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) MockTransactionalGraph(com.tinkerpop.blueprints.impls.tg.MockTransactionalGraph) Edge(com.tinkerpop.blueprints.Edge)

Aggregations

Edge (com.tinkerpop.blueprints.Edge)1 Vertex (com.tinkerpop.blueprints.Vertex)1 IgnoreIdTinkerGraph (com.tinkerpop.blueprints.impls.tg.IgnoreIdTinkerGraph)1 MockTransactionalGraph (com.tinkerpop.blueprints.impls.tg.MockTransactionalGraph)1 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)1