use of uk.gov.gchq.gaffer.data.graph.adjacency.AdjacencyMap in project Gaffer by gchq.
the class GetWalksHandler method executeOperation.
private List<?> executeOperation(final Output<Iterable<Element>> operation, final List<?> seeds, final Integer resultLimit, final Context context, final Store store, final int hops, final AdjacencyMaps adjacencyMaps, final EntityMaps entityMaps) throws OperationException {
final Iterable<Element> results = executeOperation(operation, seeds, resultLimit, context, store);
final AdjacencyMap adjacencyMap = new AdjacencyMap();
final EntityMap entityMap = new EntityMap();
final List<Object> nextSeeds = new ArrayList<>();
for (final Element e : results) {
if (e instanceof Edge) {
final Edge edge = (Edge) e;
final Object nextSeed = edge.getAdjacentMatchedVertexValue();
nextSeeds.add(nextSeed);
adjacencyMap.putEdge(edge.getMatchedVertexValue(), nextSeed, edge);
} else {
final Entity entity = (Entity) e;
entityMap.putEntity(entity.getVertex(), entity);
}
}
if (hops > adjacencyMaps.size()) {
adjacencyMaps.add(adjacencyMap);
}
entityMaps.add(entityMap);
return nextSeeds;
}
Aggregations