Search in sources :

Example 6 with DeferredVertex

use of org.unipop.schema.reference.DeferredVertex in project unipop by unipop-graph.

the class RestController method fetchProperties.

@Override
public void fetchProperties(DeferredVertexQuery uniQuery) {
    RestCollector<RestVertexSchema, BaseRequest, Vertex> collector = new RestCollector<>(schema -> schema.getSearch(uniQuery), (schema, result) -> schema.parseResults(result, uniQuery));
    Map<RestVertexSchema, BaseRequest> schemas = vertexSchemas.stream().filter(schema -> this.traversalFilter.filter(schema, uniQuery.getTraversal())).collect(collector);
    Iterator<Vertex> iterator = search(uniQuery, schemas, collector);
    Map<Object, DeferredVertex> vertexMap = uniQuery.getVertices().stream().collect(Collectors.toMap(UniElement::id, Function.identity(), (a, b) -> a));
    iterator.forEachRemaining(newVertex -> {
        DeferredVertex deferredVertex = vertexMap.get(newVertex.id());
        if (deferredVertex != null)
            deferredVertex.loadProperties(newVertex);
    });
}
Also used : java.util(java.util) LoggerFactory(org.slf4j.LoggerFactory) UnirestException(com.mashape.unirest.http.exceptions.UnirestException) SimpleController(org.unipop.query.controller.SimpleController) EmptyIterator(org.apache.tinkerpop.gremlin.util.iterator.EmptyIterator) UniQuery(org.unipop.query.UniQuery) AddEdgeQuery(org.unipop.query.mutation.AddEdgeQuery) RemoveQuery(org.unipop.query.mutation.RemoveQuery) TraversalFilter(org.unipop.structure.traversalfilter.TraversalFilter) ElementSchema(org.unipop.schema.element.ElementSchema) UniEdge(org.unipop.structure.UniEdge) DeferredVertexQuery(org.unipop.query.search.DeferredVertexQuery) Collector(java.util.stream.Collector) JsonNode(com.mashape.unirest.http.JsonNode) BaseRequest(com.mashape.unirest.request.BaseRequest) Edge(org.apache.tinkerpop.gremlin.structure.Edge) DeferredVertex(org.unipop.schema.reference.DeferredVertex) Logger(org.slf4j.Logger) UniElement(org.unipop.structure.UniElement) AddVertexQuery(org.unipop.query.mutation.AddVertexQuery) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Collectors(java.util.stream.Collectors) Element(org.apache.tinkerpop.gremlin.structure.Element) HttpResponse(com.mashape.unirest.http.HttpResponse) UniGraph(org.unipop.structure.UniGraph) PropertyQuery(org.unipop.query.mutation.PropertyQuery) SearchQuery(org.unipop.query.search.SearchQuery) java.util.function(java.util.function) SearchVertexQuery(org.unipop.query.search.SearchVertexQuery) UniVertex(org.unipop.structure.UniVertex) DeferredVertex(org.unipop.schema.reference.DeferredVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) UniVertex(org.unipop.structure.UniVertex) DeferredVertex(org.unipop.schema.reference.DeferredVertex) BaseRequest(com.mashape.unirest.request.BaseRequest)

Aggregations

java.util (java.util)6 Collectors (java.util.stream.Collectors)6 DeferredVertexQuery (org.unipop.query.search.DeferredVertexQuery)6 DeferredVertex (org.unipop.schema.reference.DeferredVertex)6 UniGraph (org.unipop.structure.UniGraph)6 MutableMetrics (org.apache.tinkerpop.gremlin.process.traversal.util.MutableMetrics)5 EmptyIterator (org.apache.tinkerpop.gremlin.util.iterator.EmptyIterator)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 SearchVertexQuery (org.unipop.query.search.SearchVertexQuery)4 UniVertex (org.unipop.structure.UniVertex)4 Collector (java.util.stream.Collector)3 Order (org.apache.tinkerpop.gremlin.process.traversal.Order)3 Profiling (org.apache.tinkerpop.gremlin.process.traversal.step.Profiling)3 TraverserRequirement (org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement)3 Edge (org.apache.tinkerpop.gremlin.structure.Edge)3 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)3 Attachable (org.apache.tinkerpop.gremlin.structure.util.Attachable)3 Pair (org.javatuples.Pair)3 UniPredicatesStep (org.unipop.process.UniPredicatesStep)3