Search in sources :

Example 1 with Attachable

use of org.apache.tinkerpop.gremlin.structure.util.Attachable in project unipop by unipop-graph.

the class UniGraphEdgeVertexStep method process.

@Override
protected Iterator<Traverser.Admin<Vertex>> process(List<Traverser.Admin<Edge>> traversers) {
    List<Traverser.Admin<Vertex>> vertices = new ArrayList<>();
    traversers.forEach(travrser -> {
        travrser.get().vertices(direction).forEachRemaining(vertex -> vertices.add(travrser.split(vertex, this)));
    });
    if (propertyKeys == null || propertyKeys.size() > 1) {
        List<DeferredVertex> v = vertices.stream().map(Attachable::get).filter(vertex -> vertex instanceof DeferredVertex).map(vertex -> ((DeferredVertex) vertex)).filter(DeferredVertex::isDeferred).collect(Collectors.toList());
        if (v.size() > 0) {
            DeferredVertexQuery query = new DeferredVertexQuery(v, propertyKeys, orders, this.stepDescriptor, traversal);
            deferredVertexControllers.forEach(deferredVertexController -> deferredVertexController.fetchProperties(query));
        }
    }
    return vertices.iterator();
}
Also used : DeferredVertex(org.unipop.schema.reference.DeferredVertex) java.util(java.util) Attachable(org.apache.tinkerpop.gremlin.structure.util.Attachable) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Collectors(java.util.stream.Collectors) Pair(org.javatuples.Pair) StepDescriptor(org.unipop.query.StepDescriptor) Direction(org.apache.tinkerpop.gremlin.structure.Direction) Traverser(org.apache.tinkerpop.gremlin.process.traversal.Traverser) Order(org.apache.tinkerpop.gremlin.process.traversal.Order) Traversal(org.apache.tinkerpop.gremlin.process.traversal.Traversal) Orderable(org.unipop.process.order.Orderable) Profiling(org.apache.tinkerpop.gremlin.process.traversal.step.Profiling) TraverserRequirement(org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement) MutableMetrics(org.apache.tinkerpop.gremlin.process.traversal.util.MutableMetrics) ControllerManager(org.unipop.query.controller.ControllerManager) UniGraph(org.unipop.structure.UniGraph) StringFactory(org.apache.tinkerpop.gremlin.structure.util.StringFactory) DeferredVertexQuery(org.unipop.query.search.DeferredVertexQuery) UniPredicatesStep(org.unipop.process.UniPredicatesStep) Edge(org.apache.tinkerpop.gremlin.structure.Edge) DeferredVertex(org.unipop.schema.reference.DeferredVertex) DeferredVertexQuery(org.unipop.query.search.DeferredVertexQuery) Attachable(org.apache.tinkerpop.gremlin.structure.util.Attachable)

Example 2 with Attachable

use of org.apache.tinkerpop.gremlin.structure.util.Attachable in project unipop by unipop-graph.

the class UniGraphEdgeOtherVertexStep method process.

@Override
protected Iterator<Traverser.Admin<Vertex>> process(List<Traverser.Admin<Edge>> traversers) {
    List<Traverser.Admin<Vertex>> vertices = new ArrayList<>();
    traversers.forEach(traverser -> {
        final List<Object> objects = traverser.path().objects();
        if (objects.get(objects.size() - 2) instanceof Vertex) {
            Vertex vertex = ElementHelper.areEqual((Vertex) objects.get(objects.size() - 2), traverser.get().outVertex()) ? traverser.get().inVertex() : traverser.get().outVertex();
            vertices.add(traverser.split(vertex, this));
        }
    });
    if (propertyKeys == null || propertyKeys.size() > 0) {
        List<DeferredVertex> v = vertices.stream().map(Attachable::get).filter(vertex -> vertex instanceof DeferredVertex).map(vertex -> ((DeferredVertex) vertex)).filter(DeferredVertex::isDeferred).collect(Collectors.toList());
        if (v.size() > 0) {
            DeferredVertexQuery query = new DeferredVertexQuery(v, propertyKeys, orders, stepDescriptor, traversal);
            deferredVertexControllers.forEach(deferredVertexController -> deferredVertexController.fetchProperties(query));
        }
    }
    return vertices.iterator();
}
Also used : DeferredVertex(org.unipop.schema.reference.DeferredVertex) java.util(java.util) Attachable(org.apache.tinkerpop.gremlin.structure.util.Attachable) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ElementHelper(org.apache.tinkerpop.gremlin.structure.util.ElementHelper) Collectors(java.util.stream.Collectors) Pair(org.javatuples.Pair) StepDescriptor(org.unipop.query.StepDescriptor) Traverser(org.apache.tinkerpop.gremlin.process.traversal.Traverser) Order(org.apache.tinkerpop.gremlin.process.traversal.Order) Traversal(org.apache.tinkerpop.gremlin.process.traversal.Traversal) Orderable(org.unipop.process.order.Orderable) Profiling(org.apache.tinkerpop.gremlin.process.traversal.step.Profiling) TraverserRequirement(org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement) MutableMetrics(org.apache.tinkerpop.gremlin.process.traversal.util.MutableMetrics) ControllerManager(org.unipop.query.controller.ControllerManager) UniGraph(org.unipop.structure.UniGraph) DeferredVertexQuery(org.unipop.query.search.DeferredVertexQuery) UniPredicatesStep(org.unipop.process.UniPredicatesStep) Edge(org.apache.tinkerpop.gremlin.structure.Edge) DeferredVertex(org.unipop.schema.reference.DeferredVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) DeferredVertex(org.unipop.schema.reference.DeferredVertex) DeferredVertexQuery(org.unipop.query.search.DeferredVertexQuery) Attachable(org.apache.tinkerpop.gremlin.structure.util.Attachable)

Example 3 with Attachable

use of org.apache.tinkerpop.gremlin.structure.util.Attachable in project unipop by unipop-graph.

the class UniGraphVertexStep method getTraversersWithProperties.

private Iterator<Traverser.Admin<E>> getTraversersWithProperties(Iterator<Traverser.Admin<E>> traversers) {
    List<Traverser.Admin<E>> copyTraversers = ConversionUtils.asStream(traversers).collect(Collectors.toList());
    List<DeferredVertex> deferredVertices = copyTraversers.stream().map(Attachable::get).filter(vertex -> vertex instanceof DeferredVertex).map(vertex -> ((DeferredVertex) vertex)).filter(DeferredVertex::isDeferred).collect(Collectors.toList());
    if (deferredVertices.size() > 0) {
        DeferredVertexQuery query = new DeferredVertexQuery(deferredVertices, propertyKeys, orders, this.stepDescriptor, traversal);
        deferredVertexControllers.stream().forEach(controller -> controller.fetchProperties(query));
    }
    return copyTraversers.iterator();
}
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) DeferredVertex(org.unipop.schema.reference.DeferredVertex) DeferredVertexQuery(org.unipop.query.search.DeferredVertexQuery) Attachable(org.apache.tinkerpop.gremlin.structure.util.Attachable)

Aggregations

java.util (java.util)3 Collectors (java.util.stream.Collectors)3 Profiling (org.apache.tinkerpop.gremlin.process.traversal.step.Profiling)3 TraverserRequirement (org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement)3 MutableMetrics (org.apache.tinkerpop.gremlin.process.traversal.util.MutableMetrics)3 Attachable (org.apache.tinkerpop.gremlin.structure.util.Attachable)3 Pair (org.javatuples.Pair)3 UniPredicatesStep (org.unipop.process.UniPredicatesStep)3 Orderable (org.unipop.process.order.Orderable)3 StepDescriptor (org.unipop.query.StepDescriptor)3 ControllerManager (org.unipop.query.controller.ControllerManager)3 DeferredVertexQuery (org.unipop.query.search.DeferredVertexQuery)3 DeferredVertex (org.unipop.schema.reference.DeferredVertex)3 UniGraph (org.unipop.structure.UniGraph)3 Order (org.apache.tinkerpop.gremlin.process.traversal.Order)2 Traversal (org.apache.tinkerpop.gremlin.process.traversal.Traversal)2 Traverser (org.apache.tinkerpop.gremlin.process.traversal.Traverser)2 Edge (org.apache.tinkerpop.gremlin.structure.Edge)2 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)2 StringFactory (org.apache.tinkerpop.gremlin.structure.util.StringFactory)2