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();
}
Aggregations