use of uk.gov.gchq.gaffer.example.gettingstarted.generator.DataGenerator6 in project Gaffer by gchq.
the class LoadAndQuery6 method run.
public CloseableIterable<String> run() throws OperationException {
// [user] Create a user
// ---------------------------------------------------------
final User user = new User("user01");
// ---------------------------------------------------------
// [graph] create a graph using our schema and store properties
// ---------------------------------------------------------
final Graph graph = new Graph.Builder().addSchemas(getSchemas()).storeProperties(getStoreProperties()).build();
// ---------------------------------------------------------
// [add] Create a data generator and 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 DataGenerator6 dataGenerator = new DataGenerator6();
final List<String> data = DataUtils.loadData(getData());
final OperationChain addOpChain = new OperationChain.Builder().first(new GenerateElements.Builder<String>().generator(dataGenerator).objects(data).build()).then(new AddElements()).build();
graph.execute(addOpChain, user);
// ---------------------------------------------------------
// [get] Create and execute an operation chain consisting of 3 operations:
//GetAdjacentEntitySeeds - starting at vertex 1 get all adjacent vertices (vertices at other end of outbound edges)
//GetRelatedEdges - get outbound edges
//GenerateObjects - convert the edges back into comma separated strings
// ---------------------------------------------------------
final OperationChain<CloseableIterable<String>> opChain = new OperationChain.Builder().first(new GetAdjacentEntitySeeds.Builder().addSeed(new EntitySeed("1")).inOutType(IncludeIncomingOutgoingType.OUTGOING).build()).then(new GetEdges.Builder<EntitySeed>().inOutType(IncludeIncomingOutgoingType.OUTGOING).build()).then(new GenerateObjects.Builder<Edge, String>().generator(dataGenerator).build()).build();
final CloseableIterable<String> results = graph.execute(opChain, user);
// ---------------------------------------------------------
log("\nFiltered edges converted back into comma separated strings. The counts have been aggregated\n");
for (final String result : results) {
log("RESULT", result);
}
return results;
}
Aggregations