use of org.apache.tinkerpop.gremlin.structure.util.Attachable 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.apache.tinkerpop.gremlin.structure.util.Attachable 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.apache.tinkerpop.gremlin.structure.util.Attachable 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