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