Search in sources :

Example 1 with UniElement

use of org.unipop.structure.UniElement in project unipop by unipop-graph.

the class RowController method fetchProperties.

@Override
public void fetchProperties(DeferredVertexQuery uniQuery) {
    SelectCollector<JdbcSchema<Vertex>, Select, Vertex> collector = new SelectCollector<>(schema -> schema.getSearch(uniQuery, schema.toPredicates(uniQuery.getPredicates())), (schema, results) -> schema.parseResults(results, uniQuery));
    Map<JdbcSchema<Vertex>, Select> selects = vertexSchemas.stream().filter(schema -> this.traversalFilter.filter(schema, uniQuery.getTraversal())).collect(collector);
    Iterator<Vertex> searchIterator = this.search(uniQuery, selects, collector);
    Map<Object, DeferredVertex> vertexMap = uniQuery.getVertices().stream().collect(Collectors.toMap(UniElement::id, Function.identity(), (a, b) -> a));
    searchIterator.forEachRemaining(newVertex -> {
        DeferredVertex deferredVertex = vertexMap.get(newVertex.id());
        if (deferredVertex != null) {
            deferredVertex.loadProperties(newVertex);
        }
    });
}
Also used : java.util(java.util) DSL(org.jooq.impl.DSL) ContextManager(org.unipop.jdbc.utils.ContextManager) LoggerFactory(org.slf4j.LoggerFactory) DSL.field(org.jooq.impl.DSL.field) 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) DefaultMapEntry(org.apache.commons.collections4.keyvalue.DefaultMapEntry) org.apache.tinkerpop.gremlin.structure(org.apache.tinkerpop.gremlin.structure) org.jooq(org.jooq) TraversalFilter(org.unipop.structure.traversalfilter.TraversalFilter) MutableMetrics(org.apache.tinkerpop.gremlin.process.traversal.util.MutableMetrics) TimingExecuterListener(org.unipop.jdbc.utils.TimingExecuterListener) ElementSchema(org.unipop.schema.element.ElementSchema) UniEdge(org.unipop.structure.UniEdge) PredicatesHolder(org.unipop.query.predicates.PredicatesHolder) DeferredVertexQuery(org.unipop.query.search.DeferredVertexQuery) Collector(java.util.stream.Collector) RowVertexSchema(org.unipop.jdbc.schemas.RowVertexSchema) P(org.apache.tinkerpop.gremlin.process.traversal.P) DeferredVertex(org.unipop.schema.reference.DeferredVertex) DataAccessException(org.jooq.exception.DataAccessException) Logger(org.slf4j.Logger) HasContainer(org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer) UniElement(org.unipop.structure.UniElement) AddVertexQuery(org.unipop.query.mutation.AddVertexQuery) RowEdgeSchema(org.unipop.jdbc.schemas.RowEdgeSchema) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) JdbcEdgeSchema(org.unipop.jdbc.schemas.jdbc.JdbcEdgeSchema) PredicatesTranslator(org.unipop.common.util.PredicatesTranslator) JdbcSchema(org.unipop.jdbc.schemas.jdbc.JdbcSchema) UniGraph(org.unipop.structure.UniGraph) PropertyQuery(org.unipop.query.mutation.PropertyQuery) TraversalMetrics(org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics) SearchQuery(org.unipop.query.search.SearchQuery) java.util.function(java.util.function) MetricsRunner(org.unipop.util.MetricsRunner) DSL.table(org.jooq.impl.DSL.table) SearchVertexQuery(org.unipop.query.search.SearchVertexQuery) UniVertex(org.unipop.structure.UniVertex) DeferredVertex(org.unipop.schema.reference.DeferredVertex) UniVertex(org.unipop.structure.UniVertex) JdbcSchema(org.unipop.jdbc.schemas.jdbc.JdbcSchema) DeferredVertex(org.unipop.schema.reference.DeferredVertex)

Example 2 with UniElement

use of org.unipop.structure.UniElement in project unipop by unipop-graph.

the class DocumentController method fetchProperties.

@Override
public void fetchProperties(DeferredVertexQuery uniQuery) {
    Map<DocumentVertexSchema, QueryBuilder> schemas = vertexSchemas.stream().filter(schema -> this.traversalFilter.filter(schema, uniQuery.getTraversal())).collect(new SearchCollector<>((schema) -> schema.getSearch(uniQuery)));
    Iterator<Vertex> search = search(uniQuery, schemas);
    Map<Object, DeferredVertex> vertexMap = uniQuery.getVertices().stream().collect(Collectors.toMap(UniElement::id, Function.identity(), (a, b) -> a));
    search.forEachRemaining(newVertex -> {
        DeferredVertex deferredVertex = vertexMap.get(newVertex.id());
        if (deferredVertex != null)
            deferredVertex.loadProperties(newVertex);
    });
}
Also used : java.util(java.util) ElasticClient(org.unipop.elastic.common.ElasticClient) LoggerFactory(org.slf4j.LoggerFactory) SimpleController(org.unipop.query.controller.SimpleController) EmptyIterator(org.apache.tinkerpop.gremlin.util.iterator.EmptyIterator) Function(java.util.function.Function) Supplier(java.util.function.Supplier) AddEdgeQuery(org.unipop.query.mutation.AddEdgeQuery) RemoveQuery(org.unipop.query.mutation.RemoveQuery) Gson(com.google.gson.Gson) Order(org.apache.tinkerpop.gremlin.process.traversal.Order) TraversalFilter(org.unipop.structure.traversalfilter.TraversalFilter) SearchSourceBuilder(org.elasticsearch.search.builder.SearchSourceBuilder) BiConsumer(java.util.function.BiConsumer) MutableMetrics(org.apache.tinkerpop.gremlin.process.traversal.util.MutableMetrics) ElementSchema(org.unipop.schema.element.ElementSchema) UniEdge(org.unipop.structure.UniEdge) io.searchbox.core(io.searchbox.core) DeferredVertexQuery(org.unipop.query.search.DeferredVertexQuery) Collector(java.util.stream.Collector) Edge(org.apache.tinkerpop.gremlin.structure.Edge) DeferredVertex(org.unipop.schema.reference.DeferredVertex) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) 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) Pair(org.javatuples.Pair) BinaryOperator(java.util.function.BinaryOperator) TimeUnit(java.util.concurrent.TimeUnit) Element(org.apache.tinkerpop.gremlin.structure.Element) Stream(java.util.stream.Stream) SortOrder(org.elasticsearch.search.sort.SortOrder) UniGraph(org.unipop.structure.UniGraph) BulkableAction(io.searchbox.action.BulkableAction) PropertyQuery(org.unipop.query.mutation.PropertyQuery) TraversalMetrics(org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics) SearchQuery(org.unipop.query.search.SearchQuery) MetricsRunner(org.unipop.util.MetricsRunner) 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) QueryBuilder(org.elasticsearch.index.query.QueryBuilder)

Example 3 with UniElement

use of org.unipop.structure.UniElement 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)3 Collector (java.util.stream.Collector)3 Collectors (java.util.stream.Collectors)3 EmptyIterator (org.apache.tinkerpop.gremlin.util.iterator.EmptyIterator)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 SimpleController (org.unipop.query.controller.SimpleController)3 AddEdgeQuery (org.unipop.query.mutation.AddEdgeQuery)3 AddVertexQuery (org.unipop.query.mutation.AddVertexQuery)3 PropertyQuery (org.unipop.query.mutation.PropertyQuery)3 RemoveQuery (org.unipop.query.mutation.RemoveQuery)3 DeferredVertexQuery (org.unipop.query.search.DeferredVertexQuery)3 SearchQuery (org.unipop.query.search.SearchQuery)3 SearchVertexQuery (org.unipop.query.search.SearchVertexQuery)3 ElementSchema (org.unipop.schema.element.ElementSchema)3 DeferredVertex (org.unipop.schema.reference.DeferredVertex)3 UniEdge (org.unipop.structure.UniEdge)3 UniElement (org.unipop.structure.UniElement)3 UniGraph (org.unipop.structure.UniGraph)3 UniVertex (org.unipop.structure.UniVertex)3