use of org.unipop.util.ConversionUtils in project unipop by unipop-graph.
the class UniGraphVertexStep method process.
@Override
protected Iterator<Traverser.Admin<E>> process(List<Traverser.Admin<Vertex>> traversers) {
Map<Object, List<Traverser<Vertex>>> idToTraverser = new HashMap<>(traversers.size());
List<Vertex> vertices = new ArrayList<>(traversers.size());
traversers.forEach(traverser -> {
Vertex vertex = traverser.get();
List<Traverser<Vertex>> traverserList = idToTraverser.get(vertex.id());
if (traverserList == null) {
traverserList = new ArrayList<>(1);
idToTraverser.put(vertex.id(), traverserList);
}
traverserList.add(traverser);
vertices.add(vertex);
});
SearchVertexQuery vertexQuery;
if (!returnsVertex)
vertexQuery = new SearchVertexQuery(Edge.class, vertices, direction, predicates, limit, propertyKeys, orders, stepDescriptor, traversal);
else
vertexQuery = new SearchVertexQuery(Edge.class, vertices, direction, predicates, -1, propertyKeys, null, stepDescriptor, traversal);
logger.debug("Executing query: ", vertexQuery);
Iterator<Traverser.Admin<E>> traversersIterator = controllers.stream().<Iterator<Edge>>map(controller -> controller.search(vertexQuery)).<Edge>flatMap(ConversionUtils::asStream).<Traverser.Admin<E>>flatMap(edge -> toTraversers(edge, idToTraverser)).iterator();
if (!this.returnsVertex || (propertyKeys != null && propertyKeys.size() == 0))
return traversersIterator;
return getTraversersWithProperties(traversersIterator);
}
Aggregations