Search in sources :

Example 1 with DataGenerator

use of uk.gov.gchq.gaffer.example.operation.generator.DataGenerator in project Gaffer by gchq.

the class OperationExample method createExampleGraph.

protected Graph createExampleGraph() {
    final Graph graph = new Graph.Builder().addSchemas(StreamUtil.openStreams(getClass(), "/example/operation/schema")).storeProperties(StreamUtil.openStream(getClass(), "/example/operation/mockaccumulostore.properties")).build();
    // Create data generator
    final DataGenerator dataGenerator = new DataGenerator();
    // Load data into memory
    final List<String> data = DataUtils.loadData(StreamUtil.openStream(getClass(), "/example/operation/data.txt", true));
    //add the edges to the graph using an operation chain consisting of:
    //generateElements - generating edges from the data (note these are directed edges)
    //addElements - add the edges to the graph
    final OperationChain addOpChain = new OperationChain.Builder().first(new GenerateElements.Builder<String>().generator(dataGenerator).objects(data).build()).then(new AddElements()).build();
    try {
        graph.execute(addOpChain, new User());
    } catch (OperationException e) {
        throw new RuntimeException(e);
    }
    return graph;
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Graph(uk.gov.gchq.gaffer.graph.Graph) User(uk.gov.gchq.gaffer.user.User) DataGenerator(uk.gov.gchq.gaffer.example.operation.generator.DataGenerator) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Aggregations

DataGenerator (uk.gov.gchq.gaffer.example.operation.generator.DataGenerator)1 Graph (uk.gov.gchq.gaffer.graph.Graph)1 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)1 OperationException (uk.gov.gchq.gaffer.operation.OperationException)1 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)1 User (uk.gov.gchq.gaffer.user.User)1