use of org.unipop.query.search.SearchVertexQuery 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);
}
use of org.unipop.query.search.SearchVertexQuery in project unipop by unipop-graph.
the class UniVertex method edges.
@Override
public Iterator<Edge> edges(Direction direction, String... edgeLabels) {
PredicatesHolder predicatesHolder = (edgeLabels.length == 0) ? PredicatesHolderFactory.empty() : PredicatesHolderFactory.predicate(new HasContainer(T.label.getAccessor(), P.within(edgeLabels)));
SearchVertexQuery searchVertexQuery = new SearchVertexQuery(Edge.class, Arrays.asList(this), direction, predicatesHolder, -1, null, null, null, null);
return graph.getControllerManager().getControllers(SearchVertexQuery.SearchVertexController.class).stream().<Iterator<Edge>>map(controller -> controller.search(searchVertexQuery)).flatMap(ConversionUtils::asStream).iterator();
}
Aggregations