use of org.unipop.schema.reference.DeferredVertex 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);
}
});
}
use of org.unipop.schema.reference.DeferredVertex 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);
});
}
use of org.unipop.schema.reference.DeferredVertex 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();
}
use of org.unipop.schema.reference.DeferredVertex 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();
}
use of org.unipop.schema.reference.DeferredVertex 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();
}
Aggregations