Search in sources :

Example 1 with AdjacencyMap

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;
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) EntityMap(uk.gov.gchq.gaffer.data.graph.entity.EntityMap) AdjacencyMap(uk.gov.gchq.gaffer.data.graph.adjacency.AdjacencyMap) Element(uk.gov.gchq.gaffer.data.element.Element) ArrayList(java.util.ArrayList) Edge(uk.gov.gchq.gaffer.data.element.Edge)

Aggregations

ArrayList (java.util.ArrayList)1 Edge (uk.gov.gchq.gaffer.data.element.Edge)1 Element (uk.gov.gchq.gaffer.data.element.Element)1 Entity (uk.gov.gchq.gaffer.data.element.Entity)1 AdjacencyMap (uk.gov.gchq.gaffer.data.graph.adjacency.AdjacencyMap)1 EntityMap (uk.gov.gchq.gaffer.data.graph.entity.EntityMap)1