Search in sources :

Example 1 with ConversionUtils

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);
}
Also used : org.apache.tinkerpop.gremlin.process.traversal(org.apache.tinkerpop.gremlin.process.traversal) java.util(java.util) Attachable(org.apache.tinkerpop.gremlin.structure.util.Attachable) LoggerFactory(org.slf4j.LoggerFactory) EmptyIterator(org.apache.tinkerpop.gremlin.util.iterator.EmptyIterator) org.apache.tinkerpop.gremlin.process.traversal.step.util(org.apache.tinkerpop.gremlin.process.traversal.step.util) PredicatesHolderFactory(org.unipop.query.predicates.PredicatesHolderFactory) Orderable(org.unipop.process.order.Orderable) Profiling(org.apache.tinkerpop.gremlin.process.traversal.step.Profiling) org.apache.tinkerpop.gremlin.structure(org.apache.tinkerpop.gremlin.structure) MutableMetrics(org.apache.tinkerpop.gremlin.process.traversal.util.MutableMetrics) PredicatesHolder(org.unipop.query.predicates.PredicatesHolder) DeferredVertexQuery(org.unipop.query.search.DeferredVertexQuery) ConversionUtils(org.unipop.util.ConversionUtils) DeferredVertex(org.unipop.schema.reference.DeferredVertex) Logger(org.slf4j.Logger) Collectors(java.util.stream.Collectors) Pair(org.javatuples.Pair) ReceivesPredicatesHolder(org.unipop.process.predicate.ReceivesPredicatesHolder) StepDescriptor(org.unipop.query.StepDescriptor) Stream(java.util.stream.Stream) TraverserRequirement(org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement) ControllerManager(org.unipop.query.controller.ControllerManager) UniGraph(org.unipop.structure.UniGraph) StringFactory(org.apache.tinkerpop.gremlin.structure.util.StringFactory) UniPredicatesStep(org.unipop.process.UniPredicatesStep) VertexStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep) SearchVertexQuery(org.unipop.query.search.SearchVertexQuery) UniVertex(org.unipop.structure.UniVertex) ConversionUtils(org.unipop.util.ConversionUtils) DeferredVertex(org.unipop.schema.reference.DeferredVertex) UniVertex(org.unipop.structure.UniVertex) SearchVertexQuery(org.unipop.query.search.SearchVertexQuery)

Aggregations

java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 org.apache.tinkerpop.gremlin.process.traversal (org.apache.tinkerpop.gremlin.process.traversal)1 Profiling (org.apache.tinkerpop.gremlin.process.traversal.step.Profiling)1 VertexStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep)1 org.apache.tinkerpop.gremlin.process.traversal.step.util (org.apache.tinkerpop.gremlin.process.traversal.step.util)1 TraverserRequirement (org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement)1 MutableMetrics (org.apache.tinkerpop.gremlin.process.traversal.util.MutableMetrics)1 org.apache.tinkerpop.gremlin.structure (org.apache.tinkerpop.gremlin.structure)1 Attachable (org.apache.tinkerpop.gremlin.structure.util.Attachable)1 StringFactory (org.apache.tinkerpop.gremlin.structure.util.StringFactory)1 EmptyIterator (org.apache.tinkerpop.gremlin.util.iterator.EmptyIterator)1 Pair (org.javatuples.Pair)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 UniPredicatesStep (org.unipop.process.UniPredicatesStep)1 Orderable (org.unipop.process.order.Orderable)1 ReceivesPredicatesHolder (org.unipop.process.predicate.ReceivesPredicatesHolder)1 StepDescriptor (org.unipop.query.StepDescriptor)1