Search in sources :

Example 1 with ElementSchema

use of org.unipop.schema.element.ElementSchema in project unipop by unipop-graph.

the class RowController method search.

@SuppressWarnings("unchecked")
protected <E extends Element, R> Iterator<R> search(UniQuery query, Map<JdbcSchema<E>, Select> selects, SelectCollector<JdbcSchema<E>, Select, R> collector) {
    if (bulk.size() != 0) {
        contextManager.batch(bulk);
        bulk.clear();
    }
    MetricsRunner metrics = new MetricsRunner(this, query, selects.keySet().stream().map(s -> ((ElementSchema) s)).collect(Collectors.toList()));
    logger.info("mapped schemas for search, schemas: {}", selects);
    if (selects.size() == 0)
        return EmptyIterator.instance();
    Iterator<JdbcSchema<E>> schemaIterator = selects.keySet().iterator();
    Set<R> collect = selects.values().stream().map(select -> this.getContextManager().fetch(select)).flatMap(res -> collector.parse.apply(schemaIterator.next(), res).stream()).collect(Collectors.toSet());
    metrics.stop((children) -> fillChildren(children, selects));
    logger.info("results: {}", collect);
    return collect.iterator();
}
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) ElementSchema(org.unipop.schema.element.ElementSchema) JdbcSchema(org.unipop.jdbc.schemas.jdbc.JdbcSchema) MetricsRunner(org.unipop.util.MetricsRunner)

Aggregations

Maps (com.google.common.collect.Maps)1 java.util (java.util)1 TimeUnit (java.util.concurrent.TimeUnit)1 java.util.function (java.util.function)1 Collector (java.util.stream.Collector)1 Collectors (java.util.stream.Collectors)1 DefaultMapEntry (org.apache.commons.collections4.keyvalue.DefaultMapEntry)1 P (org.apache.tinkerpop.gremlin.process.traversal.P)1 HasContainer (org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer)1 MutableMetrics (org.apache.tinkerpop.gremlin.process.traversal.util.MutableMetrics)1 TraversalMetrics (org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics)1 org.apache.tinkerpop.gremlin.structure (org.apache.tinkerpop.gremlin.structure)1 EmptyIterator (org.apache.tinkerpop.gremlin.util.iterator.EmptyIterator)1 org.jooq (org.jooq)1 DataAccessException (org.jooq.exception.DataAccessException)1 DSL (org.jooq.impl.DSL)1 DSL.field (org.jooq.impl.DSL.field)1 DSL.table (org.jooq.impl.DSL.table)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1